However, continuous reads on any of the platforms still have a " real time" time delay factor even at the point of direct data input in software and even more so when subjected to human reads and interpretation.īecause of this delay, it may be prudent when designing a system to eliminate the human component and build into the RFID system automatic responses triggered by software. More readers would be utilized in such a system. Passive RFID systems and BAP systems also can be configured to give continuous information, often more economically than active RFID systems deliver it. Active RFID systems give data continuously if they are programmed to do so. Real-time should not be confused with continuous time. As good as antennas are, they cannot solve the time delay problem in a passive tag, active tag or BAP tag systems because a time delay always exists - albeit a very small time delay. But what is real-time, since whenever we read RFID data - or any data for that matter - its immediacy is, by its very nature, past time. If the ID of the detected card matches with the ID in our program, we switch ON the relay otherwise, we keep it OFF.When considering an RFID system, one of the most attractive features is its ability to provide data in real-time. We modify the original rfidReader.py to constantly check the ID of each detected card using the line if id = 1002059512185. Instead of using the LED library to control the GPIO, we declare GPIO pin 17 as an output ( tup(17, GPIO.OUT)) and we write two functions that turn ON and OFF our output pin: relay_on(pin) and relay_off(pin), respectively. Then, run the following Python code on the Raspberry Pi: import RPi.GPIO as GPIO The output should be the same as shown below. To see if this operation has been successful, we read the information on the RFID card by re-running the sudo python3 rfidReader.py command. In this case, we write the string Circuit basics to the card. Everything else stays the same, except that we invoke the rfid.write("Circuit basics") when we bring the card closer to the RFID writer. So we execute the code above as many times as we want to write to different cards. This is mainly because we do not want to write the same information on different cards. import RPi.GPIO as GPIOĪ notable difference between rfidReader.py and rfidWriter.py is that we do not have a while loop in the latter. We create a file called rfidWriter.py and paste the code below. We can see how this works in the code below. To write information on the RFID card, we use another method of the RFID object: rfid.write(). This tells us that our RFID card has the ID 1002059512185 while the RFID tag has the ID 588633495959. You should see something like this being printed to the terminal: Run the Python code above by entering the command sudo python3 rfidReader.py in the terminal. We have placed this code in an infinite loop, which means that the Raspberry Pi will continuously read the output from the RFID module. To read the RFID card date, we call the read() function and store its output in the variables id and text.įinally, we print the ID and text of the card to the terminal with print(id) and print(text), respectively. Then we use rfid = SimpleMFRC522() to create a new object which we will call RFID. import RPi.GPIO as GPIOįirst, we import the necessary modules. Then, create a Python file rfidReader.py and paste the following code. To do this, connect the components as shown in the diagram above. Our first step will be to read the information on the RFID card. Then, install the MFRC522 Python library with the following command: sudo pip3 install mfrc522 Code to Read the RFID Card You also need to install pip3 with this command: sudo apt-get -y install python3-pip How to Program the RFID Card Reader with Pythonīefore we get started programming, make sure the SPI interface is enabled on your Raspberry Pi.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |