Saturday, May 25, 2013

RFID via USB for the Beaglebone Black or pcDuino Using the Innovations ID-20LA & Sparkfun RFID USB Board

The Innovations ID-20LA is a 125 kHz RFID tag reader that works with input voltages from 2.8 to 5 volts. The Sparkfun RFID USB Reader (Board) provides a socket for the ID-20LA (with its 2mm pin spacing) a mini-USB (B) connector, and broken out pins for a serial connection.

Using the mini-USB connection, it is very easy to connect it to the Beaglebone Black.  The Ångström Linux distribution that comes installed on the Beaglebone Black includes the FTDI-SIO driver/kernel module, so no additional drivers are needed. When connected to the Beaglebone, the RFID reader is mapped to the serial device /dev/ttyUSB0.

For a Python script to read from a serial device, you do need to install the PySerial package (opkg install python-pyserial).


Python Code


import serial
serial = serial.Serial("/dev/ttyUSB0", baudrate=9600)

code = ''

while True:
        data = serial.read()
        if data == '\r':
                print(code)
                code = ''
        else:
                code = code + data

pcDuino 


When working with the pcDuino, everything is the same as for the Beaglebone, except for the command to install the PySerial package. On the pcDuino use the command apt-get install python-serial.

1 comment:

  1. Very usefull tutorial. We forward your post to learn.linksprite.com. If you have any other new post about pcDuino(www.pcduino.com) or any other LinkSprite's(www.linksprite.com) products, please feel free to let us know. If you have a new post, could you please give us a backlink?

    ReplyDelete