Improve & Check Python / RaspberryPi Code
Budget: €8 – €30 EUR
I am using a RaspberryPi Zero (W) connected to a reed sensor (magnetic) to measure the activity of my gas meter. I wrote a python code that updates a MySQL data table every time the meter is active (and the last barrel increments). I am then running the Python script as a service.
It all works properly. But sometimes - for a reason I don't understand - it stops working and I have to stop/re-start the service for the script to start working again.
I'd like someone to help me fix / improve the code so it can work for weeks/months without crashing. I'd also like to get suggestions to improve the code and make it more failproof (maybe by comparing the SQL data base vs. a CSV stored on the Pi for example - just an idea).
Thanks.
PS : attaching a photo of the setup : the Honeywell black thing is the reed switch, connected to Rasp' GPIO
PS : also attaching the python script
It all works properly. But sometimes - for a reason I don't understand - it stops working and I have to stop/re-start the service for the script to start working again.
I'd like someone to help me fix / improve the code so it can work for weeks/months without crashing. I'd also like to get suggestions to improve the code and make it more failproof (maybe by comparing the SQL data base vs. a CSV stored on the Pi for example - just an idea).
Thanks.
PS : attaching a photo of the setup : the Honeywell black thing is the reed switch, connected to Rasp' GPIO
PS : also attaching the python script