How to Make a Smart River Water Level and Pollution Monitoring Boat / Buoy Using ESP32 and GPS

Meta Description: Learn how to build a smart river water level and pollution monitoring boat using ESP32, GPS and water quality sensors. Includes components, circuit connections, Arduino code and IoT monitoring.

1. Introduction

Water pollution is a major environmental challenge affecting rivers, lakes, dams and other natural water resources. Industrial waste, agricultural chemicals, sewage discharge and plastic pollution can negatively affect aquatic ecosystems and human health.

Traditional water quality monitoring often involves collecting water samples and transporting them to laboratories for testing. Although this method provides useful information, it can be time-consuming and may not provide continuous information about changing river conditions.

The Smart River Water Level and Pollution Monitoring Boat / Buoy Using ESP32 and GPS is an innovative IoT-based environmental monitoring project designed to address this challenge.

The system uses a floating boat or buoy equipped with water quality sensors to collect information about the surrounding water. An ESP32 microcontroller processes the sensor readings and uses a GPS module to determine the geographical location where measurements are collected.

The system can monitor several environmental parameters, including:

  • Water temperature.
  • Water turbidity (cloudiness).
  • Water pH (acidity or alkalinity).
  • Electrical conductivity (EC).
  • Total Dissolved Solids (TDS).
  • Geographical location using GPS.

The collected information can be transmitted to an online dashboard through Wi-Fi or a cellular communication module, allowing environmental researchers, students and water resource managers to monitor river conditions remotely.

Buoy Water Quality Automatic Monitoring System: The Ultimate Guide for Surface Water Monitoring (2026)

2. Objectives of the Project

The main objectives are:

  • To design a smart floating river monitoring boat using ESP32.
  • To monitor water quality using electronic sensors.
  • To measure water temperature, pH and turbidity.
  • To estimate dissolved substances using a TDS sensor.
  • To determine the geographical location of water samples using GPS.
  • To transmit environmental data to an online monitoring dashboard.
  • To identify possible changes in river water quality.
  • To support environmental conservation and pollution monitoring.

3. How the Smart River Monitoring Boat Works

The project combines electronic sensors, a microcontroller, GPS technology and wireless communication.

The floating boat or buoy moves on the surface of the river while its water quality sensors collect measurements.

The ESP32 receives the sensor information and processes it into readable values.

The GPS module provides geographical coordinates, allowing each measurement to be associated with a particular location.

The system then transmits the collected information to an online dashboard for monitoring and analysis.

An Intelligent, low-cost water quality monitoring system with on-device machine learning and cloud integration | Scientific Reports

System operation

  • The boat or buoy floats on the river surface.
  • Water quality sensors collect environmental measurements.
  • The ESP32 processes the sensor readings.
  • The GPS module determines the monitoring location.
  • The ESP32 combines the sensor readings with GPS coordinates.
  • Data is transmitted through Wi-Fi or cellular communication.
  • The online dashboard displays water quality information and location.

4. Components and Materials Required

The following components are required to construct the monitoring system.

No.ComponentQuantityPurpose
1ESP32 DevKit1Main microcontroller
2NEO-6M GPS module1Determines geographical location
3Waterproof turbidity sensor1Measures water cloudiness
4pH sensor module1Measures water acidity or alkalinity
5DS18B20 waterproof temperature sensor1Measures water temperature
6TDS sensor module1Estimates dissolved solids
7Waterproof ultrasonic sensor1Optional river level measurement
818650 rechargeable batteries2 or morePower supply
9Solar panel1Battery charging
10GPS antenna1Improves GPS reception where required
11Floating boat or buoy body1Supports the monitoring equipment
12Waterproof enclosure1Protects electronics
13Jumper wiresAs neededElectrical connections
14Voltage regulator and charging circuit1 setPower management

Optional components include a GSM/4G module, LoRa communication module, OLED display and motor controller.

5. Understanding the Main Electronic Components

A. ESP32 Microcontroller

