Shop OBEX P1 Docs P2 Docs Learn Events
Parallax 28440 RFID R/W Module not working as expected — Parallax Forums

Parallax 28440 RFID R/W Module not working as expected

rabiesrabies Posts: 3
edited 2017-01-09 16:55 in Accessories
hey all, first time/long time/great to be here and all that jazz.

So I have a 28440 module that I've hooked up to my pi (version 3) and I have yet to see anything resembling a red led go on. I've seen the green turn off, but no red. I'm also unable to get any data from the module. TX appears to work because I can get the LED to go off and on when attempting to read the tag serial, but the rx buffer is empty. I read here and elsewhere for something remotely resembling my situation without any help so it's time to post. I've got a pi3 with the GPIO ribbon attached to the breadboard. Jumpers going from 5v DC to vcc, gnd to gnd, tx to sin, rx to sout. Not my first rodeo, I can at least follow those basic instructions. Since I have to do things the hard way and it seems nobody here uses python for these modules, that's what I'm using in conjunction with pyserial. Below is a snippet of what I'm attempting.
#!/usr/bin/python
import serial
from time import sleep

ser = serial.Serial('/dev/serial0', 9600, timeout=5)
ser.write('!RW')
ser.write('\x01')
sleep(2)
ser.write('32')
if ser.in_waiting > 0:
    res_code = ser.read(1)
    if res_code == '\x01':
        tag_id = to_hex(ser.read(4))
        print('[*] Tag ID is: ' + tag_id)
    else:
        print('[-] Great you broke it')

Comments

  • kwinnkwinn Posts: 8,697
    Not familiar with python but if "ser.write('!RW')" is sending the ascii characters "!RW" then wouldn't "ser.write('\x01')" be sending the ascii characters "\x01" rather than the single byte address that should be between decimal 1 and 33 that the read command requires?
  • Actually, it doesn't. the !RW is sent as ascii and the response from the write is the length of the data sent so the output looks like this
    >>> ser.write('!RW') #3 bytes ascii
    3
    >>> ser.write('\x01') #1 byte hex
    1
    >>> ser.write(32)  # This where I think part of my problem is
    2
    

    Now the last bit I think might be messing with me and I stole some code from someone that already reinvented the wheel in python for this module, but still come out with similar results. His code is almost identical to mine except for taking the raw input from a prompt for address to read putting it into the addr variable and then sending it over like below, but with the same result and still no red LED:
    >>> rfid.write(chr(int(addr))) # printing chr(int(addr)) outputs ' ' when addr = 32
    1
    >>> rfid.in_waiting
    0
    

    I don't supposed there's any sort of diagnostic command I could throw at this thing which isn't outlined in the comm protocol doc to see if the module is hosed or not? Probably a long shot, I know.
  • kwinnkwinn Posts: 8,697
    Try "ser.write('\x20')" instead of "ser.write(32)". Like I said, not familiar with python, but that should output the one byte address the RFID module requires since the "ser.write('\x01')" statement seems to have sent a single byte.
  • I'll give that a shot today, but just to keep the conversation going in the interim, I should at least be getting some sort of error back regardless of the garbage in, right? At least that's how I am reading the documentation.
  • kwinnkwinn Posts: 8,697
    rabies wrote: »
    I'll give that a shot today, but just to keep the conversation going in the interim, I should at least be getting some sort of error back regardless of the garbage in, right? At least that's how I am reading the documentation.

    Not sure what if anything is returned if unexpected data/commands are sent. The data sheet lists seven possible error codes, and I would expect a status value of "0x03" to be returned, but cannot say for sure.
Sign In or Register to comment.