Page 1 of 1

Raspberry pi rfid door lock

Posted: Sun Sep 08, 2019 7:29 pm
by Annihilation989
Hello, I was wondering if anyone could help me,
I have been following this guide (https://github.com/plenkyman/RFID_RC522 ... lation.txt) to make an rfid door lock, however, when I try to set up the cards, I get an error, might it be that i'm running this on buster, but it says it is run on jessie.
I have tried contacting the creator, but unfortunately, he hasn't been online since 2017.
Any help would be greatly appreciated,
Tim

The error:

Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/pymysql/connections.py", line 571, in connect
sock.connect(self.unix_socket)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "SetupCards.py", line 26, in <module>
connection = pymysql.connect(host=tdp.rpi_ip,unix_socket='/var/run/mysqld/mysqld.sock', user=tdp.dbUs, passwd=tdp.dbPW, db=tdp.dbNa)
File "/usr/local/lib/python3.7/dist-packages/pymysql/__init__.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/pymysql/connections.py", line 325, in __init__
self.connect()
File "/usr/local/lib/python3.7/dist-packages/pymysql/connections.py", line 630, in connect
raise exc
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 2] No such file or directory)")

Re: Raspberry pi rfid door lock

Posted: Mon Sep 09, 2019 10:36 am
by topguy
The script expect a running MySQL server on "localhost" that connection is what fails.
There is a big chance that the "thedoor_full_install_v9.sh" doesnt quite work on Buster because packages has changed names etc..

Re: Raspberry pi rfid door lock

Posted: Mon Sep 09, 2019 5:55 pm
by Annihilation989
Thanks for the reply, I will try jessie

Re: Raspberry pi rfid door lock

Posted: Thu Sep 12, 2019 9:54 pm
by Annihilation989
Hello,
I have tried jessie, but the reader wasn't running, I googled around and found out the reader doesn't work with the latest version of jessie, could anyone confirm this?
Many thanks,
Tim

Re: Raspberry pi rfid door lock

Posted: Fri Sep 13, 2019 8:49 am
by topguy
Using Jessie which is very old, could be difficult in general, a better solution is to learn how the solution is supposed to work and learn set it up manually.

Re: Raspberry pi rfid door lock

Posted: Sun Oct 13, 2019 7:14 am
by Annihilation989
Everything works, except the script for setup cards fails because I don't know the directory for the reader

Re: Raspberry pi rfid door lock

Posted: Sun Oct 13, 2019 10:51 am
by topguy
You have to give more information about the script and what directory you are talking about if you want help.

Re: Raspberry pi rfid door lock

Posted: Mon Oct 14, 2019 7:27 am
by Annihilation989
The door script runs and checks for any cards on the reader, if the card has a an id that's stored in the database, then the script checks what level of clearance has been assigned to it and if it's authorized to access the room at that time and date, if not a red led turns on and the card is logged to the database of rejected cards, the script then takes a photo of the person, if a card is accepted, a relay will be switched and the electromagnet will turn off for 3 seconds.

The program I'm trying to run is setup cards, which allows you to set cards and the access level for them, however, when I run the program, it skips the reading cards bit and just exits the program. I thought it might have something to do with the directory for the reader being wrong, because there's a program you can run which will allow you to change gpio pins for leds and directories for different things, I looked in the default directory for the reader, but saw nothing that resembled a reader.
Any help would be appreciated

Re: Raspberry pi rfid door lock

Posted: Mon Oct 14, 2019 11:06 am
by topguy
I looked in the default directory for the reader, but saw nothing that resembled a reader.
And what is this directory called ?
So far we don't even know how the reader is connected to the Pi or which RC522 module you have bought.

Its very hard to follow that project you linked to, to be honest.

The code try to start another program:

Code: Select all

reader = RFIDReaderWrapper("sudo nohup "+tdc.p2r+"/rc522_reader -d 2>&1")
I dont know where this "rc522_reader" program is supposed to come from, but most likely its from here: https://github.com/plenkyman/rpi-rc522/ ... ster/rc522

Re: Raspberry pi rfid door lock

Posted: Mon Oct 14, 2019 4:53 pm
by Annihilation989
Thanks for your reply,
The reader is connected over spi and the default directory for the reader is home, this is the reader I bought:
https://www.amazon.co.uk/dp/B076HTH56Q/ ... PDbMK0DCTX

Re: Raspberry pi rfid door lock

Posted: Mon Oct 14, 2019 5:07 pm
by B.Goode
Referring back to your original query -

The substantive error appears to be
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost'

Why is it unable to connect?

Can you confirm that you are running a MySQL-compatible database server on your Raspbian Buster Operating System to which your code can make a connection?

Re: Raspberry pi rfid door lock

Posted: Tue Oct 15, 2019 4:35 pm
by Annihilation989
I no longer have that error, I changed from buster to Jessie and the only problem now is the program exiting, but thanks for your help