Notes About Working with Various Arduino & Netduino Microcontroller Boards

Thursday, May 8, 2014

RFID Using the Innovations ID20-LA with the Arduino Yun's USB Host Port

I've posted previously about using the Innovations ID20-LA and the Sparkfun RFID Reader breakout board with the Arduino Yun.  My earlier post used the serial break-out pins on the reader board to connect to the Yun using SoftwareSerial (on the Arduino side of the Yun).  It is also possible to use the USB connector on the reader board to connect to the Yun's USB host port.  The correct FTDI driver and Python pySerial library make this method very easy to use. In this case, the USB host is accessed via the Linux side of the Yun.

The following instructions assume that you are connected to the Yun via SSH. Log in using an account with root privileges.  You could also use the YunSerialTerminal example to access the command prompt.

First, make sure that your opkg package data is up to date:

opkg update

Then install the FTDI driver:

opkg install kmod-usb-serial-ftdi

After the FTDI support is installed, connect the reader and reader break-out board.  You should see the serial USB device in the device tree as /dev/ttyUSB0.

The following opkg command installs 

opkg install pyserial

You can run a quick test using the following 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


No comments:

Post a Comment