I have made a project where I'm using Raspberry Pi 4 Model B to execute two Python script that work with PN532 NFC RFID module using py532lib library package. The NFC is connected using i2c method.
Main function:
One script use to detect Mifare card at the outside and other script for inside. Therefore, the Raspberry Pi is connected to 2 NFC readers.
Both scripts work as intended, allow the user to get in or out by tapping their card to the NFC reader, and make the door open.
Problem:
However, after sometime, one script or both will not able to detect the card. After some investigation, I have checked the script stuck when they try to make connections with the NFC by send command ACK.
I believe the NFC did not send a response to the ACK command send to them. Thus make the python script keep waiting for response, causing it to "stuck"
Usually, when use Linux command i2cdetect -y 1 I will be able to see the address of the connected NFC.
But whenever this problem occurred where the NFC can not detect the card, command i2cdetect -y 1 will take some time to process, and end up showing no address at all.
At this point, I didn't believe the script is causing the problem, but rather the Raspberry pi not able to find the connected NFC.
Even using command sudo reboot, the problem still happens.
The solution for this problem to make it work again is by manually unplugging the power supply for Raspberry Pi.
But what can cause the I2C address to suddenly disappear?
Have anyone experienced their i2c module suddenly cannot be connected due to address not found?
I have tried to reboot the raspberry pi, but it did not solve the problem.
I didn't know if it possible to disconnect all the I2C and try detect and connect again.
The only solution that works is turning off the power and turn on again.