DIY Water Level Sensor — Monitor Any Tank From Your Phone , Anywhere
by AgriPulse in Circuits > Microcontrollers
124 Views, 2 Favorites, 0 Comments
DIY Water Level Sensor — Monitor Any Tank From Your Phone , Anywhere
Have you ever driven 30 minutes to check a water tank, only to find out it was fine? Or worse — arrived to find it bone dry and animals thirsty, plants wilting, or a pump running against nothing?
This sensor fixes that. It clips onto any water tank or basin, measures the water level with ultrasound, and sends the reading to your phone over LTE — no Wi-Fi needed. Whether your water is in the backyard or 10 kilometres down a dirt road, you'll know the level without making the trip.
It works for cattle basins, greenhouse reservoirs, rainwater tanks, irrigation systems — anywhere water matters and you can't always be there to check.
Built to be simple and adaptable. We deliberately minimized the custom parts. The design uses just two small 3D-printed pieces and a standard spring clamp you can pick up at any hardware store. No complex fabrication or specialty tools. If you can follow a recipe and use a drill, you can build this.
Developed at Concordia University's Innovation Lab as part of the Regenerative Agriculture Challenge.
Let's build it!
Supplies
- JSN-SR04T Ultrasonic Sensor: the "ears" of the device, sends a sound pulse and measures the distance to the water surface (~$15, Amazon)
- ESP32-S3 SIM7670G 4G Development Board: the "brain," reads the sensor and sends data to your phone over cell service (~$38, Amazon)
- IoT SIM Card: a cell data plan for the sensor, lets it transmit over LTE. Typically ~$2–5/month after initial prepaid bundle (~$50 prepaid)
- 12V-5V USB Step-Down Converter: converts battery power to the voltage the board needs (~$14, Amazon)
- Spring clamp: a standard clamp to mount the device on your basin rim (~$5–10, any hardware store)
Hardware:
- 12V battery : the power source that run the power in the field
- MEIRIYFA 12V to 5V USB Converter: converts the battery's 12V to the 5V the board needs (~$14, Amazon)
- 2x M3 Coarse thread (screws and bolts): to attach the 3D-printed piece to the clamp (size depends on your clamp — bring the printed piece to the store to match)
- Weatherproof junction box: to protect the board and battery from rain (~$5–15, hardware store)
3D-printed parts (files provided in Step 2):
- Neck + Cone piece: holds the sensor and hangs over the water
- 3D-Printed Mount:
- PLA filament
- Spring clamp
- Screw(s), if needed
Tools
- Drill
- Drill bit
- Soldering iron
- Wire cutters / wire strippers
Connect Microcontroller + Ultrasonic Sonic Sensor + LTE Chip
Follow the schematic above to connect your components:
- Insert the SIM Card
- Place your IoT Sim Card into the SIM slot on the ESP32 board
- Make sure it clicks into place and is oriented correctly
- Wire the Ultrasonic Sensor
- Connect the JSN-SR04T Ultrasonic Sensor to the ESP32-S3 SIM7670G board as follows:
- VCC → 5V (or VIN)
- GND → GND
- Trig → GPIO pin
- Echo → GPIO
- Double-Check your Connections
- Ensure all wires are firmly connected
- Verify each pin matches the schematic exactly
Print the 3D Housing Parts
The sensor needs a housing to hold it over the water at the right angle. We kept this as simple as possible — just one 3D-printed piece (the Neck + Cone) and a store-bought spring clamp you probably already own.
The parts and what they do
- The Neck + Cone (3D printed) — The arm that extends over the water. The cone at the end points downward and protects the ultrasonic sensor inside. There are holes on each side for attaching it to the clamp.
- Spring Clamp (store-bought) — Grips onto the edge of your basin. You'll drill two small holes in one jaw to bolt the Neck + Cone piece to it.
How they fit together
- Drill two holes in one jaw of the spring clamp, lined up with the holes on the Neck + Cone piece.
- Bolt the Neck + Cone to the clamp jaw using two small bolts and nuts. Tighten firmly.
- When you squeeze the clamp onto a basin edge, the cone should hang downward over the water.
Getting the 3D-printed piece
Download the STL file attached to this step:
- Updated.Neck+Cone.stl (Example)
Print settings: PETG material (handles outdoor weather better than PLA)
No 3D printer? Many Ontario public libraries offer 3D printing through their makerspaces. You can also upload the file to an online service like Craftcloud — select PETG, and it arrives by mail in about a week (~$10–15 CAD).
Connect Microcontroller to Computer Using Waveshare Driver and Create Thingspeak Account
- Connect the Board
- Connect the ESP32-S3 board to your computer using a USB-C cable
- Open the Arduino IDE on your computer
- Install the Required Board Package
- In the Arduino IDE, go to Tools → Board → Boards Manager
- Search for and install the Waveshare ESP32-S3 (or relevant ESP32-S30) board package
- Create a ThingSpeak Account
- Go to the ThingSpeak website and create a free account
- You'll use this to store and visualize sensor data
Upload Code to Microcontroller
- Install Required libraries
- Open the Arduino IDE and install the following libraries:
- ESP32
- TinyGSM
- Select the Correct Board and Port
- Go to Tools → Board and select ESP32-S3 Dev Module
- Go to Tools → Port and choose the port that corresponds to your device
- Configure the Code
- Before uploading, update the following in your code
- Insert your ThingSpeak API key
- Enter your SIM card APN (provided by your carrier)
- Upload the Code
- Click the Upload button in the Arduino IDE
- Wait for the code to compile and upload to your ESP325
- Verify Uplaod
- Open the Serial Monitor to confirm the device is connecting and sending data
Install the Ultrasonic Sensor in the Cone
Now for the fun part!
In this step, you're placing the actual sensor — the part that measures the distance to the water surface — into the 3D-printed cone you made in Step 2.
What you need for this step:
- The JSN-SR04T ultrasonic sensor probe (the small, round, waterproof disc with a cable coming out of it)
- The 3D-printed Neck + Cone piece from Step 2.
- A drill with a bit sized to fit the sensor probe [measure your probe diameter and fill in]
Here's how to do it:
- Look at the base of the head section — that's the area just above where the cone flares out. You'll see it's solid. This is where you'll drill a small hole to slide the sensor inside.
- Drill a hole at the base of the head section, just big enough for the sensor disc to pass through. Take it slow, especially if you printed in PETG. You only need one clean hole.
- Slide the sensor probe through the hole and into the interior of the cone. Position it so the flat metallic face points straight down — toward the wide opening of the cone. That metallic circle is the part that sends and receives the sound pulse. It needs a clear view of the water below.
- Once it's in the right spot, lock it in place with a dab of silicone sealant or hot glue around the entry hole. This holds the sensor firm and keeps moisture from sneaking inside.
- Route the cable out along the body of the Neck + Cone piece and secure it with a zip tie. You don't want a loose cable flapping around in the wind.
How to check you got it right:
Hold the Neck + Cone piece up and look into the cone from the bottom (the wide end). You should see the metallic face of the sensor staring straight back at you. If it's tilted or off-center, fix it before the sealant dries — the sensor needs to point straight down for accurate readings.
Attach to the Water Basin
You've got your Neck + Cone piece with the sensor installed, bolted to a spring clamp. Now you just need to clip it onto the edge of your water basin so the cone hangs over the water, pointing straight down.
What you'll need:
- The fully assembled device (spring clamp + Neck + Cone with sensor)
- Your water basin
Here's how to do it:
- Squeeze the spring clamp handles to open the jaws — just like you would with any spring clamp.
- Slide the clamp over the basin rim so that the cone arm extends inward, hanging over the water. The cone should be pointing straight down toward the water surface.
- Release the handles. The clamp grips the basin edge. Give it a wiggle — it should feel solid and not slide around. If it feels loose, try a thicker section of the rim, or wrap a strip of rubber (a piece of bicycle inner tube or rubber shelf liner) around the rim for extra grip.
- Now check the most important thing in this whole step — the cone must be pointing straight down. Crouch down and look at it from the side. It should be hanging perfectly vertical, like a plumb line. The ultrasonic sensor sends its sound pulse in a narrow beam straight down. If the cone is tilted even a little, the beam hits the water at an angle and your readings will be off. If your basin rim is sloped, reposition the clamp to a flatter section of the edge.
What if the clamp doesn't fit my basin?
- Basin wall too thick: Try a larger spring clamp from the hardware store — they come in various sizes. Just make sure the bolt holes line up with your Neck + Cone piece, or drill new ones.
- Rounded lip: Position the clamp slightly below the lip where the wall is flatter. A rubber strip between the clamp and the basin surface helps it grip curved surfaces.
Step 7 Connect to Power
Your sensor is mounted on the basin, now it needs electricity to start working!
The step-down converter in your supplies list does one simple job: it takes 12V power from a battery and converts it to the 5V that your ESP32 board needs
What you'll need:
- The 12V-5V USB step-down converter from your supplies list
- A 12V battery
- Your mounted sensor device from (Step 6)
Wiring the converter:
- Look at the converter. It has two bare wires on one end (red and black) and a USB plug on the other end.
- Connect the red wire to the positive (+) terminal of your 12V power source.
- Connect the black wire to the negative (−) terminal of your 12V power source.
- Plug the USB end into the USB port on the ESP32 board.
Note: The ESP32 board, converter, and battery all need to stay dry. Put them inside a weatherproof junction box. They cost $10–35 at any hardware store.
Test Your Sensor
Everything is connected and powered up. Before you walk away and trust it, let's make sure it's actually working.
Check for signs of life:
- Look at the ESP32 board. You should see a small LED light up, so that means it's getting power.
- Give it a minute or two. The LTE module needs about 30–60 seconds to find and connect to the cell network, just like a phone does when you turn it on.
Check ThingSpeak:
- Open ThingSpeak on your phone or computer. Go to your channel (the one you set up in step 3)
- Within 2–5 minutes, you should see a number appear on the chart. This number is the distance in centimeters from the sensor to the water surface.