LF RFID with Pico and RS-232 #15947
Replies: 2 comments 10 replies
-
You can use a logic analyzer to check the signal between the RFID reader and the Pico. This will help verify if commands are being sent and if the reader is responding. |
Beta Was this translation helpful? Give feedback.
-
UPDATE: I have a new code and now I have the communication with the antenna solved, but I get a tag-ID with tag in front of the antenna, but also without tag in front of the antenna. Help is welcome! Code: Initialize UART1 with TX on GP0 and RX on GP1uart = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1)) Function to send command to the readerdef send_command(command): Function to check if Antenna 1 is selecteddef select_antenna_1(): Function to read RFID tag datadef read_rfid():
Main loop to read RFID tagswhile True: |
Beta Was this translation helpful? Give feedback.
-
I am trying to detect a LF RFID tag with a Raspberry Pi Pico, a RS-232 module, a reader with an external antenna. When I run the code, it doesn't detect the RFID tag. I don't know why it does not detect the tag. Any help is wellcome.
The code:
from machine import UART, Pin
import utime
Initialize UART1 on TX pin GP8 and RX pin GP9
uart = UART(1, baudrate=9600, tx=Pin(8), rx=Pin(9))
Function to send command to RFID reader
def send_command(command):
uart.write(bytearray(command)) # Send command as bytearray
print(f"Command sent: {command}")
utime.sleep(0.1) # Short delay for processing
Function to read data from RFID reader
def read_rfid():
if uart.any(): # Check if there is data available
rfid_data = uart.read() # Read the data
print(f"Raw data received: {rfid_data}")
return rfid_data # Return the raw data
return None
Function to select antenna 1 for reading
def select_antenna_1():
# Command to select and tune antenna 1 (based on the documentation)
command = [0x04, 0xF2, 0xA0, 0x01, 0xB0] # Last byte is the BCC
send_command(command)
Function to poll for HDX/FDX transponders on antenna 1
def poll_for_tags():
command = [0x03, 0xEA, 0x11, 0xFC] # Poll HDX and use antenna 1
send_command(command)
Send the command to select antenna 1 and start reading RFID data
select_antenna_1()
while True:
# Poll for tags on the selected antenna
poll_for_tags()
tag = read_rfid() # Try reading RFID data
if tag:
print(f"RFID Tag Read: {tag}")
else:
print("Waiting for RFID tag...")
Beta Was this translation helpful? Give feedback.
All reactions