Measuring water levels is important for environmental monitoring and flood control. After experiencing two hurricanes in Palm Harbor, Florida (the second of which caused significant flooding in my area), I decided to build a device to measure real-time water levels in lakes, ponds, tanks, and more.
The device that I built (pictured above) works by allowing the float (black) to push an arm made out of PVC pipe up and down, causing the Nordic Thingy:91 X (orange) near the pivot point to change its angle as the water level rises and falls. The Thingy:91 X senses this via its built-in low-power ADXL367 accelerometer.
With the device angle known, a bit of trigonometry can be used to give us the float height. The Thingy:91 X's cellular modem sends information to the Golioth cloud IoT service, which then passes information to Grafana for visualization. The Thingy:91 X's all-in-one sensing plus cellular data design means that there are no additional electronics required. The whole system fits nicely into a water-tight case, while the mechanical float arm moves with the changing water level.
Read on to see how I built this, and how you can too! Note that the current state of this project represents a phase I functional prototype for Hackster's Unveil the Unseen challenge. This page will be updated with more testing and updated hardware and/or firmware.
Assorted Purchased Components
- Thingy:91 X
- Pelican 1010 Micro Case, clear (https://amzn.to/45q0S9A)
- Toilet Float (https://amzn.to/3HMBqBe)
- (6) Zip-ties (https://amzn.to/3GLphN2)
- Paracord (https://amzn.to/3IRQ6j4)
1/2" PVC Pipe
- (6) Top horizontal pipes/horizontal legs (200mm ~8in)
- (2) Down pipes (500mm ~20in)
- (1) Bottom horizontal support (420mm ~16.5in)
- (1) Movable float pipe (1000mm ~40)
- (1) Cap pipe section (25mm ~1in)
- (5) Pipe cap
- (2) Two-way elbow
- (3) Four-way tee elbow
- Pipe cement
Use either mm OR inch dimensions when cutting PVC pipe (they are slightly different - inches used in video). Roughly 12 feet of 1/2 inch PVC pipe is used in total. Suggest purchase (2) 10 ft sections.
The PVC system can be built in other configurations, which can be set up in the Golioth interface.
3D-Printed Parts [see attachments]
- Pelican-PVC-Mount
- PVC-float-adapter
- Stopper (optional, modeled, but not used)
The flashing procedure and more firmware explanation is covered in Chris Wilson's separate project writeup. Chris also outlines more about the math and programming behind the device, so be sure to check out his writeup as well!
Mechanical Assembly:Cut PVC pipe to lengths per BOM. Drill (~6.5mm) hole through center of float pipe 10mm from end. Assemble PVC float adapter, aligning printed hole with drilled hole in PVC, then insert float. Drill through aligned holes in 3D-printed fixture and pipe, plus fully-inserted float. Use zip-tie to secure the float to pipe and PVC-float adapter.
Modify (1) four-way elbow as shown below, using a rotary tool and/or sandpaper to enlarge the OD of the two inline pipe connections, so that PVC pipe rotates freely when inserted. This allows the main pivot to move according to the water/float level. Do not modify the 90º pipe connections.
Modify (2) two-way elbows by drilling a (~6.5mm) hole through roughly the center of the bend.
Attach PVC pipe and fittings (with the exception of the top plug assembly) as shown in the images below. Optionally use pipe cement on non-rotating joints, but consider which joints you may want to disassemble later for transport and/or modification.
Assemble 3D-printed PVC/Pelican case mount to the PVC assembly with (2) zip-ties, which will also help secure the float pipe if not attached with PVC glue. Attach Pelican 1010 case with (4) zip-ties with lid latch facing float. Place programmed and activated Thingy:91 X inside, with its yellow door facing toward the float. Close the case with the latch. The Thingy:91 X is a near-perfect fit for this Pelican case, and should stay in place with no additional hardware.
Plug a small length of PVC pipe and a pipe cap into the top of the 4-way PVC tee to keep water out.
Tie a knot in the end of a (~2m) length of paracord. From the outside of the assembly, run it through the previously drilled hole in one of the elbows and feed it through the PVC pipe assembly to the other elbow. Temporarily pop PVC pipe out and/or use a stiff piece of wire to help feed the paracord through.
When reassembled, pull the cord somewhat tight and loop it over the elbow to secure it as shown below. This cord attachment may not be necessary in all situations, but will keep the middle joint in place if the top were to flex under stress.
With firmware installed, SIM card inserted and your project set up in Golioth and Grafana as outlined in Chris' code writeup linked 👆, turn on your Thingy:91 X, close the yellow door, place it in its waterproof box, and close the latches. Set it up with the float... floating in the body of water you wish to measure.
Go into the Golioth interface under your device and select the LightDB Stream tab, then Expand data. Note the float_height
, float_length
, and float_offset
values, each of which are reported in inches.
float_height
- change in water level from a set zero point - the resultfloat_length
- distance between the pivot axis and approximately the center of your float. This will not change unless the float pipe length is changed or modified.float_offset
- used to set a water level zero point. Also accommodates for any change in how high the PVC fixture is. With a zero offset, the device will report afloat_height=0
when the float pipe is horizontal.
If the float_height
is not ~zero in relatively calm water (it will vary slightly), change the FLOAT_OFFSET
setting value by an equal and opposite value to the current float_height
. For example, if the float_height
at your zero state is -4, set the FLOAT_OFFSET
to +4. Select Settings under your device in Golioth and edit the value in question.
You can also change the MEASUREMENT_INTERVAL
setting via the Golioth cloud console. When testing, a short interval (e.g. 5 seconds) can be useful. However, when deployed, quickly checking things over and over will eat up data and battery power. Optimize this setting as expedient.
With your device hardware and software set up correctly, you can monitor water levels via the Golioth LightDB Stream interface. You can also open up your Grafana project to see nice graphs of the data.
Note that if the float is resting on a dry lake/creek/other body of water, it will read as ~1.5 inches higher than if it was resting on water at this level. This is because the float does not sink into solid ground, thus the angle will be affected correspondingly. This needs to be accounted for in your calibration/system setup if a no-water situation is encountered.
Final Thoughts - Future OpportunitiesThis project is currently in a functional prototype state. When finished, individual implementations will likely vary. Use this document and video as references, but don't be afraid to experiment with your own configuration!
Potential Improvements for phase 2:
- Stake mounting
- Longer pivot arm
- Reinforced structure
- Enhanced power management
- Water level alarm
- Out-of-range accelerometer alarm (indicating potential physical problem)
- Further testing, perhaps during inclement weather
Note any Amazon links are affiliate
Comments