Water Level and Temperature Detection
System
EE34-Microprocessor Project
Presented By:
Sean Ben G. Kadusale
Adcil Vic B. Tagulo
Pat Roa
Presented to:
Engr. George Bernard Carlos
Description/Design Objectives
The water level and temperature sensor project aim to develop a reliable and
accurate system for monitoring water levels and temperatures in various applications.
The system will utilize sensor technology to gather data, which will be processed and
transmitted for real-time monitoring and analysis. The purpose of this project is to
provide a comprehensive solution for monitoring water levels and temperatures in
diverse environments, such as reservoirs, tanks, agricultural fields, and industrial
settings. By continuously monitoring these parameters, the project aims to enhance
safety, improve efficiency, and support informed decision-making regarding water
resource management. The design of this project is to
• Water Level Monitoring: The system will accurately measure and track water
levels using an ultrasonic sensor, providing real-time data on water levels in
various containers or bodies of water.
• Temperature Monitoring: The system will measure and record temperature
variations in the monitored water sources, allowing for analysis of thermal
changes and identification of potential issues.
• Data Visualization: The collected data will be presented through a user-friendly
interface, enabling users to easily interpret and analyze water level and
temperature trends over time.
List of Materials and Equipment’s
• ESP 32
• Breadboard
• Jumper Wires
• Ultrasonic Sensor
• DS18B20 Temperature sensor
Schematic Diagram
Firmware
main.cpp
#include <Arduino.h>
#include <WiFi.h>
#include <WebServer.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// Wi-Fi settings
const char* ssid = "AdvilVicks";
const char* password = "12345678";
// Ultrasonic Sensor
const int trigPin = GPIO_NUM_22;
const int echoPin = GPIO_NUM_23;
// Temperature Sensor (DS18B20)
const int temperaturePin = GPIO_NUM_0;
WiFiServer server(80);
OneWire oneWire(temperaturePin);
DallasTemperature sensors(&oneWire);
// Function declarations
float readWaterLevel();
float readTemperature();
void handleRoot();
WebServer webServer(80);
void setup() {
// Initialize Serial communication
Serial.begin(115200);
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
Serial.print("Local IP address: ");
Serial.println(WiFi.localIP());
// Initialize sensors
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
sensors.begin();
// Route definitions
webServer.on("/", handleRoot);
// Start the web server
webServer.begin();
Serial.println("Water Level and Temperature Monitor");
}
void loop() {
webServer.handleClient();
}
void handleRoot() {
float waterLevel = readWaterLevel();
float temperature = readTemperature();
String html = "<html><body>";
html += "<h1>Water Level and Temperature Monitor</h1>";
html += "<p>Water Level: " + String(waterLevel) + " cm</p>";
html += "<p>Temperature: " + String(temperature) + " °C</p>";
html += "</body></html>";
webServer.send(200, "text/html", html);
}
float readWaterLevel() {
// Send ultrasonic sensor pulse
digitalWrite(trigPin, LOW);
delayMicroseconds(1);
digitalWrite(trigPin, HIGH);
delayMicroseconds(1);
digitalWrite(trigPin, LOW);
// Read the pulse duration
float duration = pulseIn(echoPin, HIGH);
// Calculate the distance (in centimeters)
float distance = duration * 0.034 / 2;
return distance;
}
float readTemperature() {
// Request temperature from DS18B20 sensor
sensors.requestTemperatures();
// Read temperature from DS18B20 sensor
float temperature = sensors.getTempCByIndex(0);
return temperature;
}
platformio.ini
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:nodemcu-32s]
platform = espressif32
board = nodemcu-32s
framework = arduino
monitor_speed = 115200
lib_deps =
adafruit/DHT sensor library@^1.4.4
adafruit/Adafruit Unified Sensor@^1.1.9
milesburton/DallasTemperature@^3.11.0
paulstoffregen/OneWire@^2.3.7
Conclusion
In conclusion, the water level and temperature sensor project aims to provide a
comprehensive and reliable solution for monitoring water levels and temperatures in
various applications. By leveraging advanced sensor technology and the capabilities of
the ESP32 platform, the project offers numerous benefits and features.
The use of the ESP32 enables wireless connectivity, allowing seamless communication
and integration into IoT networks. Real-time data monitoring and remote access provide
up-to-date information for informed decision-making, while energy efficiency ensures
optimal operation and extended battery life. The ESP32's data logging capabilities
facilitate historical data analysis and trend identification, contributing to effective water
resource management strategies.
The project's design objectives prioritize accuracy, precision, and user-friendliness.
Robust communication protocols, scalable and modular design, and a focus on
environmental sensitivity ensure the system's reliability and adaptability across diverse
settings. Cost-effectiveness, data security, and sustainability considerations further
enhance the project's value and practicality.
By combining the water level and temperature sensors with the ESP32 platform, the
project offers an efficient, connected, and cost-effective solution for monitoring water
resources. It empowers water resource management authorities, agricultural
professionals, industrial facilities, and individuals with accurate data, real-time insights,
and proactive decision-making capabilities.
Overall, the water level and temperature sensor project demonstrates a commitment to
enhancing safety, efficiency, and sustainability in water resource management. It sets the
foundation for smarter and more informed water management practices, contributing to
a more sustainable and responsible utilization of this vital natural resource.
Recommendation
To maximize the effectiveness of the water level and temperature detection project,
the product should be conducted to a thorough field testing, implement data analytics for
valuable insights, enhance the user interface, explore integration with external systems,
seek feedback for continuous improvement, and address any
challenges or issues that may arise. In addition, prioritize usability and accessibility by
designing the system with a user-friendly interface and intuitive data visualization. This
will ensure that users, regardless of their technical background, can easily interpret and
interact with the collected data. Continuously explore opportunities for integrating the
sensor system with external platforms or services, such as weather forecasting or
irrigation systems, to enhance its functionality and provide a more comprehensive
solution. Lastly, foster a culture of continuous improvement by actively seeking feedback
from users, addressing any issues or challenges promptly, and staying updated with
technological advancements and industry standards to ensure the system remains
effective and aligned with evolving needs.
Reference
• ESP32IO. (n.d.). ESP32 water sensor tutorial. In ESP32IO. Retrieved from
https://esp32io.com/tutorials/esp32-water-sensor
• Ahmad, F. (2021, February 14). IoT contactless water level monitoring with ESP32
and HC-SR04. In Microcontrollers Lab. Retrieved from
https://microcontrollerslab.com/iot-contactless-water-level-monitoring-esp32hc-
sr04/
• Tullock, I. (2022, January 18). How to Build a Water Level Sensor Using Ultrasonic
Sensor and Home Assistant. In MakeUseOf. Retrieved from
https://www.makeuseof.com/build-water-level-sensor-using-ultrasonic-
sensorand-home-assistant/
• IoT Design Pro. (n.d.). IoT-Based Water Level Indicator Using Ultrasonic Sensor.
In IoT Design Pro. Retrieved from https://iotdesignpro.com/projects/iot-
basedwater-level-indicator-using-ultrasonic-sensor
• Santana, R. (2021, March 17). ESP32 DS18B20 Temperature Sensor with Arduino
IDE. In Random Nerd Tutorials. Retrieved from
https://randomnerdtutorials.com/esp32-ds18b20-temperature-arduino-ide/
• ElectronicWings. (n.d.). DS18B20 Sensor Interfacing with ESP32.
In
ElectronicWings. Retrieved from
https://www.electronicwings.com/esp32/ds18b20-sensor-interfacing-withesp32