Hello, I was wondering if there was a way to, if when I trigger an alarm, it would trigger a sounder using a Raspberry Pi coded with Python?
That is a really intriguing idea. If Python has access to MySQL databases, which I assume it does, and you can give access to your Pi’s IP address, then there is no reason that a Python script should not be able to use the SQL to poll the status of the alarm:
SELECT * FROM
scope LIKE ‘System’ AND
name LIKE ‘Alarm’
If an alarm is detected, then activate a sound on the Pi. Keep polling until the alarm status changes, so you know that the alarm is over.
Let us know how you get on!
It worked! I built a program using a library and polled the SQL entry for ‘General’ or ‘Lockdown’. It was a simple code but it worked. Thanks for the help!
Sounds amazing! Any chance we can get a video of it working, and a code listing (remember to take out addresses, usernames and passwords for MySQL!)? Thanks!
Of course! I have now also linked it with a smart bulb so that it flashes red when the alarm is activated. The code is pretty poor because I’m just starting out with Python (treading would be a better way) but it works. I’ll get a video and the code later today. Thanks again for the help!
Ah nice! This is the kind of hacking I love to share with my own students : ) Great stuff.
The script used is attached to this comment. It has been copied into a text file to allow easier reading. Just re-save to use as Python. I’m working on the video and will put it in next comment.
Hi Ross, the forum is not allowing me to send video and I don’t have YouTube. Any suggestions?
The code looks neat. I have not done much with Python, so don’t understand all of it, but the clear function naming makes it clear what is going on. Do you want to share the file via Google Drive to email@example.com and we can host it on our YouTube channel with your code, and credits (send me the credit text you want us to use). I might even do a blog post on it : ) Thanks!
I’ve shared the video with the email address.
For anyone who is interested, the video, the code and a brief write up are available here: