1 year ago

#196880

test-img

Newboz

SimpleMFRC522 is not working when other threads are starting

So I have a Raspberry pi 4 hooked with a HQ Camera module and a breadboard with an RFID RC522 Chip. I followed the tutorials how to setup the RFID and everything works fine.

What I want is to trigger the camera when the RFID Tag is scanned and this to be fed to a separate thread which will handle the processing with OpenCV.

Now when i run the following code:

import RPi.GPIO as GPIO
from mfrc522 import SimpleMFRC522

reader = SimpleMFRC522()
while True:
    
    try:
        id, text = reader.read()
        
        if id:
            print(id)
            print(type(id))
    except:
          print('Exception occurred')

Everything runs fine but if i do something like:

image_processor = ImageProcessor()

# start image processing thread
image_processor.start()

reader = SimpleMFRC522()
while True:

    try:
        id, text = reader.read()

        if id:
            print(id)
            print(type(id))
    except:
          print('Exception occurred')

The ImageProcessor start() starts a thread and after this it enters normally in the while loop but it the reader does not read anything. It just does not work. Is there any problem with the MFRC522 and multi threading?

Does anyone knows what am I doing wrong?

python-3.x

multithreading

raspberry-pi

raspberry-pi4

mfrc522

0 Answers

Your Answer

Accepted video resources