Arduino Project 6 β Measuring a water tank level (SRF05 Ultrasonic Rangefinder/Arduino Mega 2560/Arduino Uno/1.0)
I’m harvesting rainwater from a couple of outbuildings via 110mm underground pipes connected to an underground storage tank. Since I want to stay on top of the water level in the tank and also had a SRF05 ultrasonic rangefinder sitting in a box I thought I’d put it to good use and measure the water level in the storage tank. The result is collected by an Arduino Mega 2560 and uploaded to a mysql database with the help of an ethernet shield but this is obviously optional.
The theory behind this sensor is easy to understand. It works pretty much like a bat hence sends out an ultra sonic pulse, waits for it to come back and depending on the time between the two events we can then calculate the distance between our sensor and the nearest obstacle. I’ve put the sensor including a little bit of perfboard with a switch and some LEDs into an enclosure and mounted it to the inside wall of the tanks collar facing down towards the bottom of the tank/water. To get the sensor connected to the Arduino Mega 2560/Uno there are four cables to connect before we can upload a sketch for testing purposes. Apart from reading from the sensor the sketch also blinks the onboard pin13 LED after each measurement and prints the result to the serial monitor.
Connect the sensor as follows:
Red -> Arduino 5V
Yellow -> Arduino digital pin 7
Lilac ->Β Arduino digital pin 8
Black -> Arduino GND
Upload the following sketch, open the serial monitor and you should see some results.
3. Let’s make it pretty and “put it in the hole”:
I didn’t want to just hot glue the sensor to the inside of the tank due to the humidity in there. Unfortunately I’ve currently run out of the water proof enclosures/cable glands I tend to use so I had to improvise. I also made a little perfboard which includes a switch to cut power to the sensor and board, one red LED to indicate 5V arriving on the perfboard and one yellow LED as a heart beat indicator to flash between measurements. I’ve mounted all this inside the plastic cap of an aerosol can with the LEDs sticking out the top. The two sensor eyes look out the bottom which is sealed with a bit of plastic with holes cut into it to let the sensor eyes poke through. Add a generous amount of hot glue to seal the gaps and we’re ready to mount the sensor inside the collar of the water tank.
The following sketch will print the result to the serial monitor and use the onboard pin13 LED and the perfboard LED as heart beat indicators between measurements.