Jual ESP32 ESP-32 DEVKIT V1 Board 30 Pin Wifi Bluetooth BLE Microcontroller | Shopee Indonesia

The ESP32 is the main processing unit. It receives information from the water quality sensors, processes the measurements and transmits data to an online dashboard.

B. NEO-6M GPS Module

GPS module NEO-6M with EEPROM and antenna | TIPA.EU

The NEO-6M GPS determines the geographical coordinates of the monitoring boat. It provides latitude and longitude information that can be used to identify the location of possible pollution hotspots.

C. Turbidity Sensor

DFRobot Gravity - Flüssigkeitstrübungssensor Botland - Robotikgeschäft

A turbidity sensor measures the cloudiness of water caused by suspended particles such as soil, sediment and other materials. Increased turbidity may indicate contamination or sediment disturbance.

D. pH Sensor

Sensor analógico de PH SEN0161

The pH sensor measures how acidic or alkaline the water is. The pH scale generally ranges from 0 to 14, with 7 representing neutral conditions at approximately 25°C.

E. DS18B20 Waterproof Temperature Sensor

DS18B20 Waterproof Digital Temperature Sensor Probe - Thingbits India

This sensor measures water temperature. Temperature changes can affect aquatic organisms, dissolved oxygen and other water quality characteristics.

F. TDS Sensor

What is tds meter - DFRobot TDS Meter Sensor With Arduino - DFRobot

The Total Dissolved Solids sensor estimates the concentration of dissolved substances in water, commonly expressed in parts per million (ppm). It is useful for observing changes in dissolved ionic substances but cannot identify individual pollutants.

6. Circuit Diagram and ESP32 Connections

The ESP32 connects to the different sensors through its analogue input pins and digital communication interfaces.

The GPS module communicates with the ESP32 through UART, while the DS18B20 temperature sensor uses the OneWire communication protocol.

ESP32-Based Water Quality Monitoring System with pH, TDS, and Turbidity Sensors - How-to Guide and Editable Circuit | Cirkit Designer

Pin connection table

The following pin arrangement can be used for the prototype.

ComponentSensor pinESP32 pin
Turbidity sensorAnalog OUTGPIO 34
pH sensorAnalog OUTGPIO 35
TDS moduleAnalog OUTGPIO 32
DS18B20DataGPIO 4
GPS NEO-6MTXGPIO 16 (RX2)
GPS NEO-6MRXGPIO 17 (TX2)
Ultrasonic sensorTRIGGPIO 5
Ultrasonic sensorECHOGPIO 18 through voltage divider
DS18B20VCC3.3V
GPS moduleVCCAccording to module specification
All sensorsGNDCommon GND

Important electrical precautions:

  • ESP32 analogue inputs must not receive voltages above 3.3V.
  • Check the maximum output voltage of each analogue sensor module. Use suitable voltage dividers or signal-conditioning circuits where necessary.
  • Install a 4.7 kΩ pull-up resistor between the DS18B20 data line and 3.3V.
  • Check the GPS module’s logic-level requirements before connecting its RX pin.
  • The HC-SR04 and similar 5V ultrasonic sensors require an Echo voltage divider.
  • Use a regulated power supply for the ESP32 and sensors.

7. Step-by-Step Project Construction

Step 1: Prepare the floating boat or buoy

Construct a floating platform using waterproof plastic, PVC pipes or a suitable sealed container.

The structure should be stable enough to carry the electronics, sensors, battery and solar panel.

A Solar-Powered Autonomous Boat - Hackster.io

Step 2: Install the ESP32

Mount the ESP32 inside a waterproof electronics enclosure.

The enclosure should protect the controller from rain, splashing water and moisture.

Position the GPS antenna where it has a clear view of the sky. Avoid enclosing the antenna inside metal.

Step 3: Install the water quality sensors

Mount the pH, turbidity, TDS and temperature probes so that their sensing portions can contact the river water.

