Friday, November 5, 2010

Flood alarm with X10

This simple project was done years ago, it can be an excellent example to show how is easy to integrate X10 in our own projects.
I needed a simple low cost flood alarm, capable to monitor some sensors and notify as soon as possible about flood conditions.

The problem

X10 Universal module
After two floods in the basement, one from the washer and one from the HVAC, I decided to monitor these area to avoid further problems. 
I also needed a way to be informed in the rest of the house about a problem in the basement, where the problem happened.
So I decided to use an X10 transmitter, controlling an X10 Universal module (it has the possibility to generate a sound when triggered).
The the transmitter was modified, in order to control the pushbutton with a rele reed.


Since I needed something simple, quick to build and reliable, I used the usual PIC 16F84, plus some external components (at the time I was using PICs rather then the MSP430).
Before to excite too much who is reading this article, I built the X10 interface hacking a ready-made X10 RF transmitter.
So I didn't designed nothing directly with X10.

I always try to optimize the effort and re-use as much as possible what I have around, so instead to design an X10 transmitter, with all the problems that such design imply (interface the power grid, insulation, ecc.) I choose another way also because the flood alarm is supposed to be placed in areas potentially flooded !

So I choose to use a ready-made X10 RF transmitter, drove it by a reed relay, simulating the pushbutton.
In this way I was able to obtain the requested insulation and safety and also the capability to place the alarm everywhere needed.

Here a block schematic :

Here a floor map of the basement where the flood alarm was deployed :



As I said before, the hardware is based on the PIC 16F84 and the code is not critical, so it should be  easy to port it on other PICs or other Micro controller.
As you can see from the schematic, the PIC is handling directly the LCD and the sensor, based on a Cmos port.
There is nothing to add, is almost all standard.


The sensor, based on a CMOS 4049, is very simple.
When no water is touching the two terminal of the sensor, the port is forced by the pull-up.
As soon water connect the two sensor entries, the port change state.
The LED was placed just to debug the system, is not necessary for normal operations.
The capacitor between the sensor terminal allowed to stabilize the signal event, removing noise.
Since the flood condition is (hopefully) a rare one, I didn't bother to use an AC signal to prevent sensor corrosion.
This is a flood alarm, not a level indicator so the sensors are supposed to be dry all the time.
To avoid false alarms the software filters out the reading of the sensor, cutting out any possible "spike"


The software is written all in C and compiled with the PICC Lite. It's very simple.


As you can see, the firmware perform a debounce function for each sensor input, in order to avoid as much as possible, false alarms.
Because the type of events to monitor, 10 seconds to have a positive reading for a flood, are more than acceptable.
That allowed to simplify the sensor electronic design.



For this project I used two types of sensors :
  • Sensor 1 - in a pipe
  • Sensor 2 - on the floor
In order to built the floor sensor, I used a toy container, the ones that is possible to find in some coin machines, at least here in the USA.
I screwed 3 screws on the bottom, connected a wire to one screw and the other wire to the other 2 screws.
Then I added some plastic clay to increase the weight of the sensor (be sure the clay used is not conductive and water resistant) and "glued" the entry wires with other clay.
The pipe sensor, to be placed in the T junction at the output of the HVAC, was built with two brass bars, glued with hot glue, to a pipe cap.


Here some pictures of the circuit and the placing.

The box used to host the circuit is a plastic display box for dolls.
Easy to find and work (Plexiglas) it gives an interesting view of the circuit and is easy to seal.
Note the X10 transmitter at the base of the box and the rele reed that controls it.
They are just attached with some velcro.
The X10 transmitter still uses it's own original batteries, they last years in normal use.

Here the sensor for the pipe.
The pipe it was bringing out the water from the HVAC condenser and sometime there were "clogs" in the end of the pipe.
When this was happening, the water generated by the HVAC overflowed from the condenser in the basement.
Quite a mess.

Just in case the pipe sensor was not able to catch the flood, I prepared another sensor and placed just on the bottom fo the HVAC unit, where I noticed the water going first.

Here a modification for watering the plants.
We had a very dry and hot summer, so I decided to collect the HVAC water to water the plants.
I used a big container (actually a paper waste) and created a very fast "sensor" using two PC slot covers attached to one entry of the flood alarm.
In this way when the bucket was almost full the alarm would tell me so, allowing me to empty the bucket and water the plants.

In order to fill up the bucket, I temporarily diverted the pipe coming out the HVAC.


The flood alarm worked for a couple of years without problems and currently is in some box, since the moving changed the needs.
At least I know to have it if the need arise again :-)

The most critical part, the sensor, was actually extremely reliable even if so simple.
Only one time I had problems, when a sensor wire broken up, because my bad installation (never EVER use uninsulated pins to attach a cable just because you run out of time !).
But other than that the circuit was really stable and reliable, saving me at least from 3 floods.

As usual, if somebody is interested in the source code, just contact me.
I don't have yet set up a public place where to store the code.

No comments:

Post a Comment