I'm working on a quick project with my dad for his condo. He wanted to setup a bunch of moisture sensors around the condo near sources of water (sinks, bathtubs, toilets, etc), which, if triggered, will cut off the main water line to the condo to prevent flooding.
We got several Raspberry Pi Zero's for the project, a water valve that can be controlled electronically, and some moisture sensors.
We have one Pi working as the master. It's attached to a relay that can shut off the main water valve to the condo, and to a reset switch, so that if the valve is shut off, he can hit the switch to turn it on again. The Pi is running an XMLRPC server, listening for Client Pi's to tell it that there's a water leak somewhere. Code: https://gist.github.com/terminator14/baeaf44bef265a88be7adc539b4d572a
We also have several client Pis. Each client Pi has several moisture sensors attached to it. For example, there's a client Pi in the kitchen, with one sensor next to the kitchen sink, one next to the dish washer, etc. Code: https://gist.github.com/terminator14/87ba2bc76b993c4d8b0055dfecd8c94d
In theory, everything should work, but it practice, we're seeing a bunch of issues.
For example, when we short circuit one of the moisture sensors (to set it off), the code detects that multiple sensors on that same Pi have detected moisture. We tried using different pins on the Pi for the moisture sensors, but it didn't help. I had to resort to workarounds in code that ignore sensors right after one fires, which is hackey.
Another issue we seem to have is that for no reason, every few weeks, a random moisture sensor will trip.
I know this question isn't very specific, but I'm not even sure if our problems are software, or hardware. I tried dumbing down my program to something super basic, and that still shows that when one moisture sensor triggers, others seem to be in a HIGH state as well. Any idea if we're doing something wrong?
PS. If anyone decides to reuse my code, please be aware that XMLRPC can't handle multiple concurrent messages, so if 2 clients send a message to the master at the same time, bad things will happen. I might address this at some point, but for now, I don't care.
Edit: The cables to the sensors are pretty long. Some are 15 feet. That's about the longest one.
Rough diagram can be found here. Excuse my dad's spelling mistakes. Also, the Pi3 was later changed to also be a Pi Zero, and a reset button was added. He never updated the diagram.
The Sensors came from China. It looks like this:
Not sure if I can find the specs for it somewhere.