Ensure that:

  • The pH electrode remains properly immersed when taking measurements.
  • The turbidity sensor is positioned away from direct sunlight where possible.
  • The TDS probe is immersed according to its manufacturer’s instructions.
  • The temperature probe is exposed to the surrounding water.

Keep electronic circuit boards and sensor signal-conditioning modules dry.

Step 4: Connect the GPS module

Connect the NEO-6M GPS module to the ESP32 using the UART pins.

The GPS antenna should be positioned above the water and away from sources of electrical interference.

Step 5: Connect the power supply

Connect the rechargeable battery to a suitable regulated power management circuit.

A solar panel can be used to recharge the battery, allowing the monitoring platform to operate for longer periods.

Step 6: Connect the communication system

Configure the ESP32 to transmit the collected measurements to an online dashboard through Wi-Fi.

For river locations without Wi-Fi coverage, use a suitable cellular modem or LoRa communication system with an available gateway.

Step 7: Test the monitoring system

Place the boat or buoy in a controlled water container before deploying it in a river.

Check the temperature, pH, turbidity, TDS and GPS readings to ensure that all sensors are functioning correctly.

8. Arduino IDE Programming Code

The following example demonstrates how to collect sensor readings, obtain GPS coordinates and transmit the information to an online ThingSpeak dashboard.

Required Arduino libraries

Install these libraries using Arduino IDE Library Manager:

  • TinyGPSPlus
  • OneWire
  • DallasTemperature

The ESP32 board package should also be installed in Arduino IDE.

ThingSpeak dashboard setup

  • Visit ThingSpeak.
  • Create an account.
  • Create a new channel.
  • Enable seven fields.

Use the following field arrangement:

FieldData
Field 1Water pH
Field 2Turbidity sensor voltage
Field 3TDS estimate
Field 4Water temperature
Field 5Latitude
Field 6Longitude
Field 7Water level (optional)

Copy the channel’s Write API Key and insert it into the program.

ESP32 source code


#include <WiFi.h>
#include <HTTPClient.h>
#include <TinyGPSPlus.h>
#include <OneWire.h>
#include <DallasTemperature.h>

// Wi-Fi settings
const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";

// ThingSpeak settings
String apiKey = "YOUR_WRITE_API_KEY";

// Sensor pins
#define TURBIDITY_PIN 34
#define PH_PIN 35
#define TDS_PIN 32
#define TEMP_PIN 4

// GPS pins
#define GPS_RX 16
#define GPS_TX 17

// Temperature sensor
OneWire oneWire(TEMP_PIN);
DallasTemperature tempSensor(&oneWire);

// GPS object
TinyGPSPlus gps;
HardwareSerial gpsSerial(2);

// Sensor readings
float phValue = 0;
float turbidityVoltage = 0;
float tdsValue = 0;
float temperature = 0;

double latitude = 0;
double longitude = 0;

void setup() {

  Serial.begin(115200);

  gpsSerial.begin(
    9600,
    SERIAL_8N1,
    GPS_RX,
    GPS_TX
  );

  tempSensor.begin();

  WiFi.begin(ssid, password);

  Serial.println("Connecting to Wi-Fi");

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("\nWi-Fi Connected");
}

void readGPS() {

  while (gpsSerial.available()) {
    gps.encode(gpsSerial.read());
  }

  if (gps.location.isValid()) {

    latitude = gps.location.lat();
    longitude = gps.location.lng();

  }
}

