Hi,
I am trying to get the PiicoDev RFID module to work. Current setup is a RPi5 with Python 3.11.2 and all the hardware connected.
What is happening is that I have all the required Python packages in one folder and when I run the read_id.py program in Thonny, a number of errors and warnings come up. I’m a complete novice to Python and it might have been something in the setup or version of the programs. Can anyone give me a leg up please.
Cheers,
Olle
Here are the errors I get when I’m running the read_id.py file:
%Run read_id.py
/home/olle/PiicoDev/PiicoDev_RFID.py:72: SyntaxWarning: “is” with a literal. Did you mean “==”?
assert max(asw) <= 1 and min(asw) >= 0 and len(asw) is 2, “asw must be a list of 1/0, length=2”
Traceback (most recent call last):
File “/home/olle/PiicoDev/read_id.py”, line 4, in
rfid = PiicoDev_RFID() # Initialise the RFID module
File “/home/olle/PiicoDev/PiicoDev_RFID.py”, line 69, in init
self.i2c = create_unified_i2c(bus=bus, freq=freq, sda=sda, scl=scl)
File “/home/olle/PiicoDev/PiicoDev_Unified.py”, line 187, in create_unified_i2c
i2c = I2CUnifiedLinux(bus=bus, suppress_warnings=suppress_warnings)
File “/home/olle/PiicoDev/PiicoDev_Unified.py”, line 127, in init
self.i2c = SMBus(bus)
File “/usr/lib/python3/dist-packages/smbus2/smbus2.py”, line 280, in init
self.open(bus)
File “/usr/lib/python3/dist-packages/smbus2/smbus2.py”, line 310, in open
self.fd = os.open(filepath, os.O_RDWR)
FileNotFoundError: [Errno 2] No such file or directory: ‘/dev/i2c-1’
errors I get:
1 Like
Hi @Olle185132
Welcome Welcome.
Ah I can guess what’s going on here.
Because your raspberry pi doesn’t know what i2c_1 is yet it’s struggling to make sense of what is
could mean. To personify awfully, The script is asking “what am I supposed to be comparing to?”
We need to activate the i2c_1 bus so your script can access and identify it.
This error below is trying to tell you that you haven’t activated the i2c bus on your raspberry pi5. /dev
is short for devices
FileNotFoundError: [Errno 2] No such file or directory: ‘/dev/i2c-1’
If your using the desktop version of raspberry pi os, I believe there is a gui that can help you. I had to search up where it is, apparently you can find it at:
Pi Start Menu > Preferences > Raspberry Pi Configuration.
In there you should find a radio button to activate your i2c.
→ Does this fix your problem?
If not, come back and let us know because there are still other things to check in the /boot/config.txt file of your operating system. 
Good luck.
Pix 
Further detail:
The line of code that’s flagging flairing up is this line of code.
assert max(asw) <= 1 and min(asw) >= 0 and len(asw) is 2, "asw must be a list of 1/0, length=2"
Not what I was expecting. Don’t know how the program made it to that line. Not a big deal because the trace-back correctly identifies the larger problem of missing the bus. That being said @Liam I’m not sure this is intended behavior?
1 Like
Hey @Olle185132
Looking at the error you’ve got there it’s likely as Pix mentioned that the I2C interface isn’t enabled.
In the getting started guide that we have for the RFID module we have the below photo that will show you how to enable it.
2 Likes
Hi Dan,
I thought I had turned on the I2C, but when I checked, it was not on. After turning it on, the RFID module reads the FOBs.
Thanks,
Olle
2 Likes
Hey @Olle185132,
That’s awesome to hear! Glad it was a quick fix for you.
Hopefully, it’s smooth sailing for the rest of this project! 