Hi @Mitchyr67
Welcome to the forum!
I’ve put together some code to get you started, you will need to make sure you have the Piicodev Unified package installed on your Pi.
from PiicoDev_RFID import PiicoDev_RFID
from PiicoDev_Unified import sleep_ms
import time
import math
import machine
#Intitalise the readers
reader = PiicoDev_RFID # Initialise the RFID module with both address switches OFF
#intialising the basic RFID module function for read
rfid = PiicoDev_RFID()
file_name = "attendance.csv"
with open(file_name, 'w') as file:
file.write("Name, ID, Date,Time\n")
def printTagDetails(name, ID):
print(0*" " + 'Name: ' + name) # print the persons name
print(0*" " + 'ID: ' + ID) # print the persons ID number
def log_tag(time):
# Get current local time
current_time = time.localtime()
formatted_date = "{:02}/{:02}/{:04}".format(current_time[2], current_time[1], current_time[0])
formatted_time = "{:02}:{:02}:{:02}".format(current_time[3], current_time[4], current_time[5])
# Combine name, ID, date and time into a single CSV line
csv_line = "{},{},{},{}\n".format(name, ID, formatted_date, formatted_time)
# Append the CSV line to the file
with open(file_name, 'a') as file:
file.write(csv_line)
#Start of code
print('Checking Slots\n')
while True:
if reader.tagPresent(): # if an RFID tag is present on reader
rawData = reader.readText().split() # get the info from the tag
name, ID = rawData[:2] # assign the elements in rawData into individual variables
printTagDetails(name, ID) # Call function to output tag details
log_tag(time)
sleep_ms(500)