void readSensors() {

  int rawPH = analogRead(PH_PIN);
  int rawTurbidity = analogRead(TURBIDITY_PIN);
  int rawTDS = analogRead(TDS_PIN);

  // Convert ADC readings to voltage
  float phVoltage = rawPH * 3.3 / 4095.0;

  turbidityVoltage =
    rawTurbidity * 3.3 / 4095.0;

  float tdsVoltage =
    rawTDS * 3.3 / 4095.0;

  // Example only: requires pH calibration
  phValue = 7.0 +
    ((2.5 - phVoltage) * 3.5);

  // Example TDS estimation
  // Requires calibration with standard solutions
  tdsValue =
    (133.42 * tdsVoltage *
    tdsVoltage * tdsVoltage
    - 255.86 * tdsVoltage *
    tdsVoltage
    + 857.39 * tdsVoltage) * 0.5;

  // Read water temperature
  tempSensor.requestTemperatures();

  temperature =
    tempSensor.getTempCByIndex(0);

  Serial.println("\n--- RIVER MONITOR ---");

  Serial.print("pH: ");
  Serial.println(phValue);

  Serial.print("Turbidity Voltage: ");
  Serial.println(turbidityVoltage);

  Serial.print("TDS: ");
  Serial.println(tdsValue);

  Serial.print("Temperature: ");
  Serial.println(temperature);

  Serial.print("Latitude: ");
  Serial.println(latitude, 6);

  Serial.print("Longitude: ");
  Serial.println(longitude, 6);
}

void uploadData() {

  if (WiFi.status() == WL_CONNECTED) {

    HTTPClient http;

    String url =
      "http://api.thingspeak.com/update?api_key="
      + apiKey;

    url += "&field1=" + String(phValue, 2);
    url += "&field2=" + String(turbidityVoltage, 3);
    url += "&field3=" + String(tdsValue, 1);
    url += "&field4=" + String(temperature, 2);
    url += "&field5=" + String(latitude, 6);
    url += "&field6=" + String(longitude, 6);

    http.begin(url);

    int response = http.GET();

    Serial.print("Upload response: ");
    Serial.println(response);

    http.end();
  }
}

void loop() {

  readGPS();

  readSensors();

  uploadData();

  delay(20000);
}

Important calibration note: The pH and TDS equations above are illustrative starting points, not universal sensor conversion formulas. Their accuracy depends on the particular sensor interface, ADC characteristics, calibration solutions and temperature compensation. Calibrate the pH probe using appropriate buffer solutions and the TDS module using known conductivity standards. The turbidity voltage is deliberately uploaded as a raw measurement because converting it into NTU requires sensor-specific calibration. Validate the GPS fix before accepting location data.

ThingSpeak commonly enforces a minimum 15-second update interval for free channels, so the example uses a 20-second delay. The example uses HTTP for simplicity; use HTTPS and appropriate certificate validation for a production deployment.

9. River Water Level Monitoring

In addition to water quality monitoring, the project can be upgraded to measure changes in river water levels.

There are two possible approaches.

A. Waterproof ultrasonic measurement

A waterproof ultrasonic sensor such as the JSN-SR04T can be mounted on a fixed bridge or riverbank structure facing the water surface.

It measures the distance between the sensor and the water surface.

The river level can then be calculated using:

L=H-d

Where:

  • = Water level above the reference point.
  • = Known distance from the sensor to the reference datum.
  • = Measured distance to the water surface.
Water Irrigation Decision Support System for Practical Weir Adjustment Using Artificial Intelligence and Machine Learning Techniques

B. Water pressure sensor

A waterproof pressure transducer can be submerged at a fixed depth to measure the pressure exerted by the water.

The pressure measurement can be used to estimate water depth.

h=\frac{P}{\rho g}

Where:

  • = Water depth.
  • = Water pressure relative to atmospheric pressure.
  • = Density of water.
  • = Acceleration due to gravity.

Important design consideration: A floating buoy rises and falls with the river surface. Therefore, an ultrasonic sensor mounted on the buoy cannot independently measure absolute river-level changes. For reliable river-level monitoring, use a fixed reference on the riverbank or bridge, or a properly anchored pressure sensor.

The floating boat is best suited for mobile water quality measurements, while a fixed monitoring station provides more reliable river-level measurements.

10. IoT Dashboard and Remote Monitoring

The ESP32 can transmit collected data to ThingSpeak, where it can be displayed through charts and monitoring widgets.

An Intelligent, low-cost water quality monitoring system with on-device machine learning and cloud integration | Scientific Reports

The dashboard can display:

