How to make a time marking machine with Rasberry and Nios4 (second part)
Cloud database creation and first sync
In this second article, we will install the Python programs to read the RFID data, check their validity, and send them to your cloud database for storage and sharing.
If you missed the first part of the guide about how to make an attendance marking device with Raspberry and Nios4, click here to make it up.
After checking that all components work and have access to the Raspberry, create an account on the website web.nios4.com.
Once you sign in, the site will ask you to choose a template to create the first database. In the GitHub project that you downloaded in the previous article, there is a package for creating the database to use.
By choosing a custom template or using the Install Package command inside the Help menu of all the open repositories, select and install the attendance_makers.nios4 file. This directory will create the databank with all the fields and tables you need to use in this example.
After installing the database, you are ready to add the Python libraries inside the Raspberry.
Python libraries for the first data synchronization
Download the data synchronizer project from GitHub at the following link:
Now, open the test.py file to enter your account details and the database name. In the web version, this name is located on the lower right part of the screen.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#========================================================== #TEST SYNC NIOS4 #========================================================== from sync_nios4 import sync_nios4 username = "username" password = "password" dbname = "dbname" sincro = sync_nios4(username,password) value = sincro.login() if sincro.err.error == True: print("ERROR -> " + sincro.err.errormessage) sincro.syncro(dbname) if sincro.err.error == True: print("ERROR -> " + sincro.err.errormessage)
In the file, set the username, password, and dbname variables. The following commands launch the synchronization class and log in to the server. Furthermore, they check the effective validity of the credentials and, as the last thing, perform the database synchronization.
Give the command below and launch the program:
In the first synchronization, the program creates the “db” folder and the SQLite3 database file. It sets the basic structure of the Nios4 databases and downloads all the data.
If the operation is successful, you will have a copy of your cloud data on the Raspberry.
The program for the attendance marking device
Type the following command to launch the program:
If everything goes well, the time marking machine should look like this:
In the first line of the LCD screen, the current date and time should appear, while in the fourth line there should be written “D-One” and the IP address. In case the latter is 127.0.0.0, it means that the attendance marking machine is not connected to the network.
Now, place the badge closer to the RFID reader. If the ID number is registered, the name of the owner will be displayed; otherwise, “Invalid Badge” and the ID number will appear. In this event, copy the number and enter it into the database to associate this RFID to the user.
Remember to re-synchronize both the program where you entered the users and the time marking machine. This way, the device can receive data.
These are the steps to make a time marking machine for the office by using Raspberry and the Nios4 management software as the infrastructure for data interchange.