Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5362

Python • Re: Pi 5 / RC522 / Python for RFID Reading?

$
0
0
GPIO Pins aren't only input/output.

Peripheral like SPI, I2C, UART, PWM, 1wire, etc... are available by switching some settings.

For you project using the MFRC522 card reader you need to have access to the SPI device. Using the command raspi-config you could enable the SPI0 device which are GPIO10 (MOSI), GPIO9(MISO), GPIO11(CLK), GPIO8(CE0) and GPIO7(CE1). You could also enable other SPI by modifying the /boot/firmware/config.txt.

Once you enable the SPI from Raspi-config and reboot you will notice that a new device spidev exist.

Code:

daniel@Pi5:~ $ ls -l /dev/spi*crw-rw---- 1 root spi 153, 0 20 mar 09:18 /dev/spidev0.0crw-rw---- 1 root spi 153, 1 20 mar 09:18 /dev/spidev0.1
spidev0.0 for chip select 0, and spidev0.1 for chip select1

Then just connect the MFRC522 to the correct SPI pin et voila. The rest is using the spidev interface to have access to it!

No need to deal with any GPIO input/output. Then gpiozero is not needed at all.

Do a search on the web for raspberry Pi alternate function.

Statistics: Posted by danjperron — Wed Mar 20, 2024 7:09 pm



Viewing all articles
Browse latest Browse all 5362

Trending Articles