ESP32/IoT B.Tech/Diploma Beginner

IoT Based Drinking Water Quality Monitoring with ESP32

IoT Based Drinking Water Quality Monitoring System with ESP32 WiFi Module, TDS, EC & DS18B20 Temperature Sensor with Arduino Code & Thingspeak

  • Suitable forB.Tech/Diploma ESP32/IoT students
  • Build time1-2 weeks
  • LevelBeginner
  • Available atAjvika Labs, Kakinada

About this project

Overview
In this project, we will make
IoT Based Drinking Water Quality Monitoring System
with
ESP32
WiFi Module,
TDS/EC Sensor
& Temperature Sensor. This complete system can be used to monitor the drinking water quality, i.e Water
Electrical Conductivity
or
EC
& Water
Temperature
. The EC & temperature value can be monitored online from any part of the world on an
IoT Server
called Thingspeak.
According to
WHO standards
, EC value should not exceed
400 μS/cm
or
0.4mS/cm
. The best temperature for drinking water is room temperature (
20°C / 68°F
) for maximum flavor or chilled cold (
6°C / 43°F
) for maximum refreshment.
This project uses a
TDS Sensor
and
DS18B20 waterproof temperature
sensor along with
ESP32 WiFi Module
to measure water quality monitoring parameters like Electrical Conductivity & temperature. The EC & Temperature value will be displayed on a
0.96″ I2C OLED Display
. The same data can also be monitored graphically on
Thingspeak Server
online.
Check the previous projects related to TDS Sensor:

Arduino Based TDS Meter

IoT ESP8266 TDS Meter

Aquarium Water Quality Monitoring System
Bill of Materials
To make
IoT based Water Quality Monitoring System
, we need the following components. You can purchase all these components online from the given link.
S.N.
Components Name
Quantity
Purchase Links

ESP32 Board

Amazon
AliExpress

Analog TDS Sensor

Amazon
AliExpress

DS81B20 Temperature Sensor

Amazon
AliExpress

Resistor 4.7K

Amazon
AliExpress

Connecting Wires

Amazon
AliExpress

Breadboard

