Smart Wetland Sensor: Easy Ecofriendly Project with ESP32
Smart Wetland Sensor: Protecting Our Water Resources
Introduction: Can a Wetland Send Us a Warning?
Imagine a wetland that could tell us, “My water level is falling,” “My soil is drying,” or “My environmental conditions are changing!” Wetlands cannot speak, but smart sensors can collect important environmental information and convert it into useful data. This is the main idea behind the Smart Wetland Sensor.
A Smart Wetland Sensor is an IoT-based environmental monitoring system that uses sensors, a microcontroller, wireless communication, and cloud technology to observe wetland conditions. The system can measure water level, soil moisture, temperature, and humidity. An advanced version can also include pH and turbidity sensors to study water quality.
Wetlands are important because they store water, support biodiversity, reduce flooding, and provide valuable ecological services. However, wetlands can be affected by water loss, pollution, land encroachment, and climate change. A smart monitoring system cannot solve these problems automatically, but it can provide early information that helps students, researchers, and communities investigate changes.
This Smart Wetland Sensor project is an excellent STEM activity because it combines environmental science, electronics, programming, IoT, and data analysis.
Concept of the Smart Wetland Sensor
The Smart Wetland Sensor follows a simple process:
Sense → Process → Transmit → Analyze → Act
First, the sensors collect environmental data.
- The water-level sensor checks whether the water level is increasing or decreasing.
- The soil-moisture sensor detects whether the soil is wet or dry.
- The DHT11 sensor measures temperature and humidity.
These sensor readings are sent to an ESP32 microcontroller. The ESP32 processes the information and displays it on a 16×2 LCD. Because the ESP32 has built-in Wi-Fi, it can also send the data to ThingSpeak, an IoT cloud platform.
The data can then be viewed as graphs over time. If the water level becomes too low, the soil becomes too dry or the temperature becomes unusually high, the system can activate a buzzer and send an alert value to the cloud.
Materials Required for Smart Wetland Sensor
- ESP32 development board
- DHT11 temperature and humidity sensor
- Soil-moisture sensor
- Water-level sensor
- 16×2 I2C LCD
- Buzzer
- Breadboard
- Jumper wires
- USB cable or battery power supply
- Wi-Fi connection
- Laptop with Arduino IDE
- ThingSpeak account
Working Model and Procedure
Step 1: Gather the Components
Arrange all the components and check that they are working properly. Students should understand the purpose of every component before beginning the project.
Step 2: Connect the Sensors
Make the following connections:
| Component | ESP32 Connection |
|---|---|
| DHT11 Data | GPIO 4 |
| Soil Moisture Analog Output | GPIO 34 |
| Water Level Analog Output | GPIO 35 |
| Buzzer | GPIO 5 |
| LCD SDA | GPIO 21 |
| LCD SCL | GPIO 22 |

Important: ESP32 analog inputs should not receive a voltage above 3.3 V. If a sensor module uses a 5 V analog output, use an appropriate voltage divider or a 3.3 V-compatible module.
Step 3: Create a ThingSpeak Channel
Create a new channel and name the fields:
- Field 1 – Temperature
- Field 2 – Humidity
- Field 3 – Soil Moisture
- Field 4 – Water Level
- Field 5 – Alert Code
Then copy your Channel ID and Write API Key. ThingSpeak supports multiple data fields in one channel update, and free accounts have a 15-second minimum update interval.
Step 4: Install the Arduino Libraries
Install these libraries from the Arduino IDE Library Manager:
- ThingSpeak
- DHT sensor library by Adafruit
- Adafruit Unified Sensor
- LiquidCrystal_I2C
Step 5: Upload the Program
Replace the Wi-Fi name, password, Channel ID, and Write API Key in the code. Upload the program to the ESP32.

Complete ESP32 + ThingSpeak IoT Code
Procedure Steps
How the Coding Works
The program reads temperature and humidity using the DHT11 sensor. The ESP32 uses analogRead() to collect values from the soil and water sensors. These raw values are converted into percentages to make them easier for students to understand.
The code uses selected limits:
- Water level below 20% → Alert Code 1
- Soil moisture below 25% → Alert Code 2
- Temperature above 40°C → Alert Code 3
- Normal condition → Alert Code 0
The values are displayed on the LCD and uploaded to ThingSpeak. The ThingSpeak.setField() function prepares each sensor value, while ThingSpeak.writeFields() sends multiple values to the channel together.
Students should remember that the percentage conversion values are only starting points. The sensors should be calibrated by measuring raw values under known dry and wet conditions before using the system for scientific conclusions.
Real-Time Applications
- Wetland Monitoring: Sensors can help observe changes in water level and environmental conditions over time.
- Flood and Drought Awareness: Sudden water-level changes can provide useful information for investigation.
- Environmental Education: Students can study real sensor data instead of learning only from theory.
- Pollution Monitoring: An advanced model with pH and turbidity sensors can help identify unusual water-quality conditions.
- Research Projects: Students can compare data from different seasons and create graphs to identify environmental patterns.
- Smart Conservation: Communities can use monitoring data to support better wetland protection and awareness activities.

Frequently Asked Questions
- What is a Smart Wetland Sensor?
It is an IoT-based system that uses sensors and a microcontroller to monitor environmental conditions and send data for analysis. - Why is ESP32 used in this project?
ESP32 has built-in Wi-Fi, which makes it suitable for sending sensor data to cloud platforms such as ThingSpeak. - Can this system stop pollution automatically?
No. It monitors conditions and provides information. People must investigate and take appropriate action. - Why do we use ThingSpeak?
ThingSpeak helps students store sensor data online and visualize environmental changes over time. - Why is sensor calibration important?
Different sensors can produce different readings. Calibration improves the accuracy and reliability of the measurements.
Conclusion
The Smart Wetland Sensor demonstrates how STEM and IoT technology can support environmental protection. By combining sensors, ESP32 programming, Wi-Fi, and ThingSpeak, students can build a working model that collects, displays, and analyzes environmental data.
This Smart Wetland Sensor project teaches more than coding. It develops scientific observation, problem-solving, electronics knowledge, and environmental responsibility. Smart technology cannot protect wetlands by itself, but it can help people identify changes earlier and make better decisions based on real data.
A small STEM project built in a classroom can inspire future engineers, environmental scientists, and innovators. By using smart sensors today, we can work toward healthier wetlands and safer water resources tomorrow.
Explore More…











