I've tried several programs to capture the serial number of 2 USB RFID Reader.

  1. I use 2 Mifire RFID (named RFID A & RFID B) and they connected to my Raspberry Pi.
  2. I want the Raspberry Pi capturing one of RFID reader when active or RFID detected smart card (the serial number of smart card).
  3. Some I know that, when someone brings a smart card near RFID A, the Raspberry Pi can detect that it is from RFID A (not from RFID B)

I've tried Python but it doesn't work. here's that code:

 import usb.core 
 import usb.util

 VENDOR_ID = 0x1130 
 PRODUCT_ID = 0x0001 
 DATA_SIZE = 167

 device = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID) 
 if device.is_kernel_driver_active(0): 
 except usb.core.USBError as e: 
   sys.exit("Could not detatch kernel driver: %s" % str(e)) 

 endpoint = device[0][(0,0)][0] 

and here another one

 import serial 
 import time

 serial = serial.Serial("/dev/ttyAMA0", baudrate=2400)
 while True: 
    if serial.inWaiting() > 0: 
        read_result = serial.read(12) 
        print("Read card {0}" . format(read_result.decode(encoding='utf-8')))
        print("Sleeping 2 seconds")
        serial.flushInput() # ignore errors, no data

The easiest way I've found is to use the MFRC522 (mifare) SPI card reader on the Raspberry Pi with this library-


Comes with examples and is fairly straightforward.

For the USB readers, most of them simply read the UID and output it as either serial or HID(keyboard) output. Buit there are some fully capable USB readers.

It would help to know the exact model of your USB readers.

If you are using the same model and they BOTH use serial, then you'll probably need to add another UART (you can get an I2c->Serial breakout for just a few $) The Pi has only one serial port and does not do software serial well.

If one of your readers is of the HID type, then you can look for the input at some variation of /dev/input/keyboard


This python code is working for me. I'm using a Parallax RFID.

Continuously read.

import serial
ser = serial.Serial('/dev/tty.usbmodem1411', 9600) # here you have to write your port. If you dont know how to find it just write ls -l /dev/tty.* in your terminal (i'm using mac)

while True:
        response = ser.readline()
        print response
    except KeyboardInterrupt:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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