I am a complete newbie with Raspberry Pi and any type of hardware prototyping. I have been trying to get a Parallax RFID working with my Pi 3.

I currently have it wired to the GPIO using BCM and the following pins

VCC -> 5V

/Enable -> Pin 4

SOUT -> Pin 15


I then use a python script:

import RPi.GPIO as GPIO
import serial

ENABLE_PIN  = 4              # The BCM pin number corresponding to GPIO1
SERIAL_PORT = '/dev/ttyAMA0'  # The location of our serial port.  This may
                          # vary depending on OS version.

def validate_rfid(code):
# A valid code will be 12 characters long with the first char being
# a line feed and the last c har being a carriage return.

s = code.decode("ascii")
if (len(s) == 12) and (s[0] == "\n") and (s[11] == "\r"):
    # We matched a valid code.  Strip off the "\n" and "\r" and just
    # return the RFID code.
    return s[1:-1]
    # We didn't match a valid code, so return False.
    return False

def main():
# Initialize the Raspberry Pi by quashing any warnings and telling it
# we're going to use the BCM pin numbering scheme.

# This pin corresponds to GPIO1, which we'll use to turn the RFID
# reader on and off with.

# Setting the pin to LOW will turn the reader on.  You should notice
# the green LED light on the reader turn red if successfully enabled.

print("Enabling RFID reader...\n")

# Set up the serial port as per the Parallax reader's datasheet.
ser = serial.Serial(baudrate = 2400,
                    bytesize = serial.EIGHTBITS,
                    parity   = serial.PARITY_NONE,
                    port     = SERIAL_PORT,
                    stopbits = serial.STOPBITS_ONE,
                    timeout  = 1)

# Wrap everything in a try block to catch any exceptions.
    # Loop forever, or until CTRL-C is pressed.

    while 1:
        # Read in 12 bytes from the serial port.
        data = ser.read(12)
        # Attempt to validate the data we just read.
        code = validate_rfid(data)

        # If validate_rfid() returned a code, display it.
        if code:
            print("Read RFID code: " + code);
except Exception:
    # If we caught an exception, then disable the reader by setting
    # the pin to HIGH, then exit.
    print ("Couldn't do it: %s" % e)
    print("Disabling RFID reader...")

if __name__ == "__main__":

The script runs and shows "Enabling RFID reader..." and then nothing when I pass chips in front of the reader.

I have ensured that Serial is enabled in config and I have tried both /dev/ttyAMA0 and /dev/ttyS0 (as I have read that ttyS0 is for Pi 3s)

I have tried multiple RFID cards that I got from Parallax for testing, and a couple cards from around the office that I know work with other readers.

I am at a loss on where to go from here. Any help or pointers would be greatly appreciated.

UPDATE: I found information about changing the /boot/cmdline.txt to remove "console=serial0,115200" so I did. This did not change the results.

1 Answer 1


I know that this is an old post, but I will try to answer anyways, as I am doing the exact same setup at my job at the moment.

Have you enabled UART in the config.txt?

sudo nano /boot/config.txt

Then at the bottom, add this line:


Then try to reboot and see if that works.

Context: For some reason, UART is disabled as default in the newer versions of Raspbian.

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.