Perhaps use this to get rid of the trailing “x03”:
print(“RFID Info without first and last byte:{}:”.format(rng[1:-1]))
Perhaps use this to get rid of the trailing “x03”:
print(“RFID Info without first and last byte:{}:”.format(rng[1:-1]))
Please post the info here for the next tortured soul that tries this feat you have succeeded with.
Of course!
GrovePi+ - Grove RFID (125kHz) Reader - Raspberry Pi 4 - Step by Step
Setting up the Software (check this)
Enable UART by editing the config.txt (The jumper on the reader has to be on the left side!)
sudo nano /boot/config.txt
Add this line at the end of the file
enable_uart=1
sudo raspi-config
sudo nano /home/pi/Dexter/GrovePi/Software/Python/rfid_read.py
Paste this code and save the file
#!/usr/bin/env python3
# FILE: rfid_read.py
# USAGE: sudo python3 rfid_read.py
# REFERENCES:
# Serial API: https://pyserial.readthedocs.io/en/latest/pyserial_api.html
# Grove RFID Sensor: https://wiki.seeedstudio.com/Grove-125KHz_RFID_Reader/
import serial
import time
rpiser = serial.Serial("/dev/ttyS0", 9600, timeout=1)
rpiser.flush()
while True:
print("active, waiting...")
# wait until first byte is seen in the serial stream
while rpiser.in_waiting == 0: # note that in_waiting is a property in Python3
time.sleep(0.005)
# Bytes coming in! Wait until the 1s timeout to get them all
time.sleep(1.0)
bytes_available = rpiser.in_waiting
print("Tag Detected with {} bytes ready".format(bytes_available))
rfid = rpiser.read(bytes_available)
print("RFID Info:{}:".format(rfid))
print("RFID Info without first and last byte:{}:".format(rfid[1:-1]))
Now let’s start the script
sudo python3 /home/pi/Dexter/GrovePi/Software/Python/rfid_read.py
pi@raspberrypi:~/Dexter/GrovePi/Software/Python $ sudo python3 rfid_new2.py
active, waiting...
Tag Detected with 14 bytes ready
RFID Info:b'\x02380040B539F4\x03':
RFID Info without first and last byte:b'380040B539F4':
active, waiting...
I’m very thankfull for the help of @cyclicalobsessive !!
I hope this will help in future!
For those of you who have never dealt with Wiegand access control cards, a Wiegand card is a plastic card, about the same size as a credit card, that has two rows of metal pins across the bottom of the card. One row is the “bit” row and the other row is the “clock” row. The presence of a metal pin in the bit row indicates a “1” and the absence of a pin indicates a “0”
A Wiegand reader has four wires: +5, ground, data, and clock - which are driven low when an associated pin is read within the card.
Here are two interesting articles, one on the interface itself and the other on the Wiegand effect.
I used to work with the “original” swipe-type Wiegand cards in the middle 90’s when I was working for a big access control system manufacturer on Long Island.
The readers had a distinctive shape and were potted with what can only be described as kryptonite () because it required an atomic blast to remove it. (And yes, I tried.)
Interesting factoid:
Back when I was working with access control systems I was told that the Wiegand interface had two signal lines:
And depending on which row on the card had a wire, either the “1” or “0” line would toggle.
Today while I was researching this, I found a site that claimed that a Wiegand card had one row of wires for data and the second row was a “clock” row, with all bit positions occupied to generate a coherent clock for the data.
“Hmmm. . .” I thought. “That’s not the way I remember it, but who knows, that that was a long time ago. And who knows, I could be loosing my grip.”
Turns out that when I read the physical interface part of the Wikipedia article on Wiegand, they mentioned two things:
— AND —
Maybe I’m not loosing my mind after all?