Saturday, May 4, 2013

RFID for the pcDuino using the Innovations ID12 & Sparkfun RFID USB Reader Breakout

I have posted on my other blogs about using the ID12 RFID reader (125 kHz) with the Sparkfun USB Reader Breakout to provide an easy way to connect the RFID reader by a serial (UART) connection to a Raspberry Pi  or an Arduino Uno. While the name of the breakout board makes it clear that it is primarily intended for USB connections, the board breaks out the pins for connecting to the serial pins (digital 0 & digital 1) on the pcDuino.  The simple Python code in this example is the same as the code used with the Raspberry Pi.

The code requires the PySerial module. You can install it using the following apt-get command (assuming your pcDuino has functioning network connection):

sudo apt-get install python-serial

Connections:


RFID Breakout  pcDuino
VCC            5V
GND            GND
TX             Digital 0 (RX)
TXR            Digital 1 (TX)


Python Code: 


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

code = ''

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


If you have problems with getting serial I/O to work on the pcDuino's 0 and 1, try the setuart2 utility discussed in the pcDuino forum

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