3

I just purchased the RFIDRW-E-USB RFID reader from Priority 1 Design (see this page, datasheet available in PDF form.)

I have tried to make it work on my computer (Ubuntu), before plugging it to my Raspberry Pi, but I had not luck so far and I am running out of ideas on how to make it work.

I connected the provided antenna to the A+ and A- nodes on the board but did not solder it in place, as I plan on installing another antenna later and I'm not really good at welding. (I made sure the stripped part of the wire was touching a metal part on the board, and taped them in place.)

Then, I plugged the whole thing in my computer, and I can see the board as /dev/ttyUSB0.

Then, inspired by the code for a Parallax RFID reader (from here), I tried the following in Python (with super user privilege):

import serial

device = serial.Serial("/dev/ttyUSB0", 2400, timeout=5)
while True:
    tag = device.read(12)  # Tries to read the ISO tag format made of 12 digits
    if len(tag) != 0:  # If something has been read, print it then break out of the loop
        print tag
        break

When I approach a tag, nothing happens.

Is there a flaw in my method? What is the most likely cause of error in these steps?

EDIT: After contacting their customer support, I have been told to use a virtual com port driver to communicate with the FTDI chip, from here. Since I want to code in python, I will try various python modules for FTDI chips.

EDIT2: So now I can communicate with my device, but only in interactive mode. I can use screen to connect: sudo screen /dev/ttyUSB0. Then, I can use the various commands shown in the datasheet. If I enter ver (followed by a carriage return), I receive the expected output ?09. Now I just need to do the same in Python...

EDIT3: The FTDI chip is FT232RL. Google shows me a lot of people successfully using this chip with Python (in bitbang mode). There must be something simple I'm missing...

2
  • what is your script for the virtual com port driver? I'm trying to use the same rfid reader, but i'm stock and looking for all the possibilities. Aug 4, 2017 at 14:59
  • It has been a while since I worked with it, but from what I remember, I did not use any other script or driver. It was all in the default serial module of python.
    – PhilMacKay
    Aug 11, 2017 at 21:14

1 Answer 1

2

One of the good points about Python is that you can use it interactively.

From a command prompt type python.

Then try out the commands.

import serial
import time

device = serial.Serial("/dev/ttyUSB0", 2400)

while True:

   print(device.read(12)) # important to indent this line
   time.sleep(1)  # important to indent this line

# press return here to execute the while loop
# control C to abort while loop

device.write("ver")
device.read(12)

Anything you can get working interactively will work in a script.

3
  • That is the weird thing: When I have /dev/ttyUSB0 open in screen, then I do device.write("ver") (in another terminal), I see the reply in screen. But, when I try device.read(12) in python, I get nothing (an empty string).
    – PhilMacKay
    Nov 25, 2014 at 20:26
  • I'm not familiar with the serial module you are using. Rather than read(12) which may block until 12 bytes are available I'd call a function which spins testing for data availability (inWaiting) then reads/prints that number of characters.
    – joan
    Nov 25, 2014 at 20:37
  • Your python program may not be opening the device with the right settings to run by itself. Jan 26, 2015 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.