I have a USB NFC reader (acts as an emulated keyboard that types out the 10 digit ID number on the card when scanned).

I want an app to listen for this input and when it sees 10 digits, I want it to use them to try to update a column in a table on my SQL Server DB with the 10 digits acting as a unique identifier.

I can handle the SQL but have no idea about the (I assume) Python script to listen for 10 character input and then make an SQL connection.

After this I want it to trigger something via GPIO, but one step at a time.

After all this I need it to loop back to the beginning so it's ready for the next person to swipe their card on the NFC reader.

Any help on where to look / where to start would be appreciated.


Here is sample code not full but might help you

#!/usr/bin/env python
import time
import sys

def main():
    with open('/dev/tty0', 'r') as tty:
        while True:
            RFID_input = tty.readline()
            // store this RFID_input to you SQL DB see the DB operation in python

Please see how to store data into DB using python.
Simple Tutorial for MySQL and Python : MySQL-Python

Take a look at USB RFID

After Successful script to save into DB and then script to make GPIO high or low, run your script to listen the NFC Reader. Code your self and post your problem with DB and GPIO.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.