ParameterInformation displayed
Water pHAcidity or alkalinity
TurbidityWater cloudiness
TDSEstimated dissolved solids
TemperatureWater temperature in °C
LatitudeGPS geographical coordinate
LongitudeGPS geographical coordinate
Water levelRiver level from fixed monitoring station

The GPS coordinates can also be opened in Google Maps to identify the monitoring location.

For example, the dashboard can help identify locations where turbidity increases or pH changes significantly.

11. Pollution Detection and Alert System

The project can be upgraded to identify unusual changes in water quality.

For example:

ParameterPossible observation
pHUnusual acidic or alkaline conditions
TurbidityIncreased suspended particles
TDSChanges in dissolved ionic substances
TemperatureUnusual temperature increases
GPSLocation of the recorded measurement

An additional buzzer or notification system can be introduced to alert researchers when readings exceed selected monitoring thresholds.

However, these sensors do not identify specific chemicals, pathogens, heavy metals or all forms of pollution. They provide screening information that should be followed by laboratory analysis where contamination is suspected.

12. Power Supply and Solar Charging System

Since the monitoring boat may operate away from buildings and electrical outlets, a rechargeable battery system is recommended.

Science - Research and Monitoring | Mallows Bay-Potomac River National Marine Sanctuary

Suggested power components

ComponentPurpose
Solar panelConverts sunlight into electrical energy
Rechargeable batteryStores electrical energy
Solar charge controllerManages battery charging
DC-DC converterProvides regulated voltage
ESP32Processes and transmits information
Waterproof enclosureProtects electronics

The solar panel should be sized according to the total power consumption, operating time, battery capacity and expected sunlight.

Use a proper battery management system with overcharge, over-discharge and short-circuit protection. Do not connect a solar panel directly to a lithium battery.

13. Improving the Project Using Additional Technologies

Meet Aquabot: Aquatic drone that measures water quality throughout river networks - The Brighter Side of News
“水质巡逻兵”--无人值守船 - 粤港澳大湾区应用场景发布厅
Real-Time Environmental Monitoring for Aquaculture Using a LoRaWAN-Based IoT Sensor Network
Autonomous Water Quality Monitoring and Water Surface Cleaning for Unmanned Surface Vehicle
Remote Surface Water Vehicle | ysi.com
Autonomous Water Quality Monitoring and Water Surface Cleaning for Unmanned Surface Vehicle
Remote Surface Water Vehicle | ysi.com
A Low-Cost AI Buoy System for Monitoring Water Quality at Offshore Aquaculture Cages | MDPI
Erstmaliger Einsatz autonomer Wasserdrohne: Bezirksregierung Düsseldorf und Fraunhofer IOSB vermessen die Ruhr -  Fraunhofer IOSB
Jal Rakshak Part 1 | project
SSU WATERS Grant Recipient Nansong Wu: Using Low-Cost Conductivity Sensors to Measure Salinity at Russian River Estuary | Center for Environmental Inquiry at Sonoma State University
A Low-Cost Sensor Buoy System for Monitoring Shallow Marine Environments
Measuring the mighty Mississippi | Modern discharge data collection using ADCP, water quality, and autonomous platforms
智慧水務於水質管理之應用  - 成大水工所
Drones acuáticos con inteligencia artificial para cuidar ríos y lagos | Escuela Técnica Superior de Ingeniería
Development of Autonomous Electric USV for Water Quality Detection
Autonomous Water Quality Monitoring and Water Surface Cleaning for Unmanned Surface Vehicle

The project can be further improved through the following developments.

A. Autonomous Navigation

Add DC motors, propellers, motor drivers and a suitable control system to allow the boat to move between selected monitoring locations.

B. LoRa Communication

Use LoRa modules to transmit sensor readings over longer distances where suitable gateway coverage is available.

C. GSM/4G Communication

Integrate a cellular modem to send monitoring data from remote river locations to an online platform.

D. Automatic Pollution Alerts

Configure the ESP32 to send notifications when measured parameters exceed predetermined thresholds.

