Water Level Monitoring System
In this Instructable, we will guide you through building a Water Level Monitoring System as part of our group project for the CSM3313 IoT Computing course. This project focuses on creating a simple IoT-based system that can collect environmental data and send it wirelessly to a cloud platform for monitoring.
The system uses a Raspberry Pi Pico W and multiple sensors to measure water level, temperature, humidity, and carbon monoxide levels. All collected data is uploaded to ThingSpeak, where it can be viewed in real time through an online dashboard. This project demonstrates a practical and hands-on approach to learning IoT concepts using affordable components.
Why Build Your Own Water Level Monitoring System?
- Learn New Skills
This project helps us learn basic electronics, sensor usage and WiFi communication while building a working IoT system.
- Real-World Applications
Water level monitoring is useful in many real situations such as water tanks, containers and drainage systems to avoid overflow or shortages.
- Cost-Effective Solution
By using affordable and easily available components, this system can be built at a low cost compared to commercial products.
- Flexible and Expandable Design
The system can be upgraded by adding more sensors like temperature, humidity or gas sensors in the future.
- Educational and DIY Experience
Building the system ourselves gives hands-on experience and shows how simple IoT projects can solve real problems.
What You’ll Learn
By following this project, you will learn:
- How to measure water level using a water-resistant ultrasonic sensor
- How to read temperature and humidity data using a DHT22 sensor
- How to detect carbon monoxide levels using an MQ-7 gas sensor
- How to use a Raspberry Pi Pico W with WiFi for IoT applications
- How to send sensor data to a cloud platform (ThingSpeak) for monitoring
- How to power an IoT system using a USB power bank
- Basic troubleshooting and testing techniques for IoT sensors
Downloads
Supplies
Materials Needed
1. Electronics Components
- Raspberry Pi Pico W (Microcontroller)
- AJ-SR04M Water Resistant Ultrasonic Distance Sensor (https://www.thingiverse.com/thing:5404031)
- DHT22 / AM2302 Temperature and Humidity Sensor (https://www.thingiverse.com/thing:3222598)
- MQ-7 Carbon Monoxide Gas Sensor (https://www.thingiverse.com/thing:2578744)
- Standard Breadboard
- Jumper Wires (Male-to-Male / Male-to-Female)
- Resistors (10 kΩ, 20 kΩ)
2. Power & Cables
- 5V USB Power Supply (Power Bank)
- Micro-USB Cable (for Raspberry Pi Pico W)
3. Enclosure & Mounting
- Waterproof PVC Enclosure Case
- 3d Printed Sensor Casing for AJ-SR04M
- 3d Printed Sensor Casing for MQ-7
- 3d Printed Sensor Casing for DHT22
- Cable Glands / Grommets (PG13.5 and PG7)
- Screws and Nuts (M3, M4, M5)
- Double-sided Tape
- Cable Ties
- 2-inch PVC Pipe and Connectors (with glue)
- Safety Tether / Rope for hanging
4. Tools
- Multimeter (for testing voltages and connections)
- Screwdriver set
- Electric drill and drill bits
- Cardboard (for temporary testing or layout planning)
Gather and Prepare Components
- Collect all components and tools listed in the Materials Needed section.
- Make sure nothing is missing before you start building.
- Test each component one by one:
- Power on the Raspberry Pi Pico W
- Check the ultrasonic sensor
- Test the DHT22 temperature & humidity sensor
- Test the MQ7 carbon monoxide sensor
- Prepare the enclosure:
- Get the waterproof case / 3D-printed sensor covers ready
- Ensure holes for sensors and cables are clear
- Organize wires and small parts:
- Sort jumper wires, resistors, and screws
- This will make wiring and assembly easier later
Wiring the Components
1.Place the Raspberry Pi Pico W on the breadboard to make wiring easier.
2.Connect the ultrasonic distance sensor (AJ-SR04M)
The ultrasonic distance sensor (AJ-SR04M) is used to measure the distance between the sensor and the water surface for water level monitoring.
The wiring connections are as follows:
- VCC - Breadboard + rail (connected to Pin 36 – 3V3 (OUT) of Raspberry Pi Pico W)
- GND - GND pin of Raspberry Pi Pico W
- TRIG - GPIO4 (GP4)
- ECHO - GPIO3 (GP3)
Pin 36 (3V3 OUT) of the Raspberry Pi Pico W is connected to the positive (+) rail of the breadboard, and the VCC pin of the AJ-SR04M ultrasonic sensor is connected to the same rail to supply 3.3V. The ground pin of the sensor is connected directly to GND pin of the Raspberry Pi Pico W to provide a common ground reference.
3.Connect the Temperature and Humidity Sensor (DHT22)
The temperature and humidity sensor (DHT22) is used to measure the ambient temperature and relative humidity of the surrounding environment.
The wiring connections are as follows:
- VCC - Breadboard + rail (connected to Pin 36 – 3V3 (OUT) of Raspberry Pi Pico W)
- GND - GND pin of Raspberry Pi Pico W
- DATA - GPIO15 (GP15)
The DHT22 sensor is powered using the 3.3V supply from Pin 36 (3V3 OUT) of the Raspberry Pi Pico W through the breadboard positive rail. The VCC pin of the DHT22 sensor is connected to the positive rail, while the ground pin is connected directly to GND pin of the Raspberry Pi Pico W. The data pin of the DHT22 sensor is connected to GPIO15 (GP15) to transmit temperature and humidity data to the microcontroller.
4.Connect the Carbon Monoxide Gas Sensor (MQ-7)
The MQ-7 gas sensor is used to detect the presence of carbon monoxide (CO) gas in the surrounding environment. The sensor provides an analog output voltage proportional to the detected gas concentration.
The wiring connections are as follows:
- VCC - VBUS (5V) of Raspberry Pi Pico W
- GND - GND pin of Raspberry Pi Pico W via 20kΩ resistor
- AO - GPIO26 (ADC0) via 10kΩ resistor
The MQ-7 gas sensor is powered using the VBUS (5V) pin of the Raspberry Pi Pico W to provide sufficient voltage for the sensor heater operation. The ground pin of the sensor is connected to GND pin of the Pico W through a 20kΩ resistor to limit current and enhance circuit safety. The analog output pin (AO) is connected to GPIO26 (ADC0) through a 10kΩ resistor to protect the ADC input from excessive current while allowing accurate voltage measurement.
Programming the Pico W (Using Thonny & ThingSpeak)
- Connect the Raspberry Pi Pico W to your computer using a USB cable.
- Open Thonny IDE on your computer.
- Make sure Thonny is set to use MicroPython (Raspberry Pi Pico):
- Go to Tools → Options → Interpreter
- Select MicroPython (Raspberry Pi Pico)
- Open the project Python code in Thonny.
- Edit the following details in the code:
- WiFi SSID and password
- ThingSpeak API key
- Save the code to the Pico W:
- Name the file (for example: main.py)
- Save it directly to the Pico W
- Run the program in Thonny:
- Check the console for messages
- Make sure the Pico W connects to WiFi successfully
- Log in to ThingSpeak:
- Create a channel
- Assign fields for water level, temperature, humidity, and CO
- Confirm that data appears on the ThingSpeak dashboard
- If data does not appear:
- Recheck WiFi details
- Confirm the API key is correct
- Check sensor wiring and connections
Mounting the System in the Enclosure
- Mark and drill all required holes on the enclosure prior to installation to ensure accurate component placement and proper sealing against environmental exposure.
- Drill one hole at the bottom of the enclosure and install a PG13.5 wire gland to route the cables for both the AJ-SR04M ultrasonic sensor and the MQ-7 gas sensor, as both sensors are mounted below the enclosure.
- Drill one additional hole at the bottom of the enclosure for the USB power cable, since the power supply is positioned outside the enclosure inside a protective bottle.
- Drill one hole on the side of the enclosure and install a PG7 wire gland for routing the DHT22 sensor cable, allowing exposure to ambient air while maintaining enclosure sealing.
- Install a metal bar (bracket) below the enclosure and use it to suspend the 3D-printed casing of the AJ-SR04M ultrasonic sensor, ensuring that the sensor faces downward toward the water surface for accurate distance measurement.
- Mount the DHT22 sensor inside a 3D-printed casing and secure it to the front side of the enclosure using screws to provide stable positioning and proper airflow.
- Place the MQ-7 gas sensor inside its 3D-printed casing and mount it below the enclosure, ensuring sufficient airflow. A plastic cardboard shield is installed at the front of the enclosure to protect the MQ-7 sensor from direct water exposure or rain splashes.
- Route all sensor cables through their respective wire glands and secure the cable ends using electrical tape to enhance insulation and prevent loose or exposed connections.
- Place the Raspberry Pi Pico W, breadboard and electronic components inside the enclosure and attach the breadboard to the interior surface using double-sided tape to prevent movement during operation.
- Mount the enclosure onto a 2-inch diameter PVC pipe using metal mounting straps at the rear side of the enclosure to ensure mechanical stability.
- As an additional safety measure, a strong rope is tied from the PVC pipe to a nearby fence to act as a safety tether. This precaution prevents the system from falling forward in the event that the PVC pipe embedded in the ground becomes unstable, thereby reducing the risk of the enclosure falling into the water.
- The enclosure containing the Raspberry Pi Pico W is then connected to a power bank to supply power to the system. The power bank is placed outside the enclosure inside a 1.5-liter mineral water bottle to protect it from rain and environmental exposure.
- The mineral water bottle is cut into two sections, allowing the power bank to be placed inside, while the USB power cable is routed through the bottle cap. The bottle is then reassembled and sealed using wide adhesive tape to improve water resistance and mechanical stability.
- This power supply arrangement allows easy access to the USB cable for connection to a laptop, enabling system monitoring, data retrieval, or reprogramming without opening the main enclosure, thereby maintaining enclosure sealing and reducing maintenance time.
- After confirming proper power delivery and system operation, finally close and seal the enclosure properly to ensure reliable, safe, and long-term outdoor operation. The installation is then considered complete and ready for continuous outdoor deployment.
Testing the System
- Power on the system using a USB cable or power bank.
- Check the LED indicator on the Pico W:
- The blinking LED shows the system is running.
- Stable LED indicates WiFi connection is active.
- Place an object or your hand below the ultrasonic sensor.
- Observe the change in water level readings.
- Check the temperature and humidity sensor (DHT22):
- Make sure values are updating and not showing zero or error.
- Test the carbon monoxide (CO) sensor:
- Observe changes in voltage values when the environment changes.
- Open your ThingSpeak dashboard.
- Verify that all data fields are updating correctly:
- Water Level
- Temperature
- Humidity
- Carbon Monoxide
- Leave the system running for several minutes.
- Confirm that data updates at the set interval.
- If data does not update:
- Check WiFi connection
- Recheck wiring
- Restart the Pico W
- Once all values appear correctly on ThingSpeak, the system is ready for use.
Viewing and Analyzing Data on ThingSpeak
- Open the ThingSpeak website and log in to your account.
- Go to your project’s ThingSpeak Channel.
- All sensor readings will appear on the ThingSpeak dashboard automatically after data is uploaded.
- The dashboard displays data in graph form, including:
- Water Level (cm)
- Temperature (°C)
- Humidity (%)
- Carbon Monoxide (Voltage)
- Each sensor has its own chart, making the data easy to understand at a glance.
- Observe how the graphs change when:
- Water level rises or falls
- Temperature and humidity vary
- CO sensor detects changes in air quality
- The dashboard updates based on the time interval set in the code.
- Users can view the data anytime and anywhere as long as there is an internet connection.
Final Result and System Overview
- At this stage, the WiFi Water Level Monitoring System is fully assembled and operational.
- The system continuously collects data from all connected sensors:
- Water level using the ultrasonic sensor
- Temperature and humidity using the DHT22
- Carbon monoxide levels using the MQ-7 sensor
- All sensor data is processed by the Raspberry Pi Pico W.
- The Pico W sends the data wirelessly to ThingSpeak through WiFi.
- The readings are displayed clearly on the ThingSpeak dashboard in real-time graphs.
- The system can be powered using a USB power source or power bank, making it portable and easy to deploy.
- This setup demonstrates a complete IoT monitoring solution, from data collection to cloud visualization.
- The project successfully meets the objectives of the CSM3313 IoT Computing group project.