Update 9 files

- /image.png
- /.vscode/settings.json
- /image-1.png
- /image-2.png
- /image-3.png
- /image-4.png
- /image-5.png
- /image-6.png
- /README.md
This commit is contained in:
jpd committed 2026-07-24 14:20:44 +01:00
1 parent 1091209fe9
commit aeadc97848
9 files changed
+95 -87

No files matched your search

+90 -87
View File
@@ -1,93 +1,96 @@
# PiClock
Custom made replacement of traditional Punchcard-Systems with NFC cards and a Raspberry Pi instead.
![alt text](image.png)
Materials required:
- Raspberry Pi2 (32bit) (when tested on Pi 4 or newer struggled as it's 64bit and too fast)
- Pi2 PSU
- Wifi dongle (Pi2 does not have wifi)
- NFC HAT (e.g. PN532 NFC HAT)
- LCD screen HAT (e.g. ELEGOO 3.5 Inch 480x320 TFT Display HAT)
- mini speaker (buzzer)
- 100x NFC cards (NTag215 the box they came in is perfect size for building a case cutting off the front to reveal the LCD screen and a slot on the side to "swipe" the NFC cards)
Steps I broadly took if memory serves, might need tweaking for different scenarios:
1. Install default Pi OS legacy 32 bit (bullseye)
2. sudo raspi-config to enable SSH,SPI,i2c,GPIO etc...
3. nano .ssh/authorized_keys to add your ssh pubkey for passwordless access (optional)
4. sudo apt update && sudo apt upgrade -y
5. sudo apt install python3-serial* libusb-dev libpcsclite-dev libtool automake autoconf gpiod pip samba ntp inotify-tools install setuptools -y
6. sudo pip3 install git+https://github.com/nicmcd/vcgencmd.git
7. sudo pip3 install -e .
8. wget https://files.waveshare.com/upload/8/85/Pn532test.zip
9. wget https://files.waveshare.com/upload/6/66/Pn532-nfc-hat-code.7z
10. git clone https://github.com/nfc-tools/libnfc.git
11. git clone https://github.com/nfc-tools/mfoc.git
12. autoreconf
13. ./configure --prefix=/usr --sysconfdir=/etc
14. make
15. sudo make install
16. gpioinfo (to check GPIO connections)
17. nfc-list (to check NFC HAT is working properly)
18. Edit py scripts to use I2C comms (Serial/UART and SPI did not work for me)
19. cp the example_get_uid.py into your clockin.py project file and adjust or check out my example
20. the script needs a times.csv file, it will add one line per "swipe" or "punch"
I created an Excel to prototype first then a php page on a different machine that presents the data.
The Excel filters out the 3 columns we need (card id, day/month and time/hour:minute)
some formulas I used to strip unwanted repeated characters from the Card IDs and timestamps:
CARD =SUBSTITUTE(CONCAT(MID(B2,6,1),MID(C2,5,2),MID(D2,5,2),MID(E2,5,2),MID(F2,5,2),MID(G2,5,1),MID(H2,5,2)),"'","")
day =CONCAT(MID(J2,11,2),"/",MID(J2,8,2))
time =MID(J2,14,5)
Name assignement: =XLOOKUP([@CARD],Info!$A$2:$A$101,Info!$B$2:$B$101,"UNREGISTERED")
Advanced Filter:
List Range =$K$1:$M$ (LastLineNr)
Criteria Rg= $K$2:$M$2
But alas you build you own... I used a Pivot table and it was nice... good excersise...
But I added the examples of the php pages I created at the end which are better as no Excel Client needed...
Everyone has a browser! and if opened on mobile, can be a neat webapp... see the php examples for similar results
You want to keep the Pi as lean as possible, I edited the PiOS desktop:
- desktop color: black
- have only the top panel, background black, text white
- strip everything from the top panel except the time
- make the top panel as big as possible to fit the LDC screen
I also created some services on it:
- Service that constantly reads the NFC reader and write it to times.csv (adapted python script from NFC manufacturer)
- Service that makes a copy of the times.csv and names.csv to a NAS and to another PC with a LAMP docker install
(Optional) I created a crontab that runs a trim of old data, keeps only last 6 months, can be adjusted...
These Services keep the pi lean and the logic / webpage / Excel get their data from the NAS or from the PC. This way the pi only takes care of showing the time on the LCD,
reading the cards with a confirmation beep, and copying the csv files somewhere else for processing (the NAS and webserver aka. an UbuntuVM with docker-compose-lamp on a "PVE-PC" in my case).
In my python script I added the sensor temp of the CPU for monitoring / troubeshooting reasons, but is not shown anywhere in my example. In my experience the pi with a heatsink never got too hot (under 60 celsius all the time, even on hot days).
The PC that hosts the webapp (a php page really running on mounted volume of a docker-compose-lamp installed on an UbuntuVM...) takes care of all the logic. The Excel only needs access to the NAS and also takes care of all the logic. As mentioned above, the pi uploads the names and times csv files to them when NFC cards are swiped...
UPDATE: for testing I added scanner.html to www that used on a Chrome on an Android phone can be used to swipe cards and write the timstamps and card code to the mysql in the lamp docker composer portainer stack. However, for securuty reasons this needs to run via https. I used my vpnstack with duckdns to sign free let's encrypt certificates to make it work.
![alt text](image-1.png)
![alt text](image-2.png)
![alt text](image-3.png)
![alt text](image-4.png)
![alt text](image-5.png)
![alt text](image-6.png)
EDIT: Added roadmap in TODO.md for hardening. First a ban2fail implementation should be in place though... also added Barcode support on the staff names mgmt.
## Getting started
Prototyped, Proyected and Created by F.Javier "habiwan" Puig Diaz (https://github.com/habiwan).
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
All software used is GPL licenced and hence there is no warranty for this modified free software either.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
* [Create](https://docs.gitlab.com/user/project/repository/web_editor/#create-a-file) or [upload](https://docs.gitlab.com/user/project/repository/web_editor/#upload-a-file) files
* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://gitlab.com/habiwan/piclock.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
* [Set up project integrations](https://gitlab.com/habiwan/piclock/-/settings/integrations)
## Collaborate with your team
* [Invite team members and collaborators](https://docs.gitlab.com/user/project/members/)
* [Create a new merge request](https://docs.gitlab.com/user/project/merge_requests/creating_merge_requests/)
* [Automatically close issues from merge requests](https://docs.gitlab.com/user/project/issues/managing_issues/#closing-issues-automatically)
* [Enable merge request approvals](https://docs.gitlab.com/user/project/merge_requests/approvals/)
* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
## Test and Deploy
Use the built-in continuous integration in GitLab.
* [Get started with GitLab CI/CD](https://docs.gitlab.com/ci/quick_start/)
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/user/application_security/sast/)
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/topics/autodevops/requirements/)
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/user/clusters/agent/)
* [Set up protected environments](https://docs.gitlab.com/ci/environments/protected_environments/)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
Exception: /*! JsBarcode v3.11.5 | (c) Johan Lindell | MIT license */