Started 21st December 2016
I measured the depth of water in the crawl space under my house using a capacitive sensor (see Sensor) and an ultrasonic ranging module (see HCSR04). Then at the end of 2016 I became aware of the ST Microelectronics laser time of flight sensors.
As a young lad playing with tiny radio transmitters I had thought why not use radar to see how far away objects in my work-space were. Even for me back then the calculation was simple and the answer is that light travels fast, really really fast. At the time I doubt anyone had electronics which could measure how long light takes to cover a foot (as 300 mm was known then).
We'd been out on the vast school playing field and measured the (far lower) speed of sound with our ancient technology ("I will blow my whistle and Pilling will wave his flag when he hears it") and failed to get anywhere near the right value.
So amazing new technology, I had to give it a go.
Two versions currently are available on ebay, the VL53L0X and the VL6180X "Time-of-Flight Distance Sensor". The VL6180X is short range (10 cm) and the VL53L0X longer (1 m). The ST home pages are: VL53L0X and VL6180X.
The ebay version (shown below) contains level shifters and a voltage regulator which means it can be connected to a 5 V or 3.3 V Arduino.
The SparkFun library is very simple to use and trivial to splice into the rest of my sensor code. Results are noisy, but if enough are averaged they are accurate. There's no problem of monotonicity like with the unmodified ultrasonic ranging module.
At the end of 2017 the water in the crawl space rose above the VL6180 sensor and fatally damaged it. As I had a VL53L0X sensor I reworked the code to use that.
I rejected the Adafruit library as too complicated and used the Pololu library. Previously I have used a customised version of the wire and twi libraries (to disable pull ups) in this version I used the standard one and added code to handle the pull ups.
I 3D printed an arm to hold the VL53L0X sensor some 250 mm above the ground level. I have a plastic box filled with gravel which the electronics sit on top of. It is important to have enough ballast so that as the water level rises the box does not float.
- Archive of Arduino sketchbook SensorTXLD2 files and libraries - VL5310X version
- Archive of OpenSCAD design for arm to hold sensor
I set off wanting to measure single mm of water, and ended three years later with inches (25.4 mm units) of it, a worrying trend.
I had a couple of comments from people detecting water levels, one of them was along the lines "does water reflect light", which I batted aside, "of course water reflects light, what do you think Polaroid sunglasses are all about", eventually I read a comment by C. Wayne Wright here (a You Tube video about the VL53L0X) which makes the good point that reflection from water is specular, angle of incidence equals angle of reflection, so the sensor has to be perpendicular to the liquid. I've not come unstuck with this because my water is so mucky; there's often a white film on it which will give diffuse reflection.
I used a lot of freely available software. Credit to the people who wrote it and made it available.
- LowPower library by Rocket Scream Electronics
- DHT11 Temperature & Humidity Sensor library for Arduino by Rob Tillaart and others
- connectingStuff, Oregon Scientific v2.1 Emitter by Olivier Lebrun
- Decoding the Oregon Scientific V2 protocol by Dominique Pierre
- Oregon Scientific sensors with Raspberry PI by Paul Pinault
- ATMega 328 Secret volt meter by Tinker It
- ATMega 328 Secret thermometer Tinker It
- Oregon Scientific RF Protocol Description
- Power saving techniques for microprocessors - Nick Gammon
- Arduino Pro Mini Schematic
- Setting up an Arduino on a breadboard - Physical Computing at ITP