Water Level Monitoring System

by s72334 in Circuits > Sensors

326 Views, 1 Favorites, 0 Comments

Water Level Monitoring System

CSM3313 - 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?

  1. Learn New Skills

This project helps us learn basic electronics, sensor usage and WiFi communication while building a working IoT system.

  1. 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.

  1. Cost-Effective Solution

By using affordable and easily available components, this system can be built at a low cost compared to commercial products.

  1. Flexible and Expandable Design

The system can be upgraded by adding more sensors like temperature, humidity or gas sensors in the future.

  1. 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:

  1. How to measure water level using a water-resistant ultrasonic sensor
  2. How to read temperature and humidity data using a DHT22 sensor
  3. How to detect carbon monoxide levels using an MQ-7 gas sensor
  4. How to use a Raspberry Pi Pico W with WiFi for IoT applications
  5. How to send sensor data to a cloud platform (ThingSpeak) for monitoring
  6. How to power an IoT system using a USB power bank
  7. Basic troubleshooting and testing techniques for IoT sensors

Downloads

Supplies

Materials Needed


1. Electronics Components

  1. Raspberry Pi Pico W (Microcontroller)
  2. AJ-SR04M Water Resistant Ultrasonic Distance Sensor (https://www.thingiverse.com/thing:5404031)
  3. DHT22 / AM2302 Temperature and Humidity Sensor (https://www.thingiverse.com/thing:3222598)
  4. MQ-7 Carbon Monoxide Gas Sensor (https://www.thingiverse.com/thing:2578744)
  5. Standard Breadboard
  6. Jumper Wires (Male-to-Male / Male-to-Female)
  7. Resistors (10 kΩ, 20 kΩ)


2. Power & Cables

  1. 5V USB Power Supply (Power Bank)
  2. Micro-USB Cable (for Raspberry Pi Pico W)


3. Enclosure & Mounting

  1. Waterproof PVC Enclosure Case
  2. 3d Printed Sensor Casing for AJ-SR04M
  3. 3d Printed Sensor Casing for MQ-7
  4. 3d Printed Sensor Casing for DHT22
  5. Cable Glands / Grommets (PG13.5 and PG7)
  6. Screws and Nuts (M3, M4, M5)
  7. Double-sided Tape
  8. Cable Ties
  9. 2-inch PVC Pipe and Connectors (with glue)
  10. Safety Tether / Rope for hanging


4. Tools

  1. Multimeter (for testing voltages and connections)
  2. Screwdriver set
  3. Electric drill and drill bits
  4. Cardboard (for temporary testing or layout planning)


Gather and Prepare Components

abf847dd-3558-4162-9dfd-bee244d1863d.jpg
e4345258-f0b8-4fb3-a596-be5d727939ed.jpg
  1. Collect all components and tools listed in the Materials Needed section.
  2. Make sure nothing is missing before you start building.
  3. Test each component one by one:
  4. Power on the Raspberry Pi Pico W
  5. Check the ultrasonic sensor
  6. Test the DHT22 temperature & humidity sensor
  7. Test the MQ7 carbon monoxide sensor
  8. Prepare the enclosure:
  9. Get the waterproof case / 3D-printed sensor covers ready
  10. Ensure holes for sensors and cables are clear
  11. Organize wires and small parts:
  12. Sort jumper wires, resistors, and screws
  13. This will make wiring and assembly easier later

Wiring the Components

6271636049238888396.jpg
dcd0c830-41df-4c2d-971f-562c50d1ae49.jpg
54edae00-6f20-4234-8443-def20d09525a.jpg

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:

  1. VCC - Breadboard + rail (connected to Pin 36 – 3V3 (OUT) of Raspberry Pi Pico W)
  2. GND - GND pin of Raspberry Pi Pico W
  3. TRIG - GPIO4 (GP4)
  4. 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:

  1. VCC - Breadboard + rail (connected to Pin 36 – 3V3 (OUT) of Raspberry Pi Pico W)
  2. GND - GND pin of Raspberry Pi Pico W
  3. 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:

  1. VCC - VBUS (5V) of Raspberry Pi Pico W
  2. GND - GND pin of Raspberry Pi Pico W via 20kΩ resistor
  3. 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)

Screenshot 2026-01-09 223026.png
Screenshot 2026-01-09 223338.png
  1. Connect the Raspberry Pi Pico W to your computer using a USB cable.
  2. Open Thonny IDE on your computer.
  3. Make sure Thonny is set to use MicroPython (Raspberry Pi Pico):
  4. Go to Tools → Options → Interpreter
  5. Select MicroPython (Raspberry Pi Pico)
  6. Open the project Python code in Thonny.
  7. Edit the following details in the code:
  8. WiFi SSID and password
  9. ThingSpeak API key
  10. Save the code to the Pico W:
  11. Name the file (for example: main.py)
  12. Save it directly to the Pico W
  13. Run the program in Thonny:
  14. Check the console for messages
  15. Make sure the Pico W connects to WiFi successfully
  16. Log in to ThingSpeak:
  17. Create a channel
  18. Assign fields for water level, temperature, humidity, and CO
  19. Confirm that data appears on the ThingSpeak dashboard
  20. If data does not appear:
  21. Recheck WiFi details
  22. Confirm the API key is correct
  23. Check sensor wiring and connections

Mounting the System in the Enclosure

918a53f6-931f-44c6-b378-7834db9cfc5c.jpg
aea0075a-a0bb-44ff-ace6-707833008552.jpg
f32a5b25-e864-42af-be3e-d886bd2320d8.jpg
  1. Mark and drill all required holes on the enclosure prior to installation to ensure accurate component placement and proper sealing against environmental exposure.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. 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.
  10. 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.
  11. 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.
  12. 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.
  13. 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.
  14. 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.
  15. 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

d51313f6-02db-49ea-84e2-cb560755351f.jpg
Screenshot 2026-01-09 230723.png
  1. Power on the system using a USB cable or power bank.
  2. Check the LED indicator on the Pico W:
  3. The blinking LED shows the system is running.
  4. Stable LED indicates WiFi connection is active.
  5. Place an object or your hand below the ultrasonic sensor.
  6. Observe the change in water level readings.
  7. Check the temperature and humidity sensor (DHT22):
  8. Make sure values are updating and not showing zero or error.
  9. Test the carbon monoxide (CO) sensor:
  10. Observe changes in voltage values when the environment changes.
  11. Open your ThingSpeak dashboard.
  12. Verify that all data fields are updating correctly:
  13. Water Level
  14. Temperature
  15. Humidity
  16. Carbon Monoxide
  17. Leave the system running for several minutes.
  18. Confirm that data updates at the set interval.
  19. If data does not update:
  20. Check WiFi connection
  21. Recheck wiring
  22. Restart the Pico W
  23. Once all values appear correctly on ThingSpeak, the system is ready for use.

Viewing and Analyzing Data on ThingSpeak

Screenshot 2026-01-09 230632.png
Screenshot 2026-01-09 231049.png
Screenshot 2026-01-09 231102.png
  1. Open the ThingSpeak website and log in to your account.
  2. Go to your project’s ThingSpeak Channel.
  3. All sensor readings will appear on the ThingSpeak dashboard automatically after data is uploaded.
  4. The dashboard displays data in graph form, including:
  5. Water Level (cm)
  6. Temperature (°C)
  7. Humidity (%)
  8. Carbon Monoxide (Voltage)
  9. Each sensor has its own chart, making the data easy to understand at a glance.
  10. Observe how the graphs change when:
  11. Water level rises or falls
  12. Temperature and humidity vary
  13. CO sensor detects changes in air quality
  14. The dashboard updates based on the time interval set in the code.
  15. Users can view the data anytime and anywhere as long as there is an internet connection.


Final Result and System Overview

  1. At this stage, the WiFi Water Level Monitoring System is fully assembled and operational.
  2. The system continuously collects data from all connected sensors:
  3. Water level using the ultrasonic sensor
  4. Temperature and humidity using the DHT22
  5. Carbon monoxide levels using the MQ-7 sensor
  6. All sensor data is processed by the Raspberry Pi Pico W.
  7. The Pico W sends the data wirelessly to ThingSpeak through WiFi.
  8. The readings are displayed clearly on the ThingSpeak dashboard in real-time graphs.
  9. The system can be powered using a USB power source or power bank, making it portable and easy to deploy.
  10. This setup demonstrates a complete IoT monitoring solution, from data collection to cloud visualization.
  11. The project successfully meets the objectives of the CSM3313 IoT Computing group project.