E. Artificial Intelligence Integration

Historical measurements can be analysed to identify unusual changes, pollution patterns and possible environmental risks.

F. Water Sampling Mechanism

A small controlled pump can be added to collect water samples for laboratory testing at selected GPS locations.

14. Applications of the Smart River Monitoring System

The project has several potential applications.

  • River pollution monitoring: Observing changes in river water quality.
  • Environmental conservation: Supporting research into aquatic ecosystems.
  • Agriculture: Monitoring water sources used for irrigation.
  • Water resource management: Collecting geographical water quality data.
  • Industrial monitoring: Observing downstream changes near industrial discharge locations.
  • Research institutions: Supporting environmental science experiments.
  • Flood monitoring: Combining fixed river-level sensors with GPS-enabled monitoring stations.
  • STEM education: Demonstrating IoT, robotics, electronics and environmental science.

15. Advantages of the Project

  • Supports continuous environmental data collection.
  • Combines GPS location tracking with water quality monitoring.
  • Can transmit information to remote dashboards.
  • Reduces the need to manually collect every monitoring reading.
  • Can identify locations requiring further environmental investigation.
  • Supports solar-powered operation.
  • Can be upgraded into an autonomous monitoring boat.
  • Encourages practical innovation in environmental conservation.

16. Limitations and Troubleshooting

ProblemPossible causeSolution
GPS does not provide coordinatesPoor satellite receptionPosition antenna with a clear sky view
Incorrect pH readingsPoor calibrationCalibrate using standard buffer solutions
Unstable turbidity readingsSensor positioning or interferenceClean and reposition the probe
Incorrect TDS readingsTemperature or calibration errorCalibrate with conductivity standards
ESP32 disconnectsWeak Wi-Fi signalUse cellular or LoRa communication
Battery drains quicklyHigh power consumptionOptimize sampling and transmission intervals
Water enters enclosurePoor waterproof sealingUse suitable waterproof housing and cable glands

Safety precautions: Test the boat in a controlled environment before river deployment. Secure the electronics, battery and sensors against water ingress. Avoid deployment during floods or dangerous river conditions. The system should be recovered safely for cleaning, calibration and maintenance.

17. Conclusion

The Smart River Water Level and Pollution Monitoring Boat / Buoy Using ESP32 and GPS demonstrates how Internet of Things technology can be applied to environmental conservation and water resource management.

By combining water quality sensors, GPS positioning and wireless communication, the project provides a platform for collecting geographical water quality information from rivers and other water bodies.

The ESP32 processes measurements from the sensors while GPS identifies where the readings are collected. The information can then be transmitted to an online dashboard for analysis and environmental monitoring.

With additional improvements such as solar charging, autonomous navigation, LoRa communication and automatic water sampling, the project can be developed into an advanced environmental monitoring platform.

mbeva

Dominic Mbeva is a science teacher, experienced researcher, innovator, and creative technologist with expertise in STEM education, digital media, and scientific research. As a Kenya Science and Engineering Fair (KSEF) advisor and projects manager, he mentors young scientists, guiding them in developing award-winning innovations. He is also an IC Technorat, leading advancements in science and technology. Beyond education, Dominic is a skilled photographer and video editor, using visual storytelling to make science more engaging. His philosophy, “If you take care of minutes, hours will take care of themselves,” reflects his belief in consistent effort, strategic thinking, and innovation to drive success in both research and creativity.

Related Posts

How to build an automatic street light controller using Arduino and an LDR sensor.

Meta Description: Learn how to build an automatic street light controller using Arduino and an LDR sensor. Explore circuit connections, components, Arduino code and how the system works. 1. Introduction…

Read more

How to Make an Ultrasonic Reverse Parking Sensor System Using Arduino, Buzzer, and LCD

Meta Description: Learn how to build an ultrasonic reverse parking sensor using Arduino, HC-SR04 sensor, buzzer and LCD. Follow the circuit connections, programming code and step-by-step construction guide. 1. Introduction…

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *