My basement flooding alarm was put in place because this year we have seen extreme rain on a few occasions, which in one case actually flooded the street, and as a result also my basement.
With the electrical cabinet and utility connections in the basement, that could have been very bad, if waterlevels had reached the cabinet itself, so I needed a way to measure waterlevels and have an automatic start of a sump pump when not at home (now my neighbours called me at work to tell me what was happening in the street).
As the house this alarm was built for, is not always occupied, we needed notifications via internet.
In the house I set up a MySensors network with a few nodes and a Raspberry which integrates the Controller (Domoticz) and Gateway functions (nrf24l01+ directly connected via interface board to raspi).
The basement is now being watched by a node which measures the distance to the floor using a cheap ultrasonic sensor. It will switch a relay if the "floor" rises a certain amount (10cm) and will switch off the relay when the "floor" is back within 2 cm from initial position.
The node resets itself to a start position on startup. This means that during startup a first distance measurement is done. This is the "zero" level. Any deviation from that first measured distance is "the change".
Here are some pictures of the node while not yet in the box:
And when mounted in the box:
I then installed this in the basement next to the electrical cabinet:
The node sends new distance measures to the controller only when they change. As I wanted to be able to remotely switch the relay at my discretion, the node itself is not battery based, but always on. I'm using a PCB I designed which you can find on Openhardware.io:
You can use any relay module which can be controlled by a digital pin.
I use the PA+LPA version of the nrf24l01+ radio, since the basement is covered by a slab of metal re-inforced concrete. A normal radio did not reach the gateway.
I have added the sketch below: