“Our house has a water tank fed from the rain falling on the roof, and used for the toilet, the washing machine and watering plants in the garden. For the last three years the summers were very dry, so we kept an eye on the water level in the tank. So far, we used a wooden stick, which we put in the tank and marked the level. But surely it must be possible to improve on this!
This is where this project comes in. The idea is to attach an ultrasonic distance sensor at the top of the tank. This sensor works as a sonar emitting sound waves, which are then reflected by the water surface. From the time it takes for the waves to come back and the speed of sound, you can calculate the distance to the water surface and determine how full the tank is.
Since I don’t have a mains connection close to the tank it is essential that the complete device works on batteries. This means I had to be conscious about the power consumption of all the parts. To send back the data I decided to use the built-in Wifi of an ESP8266 microchip. While the Wifi is fairly power-hungry, it has an advantage over another type of radio connection: you can directly connect to your home’s wireless router without having to build another device that acts as a relay.
To save power I’ll put the ESP8266 in deep sleep most of the time and take a measurement every hour. For my purpose of following up on the water level this more than suffices. The data will be send to ThingSpeak and can then be read off on a smartphone through an app.
One more detail! The speed of sound, essential for the distance measurement, depends on the temperature and to a lesser extent on the humidity. For an accurate outside measurement over the seasons we’ll thrown in a BME280 sensor, which measures temperature, humidity and pressure. As a bonus this makes from our water level sensor also a mini weather station.
1x ESP8266 ESP-12F.
1x ESP-12F adapter plate.
1x FT232RL FTDI: USB to Serial adapter.
1x HC-SR04-P: ultrasonic distance measurement module. Note that the P is important, since this is the version that has a low minimum operating voltage of 3V.
1x BME280 3.3V version: temperature, pressure and humidity sensor.
1x IRL2203N: n-channel MOSFET transistor.
1x MCP1700-3302E 3.3V version: voltage regulator.
3x rechargeable AA battery, e.g. 2600mAh.
1x battery holder for 3 batteries.
Resistors: 1x 470K, 1x 100K, 4x 10K.
Capacitors: 2x ceramic 1uF.
3x toggle switch.
U-shape breadboard wires.
Plastic soup container 1l.
Attachment ring for the container.
I made the code available on GitHub.”