Amazon
AliExpress
What is Water Electrical Conductivity (EC)?
EC or Electrical Conductivity of water is its ability to conduct an
electric current
. Salts or other chemicals that dissolve in water can break down into positively and negatively charged ions. These
free ions
in the water conduct electricity, so the water’s electrical conductivity depends on the
concentration
of ions.
Salinity
and
total dissolved solids (TDS)
are used to calculate the EC of water, which helps to indicate the water’s purity. The pure the water, the lower the conductivity. To give a real-life example,
distilled water
is almost an insulator, but
salt water
is a very efficient electrical conductor.
Analog TDS Sensor
The
Analog TDS Sensor
is an
Arduino-compatible TDS sensor/Meter
Kit for measuring TDS value of the water. It can be applied to domestic water, hydroponic and other fields of water quality testing. This product supports
3.3 ~ 5.5V
wide voltage input, and
0 ~ 2.3V
analog voltage output, which makes it compatible with 5V or 3.3V control systems or boards.
The excitation source is an
AC signal
, which can effectively prevent the probe from
polarization
and prolong the life of the probe, meanwhile, it can help increase the stability of the output signal. The
TDS probe
is waterproof, it can be immersed in water for long time measurement.
The sensor has a TDS Measurement Range between 0 ~ 1000ppm with an accuracy of 10% FS (25 ℃). The probe can not to be used in water above 55 degrees centigrade.
Specifications
Input Voltage: 3.3 ~ 5.5V
Output Voltage: 0 ~ 2.3V
Working Current: 3 ~ 6mA
TDS Measurement Range: 0 ~ 1000ppm
TDS Measurement Accuracy: ± 10% F.S. (25 ℃)
Waterproof Probe
DS18B20 Waterproof Temperature Sensor
This is a pre-wired and
waterproofed version of the
DS18B20 Sensor
used to measure something far away, or in wet conditions. The Sensor can measure the temperature between
-55 to 125°C
(-67°F to +257°F). The cable is jacketed in PVC. These 1-wire digital temperature sensors are fairly precise, i.e ±0.5°C over much of the range. They work great with any microcontroller using a single digital pin.
The sensor requires two libraries like
Dallas Temperature Sensor Library
&
One-Wire Library
. It also requires a
4.7k
resistor, which is required as a pullup from the DATA to the VCC line when using the sensor. To learn more about this sensor you can go through the previous post:
DS18B20 Sensor Tutorial
Circuit: IoT Based Water Quality Monitoring System
Now, let us
interface
the Analog
TDS Sensor & DS18B20 Temperature Sensor with ESP32
Board. The reason why we are using a temperature sensor is that the temperature parameter is required during Electrical Conductivity EC Value compensation. The EC values change a lot with rising and fall in temperature.
Here is the simple
connection diagram
for the project.
Connect the TDS & Temperature Sensor
VCC
&
GND
Pin to ESP32 3.3V & GND Pin respectively. Connect the output analog pin of the TDS Sensor to ESP32
A0
Pin, which is the GPIO36 Pin. Similarly, connect the output of DS18B20 to ESP32
IO14
Pin. A 4.7K pull of resistor is necessary and requires a connection between the DS18B20 output pin & 3.3V VCC as a parasitic power.
You may assemble the components on a breadboard for testing purposes.
Project PCB Gerber File & PCB Ordering Online
If you don’t want to assemble the circuit on a breadboard and you want
PCB
for the project, then here is the PCB for you. I used EasyEDA to design the PCB. The PCB Board for
IoT Water Quality Monitoring
looks something like below.
The Gerber File for the PCB is given below. You can simply download the Gerber File and order the PCB from
ALLPCB
at
1$
only.
Download Gerber File:
IoT Drinking Water Quality Monitoring
You can use this Gerber file to order high quality PCB for this project. To do that visit the
ALLPCB
official website by clicking here:
https://www.allpcb.com/
You can now upload the Gerber File by choosing the Quote Now option. From these options, you can choose the Material Type, Dimensions, Quantity, Thickness, Solder Mask Color and other required parameters.
After filling all details, select your country and shipping method. Finally you can place the order.
You can assemble the components on the PCB Board.
Setting up Thingspeak Server
In order to Monitor the
Electrical Conductivity (EC)
& Temperature data on Thingspeak Server, you first need to Setup the
Thingspeak
. To set up the Thingspeak Server, visit
https://thingspeak.com/
. Create an account or simply sign in if you created the account earlier. Then create a new channel with the following details.
Then go to the API section of the dashboard and copy the
API Key
. This API key is needed in the code part.
Source Code/Program
The source code/program for IoT Based Drinking Water Quality Monitoring with ESP32 is written in C/C++ on Arduino IDE. The code uses a lot of libraries in this project.
Some of the libraries for this project along with the download link are given below. First, download all these libraries and add them to the Arduino library folder.
1. OneWire Library
:
https://github.com/PaulStoffregen/OneWire
2. Dallas Temperature Library
:
https://github.com/milesburton/Arduino-Temperature-Control-Library
3. ADS1015 Library
:
https://github.com/adafruit/Adafruit_ADS1X15
(Install version 1.4)
4. DFRobot ESP EC Library
:
https://github.com/GreenPonik/DFRobot_ESP_EC_BY_GREENPONIK
5. Adafruit GFX Library
:
https://github.com/adafruit/Adafruit-GFX-Library
6. Adafruit SSD1306 Library
:
https://github.com/adafruit/Adafruit_SSD1306
The complete code for the project is given below. Before uploading the code to the ESP32 Board, you need to make some changes to the following lines.

String
apiKey
=
"****************"
;
// Enter your Write API key from ThingSpeak
const
char
*
ssid
=
"****************"
;
// replace with your wifi ssid and wpa2 key
const
char
*
pass
=
"****************"
;
Replace the Thingspeak API Key with the key that you copied earlier from the Thingspeak setup API tab. Then change the WiFi SSID & Password by replacing them with your local SSID & password.
Now you can upload the code to the ESP32 WiFi Module.

Technologies used

ESP32ESP8266ArduinoThingSpeakWiFiBLEDS18B20SSD1306OLEDI2CArduino IDEC++

Hardware components

  • ESP32
  • ESP8266
  • Arduino
  • DS18B20
  • SSD1306
  • OLED

Software & tools

  • Arduino IDE
  • ThingSpeak
  • EasyEDA

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.