You are on page 1of 40

IoT BASED pH AND TEMPARETURE MEASUREMENT SYSTEM

Submitted by
ID: 181311135
Name: Elias Kabir
Department of Computer Science and Engineering
Varendra University
Rajshahi, Bangladesh

Supervised by
Md. Toufikul Islam
Lecturer
Department of Computer Science and Engineering
Varendra University
Rajshahi, Bangladesh
IoT BASED pH AND TEMPARETURE MEASUREMENT SYSTEM

CERTIFICATE
A thesis submitted in partial fulfillment of the requirements of Varendra
University for the degree of BSc Engineering in CSE.

January 2022

Submitted by
ID: 181311135
Name: Elias Kabir
Department of Computer Science and Engineering
Varendra University
Rajshahi, Bangladesh

Supervised by
Md. Toufikul Islam
Lecturer
Department of Computer Science and Engineering
ACKNOWLEDGEMENT

I express great pleasure for me to express my gratitude to our honourable CHAIRMAN


Mr. Hafizur Rahman Khan, Varendra University Trust, for providing the opportunity and
platform with facilities in accomplishing the project-based labratory. I express the sincere
gratitude to our VICE CHANCELLOR Dr. M. Osman Gani Talukder, Varendra University
for his administration towards our academic growth.

I express sincere gratitude to our Head of the department CSE

Khademul Islam Molla for his leadership and constant motivation provided in
successful completion of our academic semester. We record it as our privilege to deeply
thank for providing us the efficient faculty and facilities to make our ideas into reality.

I express my sincere thanks to my project supervisor Md. Toufikul Islam for his
novel association of ideas, encouragement, appreciation and intellectual zeal which motivated
us to venture this project successfully.

I am pleased to acknowledge the indebtedness to our lab technicians who devoted


themselves directly or indirectly to make this project success.

Last but not the least I express my deep gratitude and affection to my parents who
stood behind us in all our endeavours.
Contents
Chapter 1:Abstract………………………………………….... 1

Chapter 2:Introduction…………………………… ………….2


2.1 Background 2
2.2 Internet of things (IoT) 3
2.3 Arduino 4
2.3.1 Reset Button 6
2.3.2 Power LED Indicator 7
2.3.3 TX RX LEDs 7
2.3.4 Main IC 7
2.3.5 Voltage Regulator 7
2.3.6 Arduino Uno (R3) 8
2.3.7 Red Board 8
2.3.8 Arduino Mega (R3) 9
2.3.9 Arduino Leonardo 9
2.3.10 The Extended Family 9
2.4 NodeMCU 10
2.4.1 NodeMCU Specifications 11

2.4.2 NodeMCU Compatibility with Arduino IDE 14

2.5 Sensor 15

2.5.1 Different Types of Sensors 15

2.5.2 Temperature Sensor 16


2.5.3 pH Sensors 17

2.5.3.1 pH Value 17

2.5.3.2 Analog pH Sensor Work 17

2.5.3.3 pH Electrode Construction 19

Chapter 3: Circuit diagram 20

Chapter 4: List of functions 21

4.1 pH Sensor Kit Interfacing with Arduino 22

4.2 Blynk App Water Quality Monitoring System 22

Chapter 5: Body of the Project 23

5.1 IoT water Quality Monitoring Programming 23

5.2 Arduino Programming 23

5.3 Code 24
Chapter 6: RESULTS…………………………………………….. 30
Chapter 7: Budget………………………………………………… 32
Chapter 8: FUTURE SCOPE…………………………………..... 33
Chapter 9: CONCLUSION………………………………………. 34
Chapter 10: References………………………………………… 35
List of Figures

Figure 2.4 NodeMCU 10

Figure 2.4.1 NodeMCU Specifications 12

Figure 2.4.2 NodeMCU Compatibility with Arduino IDE 14

Figure 2.5 Sensor 15

Figure 2.5.2 Temperature Sensor 16

Figure 2.5.3.1 pH Value 17

Figure 2.5.3.2 pH Signal Conversion Board 18

Figure 2.5.3.3 Pin Description 18

Figure 2.5.3.4 pH Electrode Construction 19

Figure 3.0 Circuit diagram 20

Figure 6.0 Results 30

Figure 6.1 Pure Water 31

Figure 6.2 Lemon Juice 31

List of Tables

Table 2.4 NodeMCU Specifications 11

Table 7.0 Budget 32


Abstract

This project uses IoT technology to make a note of every student entering into the classroom and
also to calculate the time resides in the class. In this proposed system, every student is allotted
with an IoT tag. The process of measurement can be done by placing the card near the IoT reader
and not only this, but we have introduced some more functions in this project.

The term IoT (Internet of Things) is one type of electronic device includes a small
wifi device and a chip. IoT (Internet of Things) is designed to serve as the Purpose of mobile
application. It creates a unique identifier for that object and just as a pH value or temperature
measure it.

This device is used to transmit the information like water quality, pH or temperature.
IoT tag using pH sensor, temperature fields. In this project, I have used IoT reader/sensor, IoT
tags, Arduino UNO board. This project will help any fish farmer to manage their farm.

1
Introduction

Water Quality Monitoring System–, we will learn how to make an IoT based water
quality
monitoring system using Arduino, pH Sensor, Temaperature Nodemcu esp8266 wifi
module and Blynk Application. As this is an IoT “Internet of Things” based project, the
water quality can be monitored from anywhere around the world. I will practically explain
how to measure the pH value of the Well water, and I will also explain whether the water
under test is good or bad for fish. We will also the Blynk application. This is Version2 of the
pH sensor Water Quality Monitoring System.

Background

On the hardware side, there are a number of products currently on the market that can
perform some of the requirements of this project. The esp8266 is the best example. The
esp8266 is a small microcontroller with a built-in wifi module. It is able to perform many of
projects functions, such as communicating with wired and wireless sensors, transmitting
information to an Android device via wifi, and storing data to an SD card. However, the
main problem with this solution, along with many others like it, is that the esp8266 must be
programmed to perform this operation. This makes the esp8266 an impossible solution for
users who don’t know how to program, and an impractical solution for those that can
program, but don’t want to. A better product would already have the code pre-compiled, the
input ports clearly labeled, and require little to no setup from the user. On the software side,
there are some Android apps that interface with certain microcontrollers. One example is
Blynk . This app communicates with an Arduino microcontroller via a wifi connection.
Using Blynk, users can read data coming from an Arduino board and esp8266, and configure
Arduino GPIO pins to function as either input or output. The main problem with this app is
that it does not perform the specific functions required, such as listing multiple Arduino port
outputs, saving data, and graphing data history.
To accomplish these tasks, an app should be designed from scratch with these functions in
mind. The sensor interface will ultimately work with smart phones, specifically Android
devices, which pride themselves on being sleek, stylish, and above all, open. The portability and
creative nature of the design needed to match the idea of the internet being in more and more
products. The bulk of our design was not our only convenience issue; required parts for the
microcontroller to interface with was created.

2
There will need to be many forms of inputting and outputting data via wired and wireless
connections. This data must be able to be stored until it is able to be buffered and sent to the
phone. Android devices. The Android device must be able to input the data from the
microcontroller and organize and display it in a way that is convenient for the user. Once it
has displayed this data it will then upload to a cloud form of storage to be further processed.
There are many other features that an optimal, but not realistically viable given our time
frame and other constraints. The internet of things, or IoT, is a system of interrelated
computing devices, mechanical and digital machines, objects, animals or people that are
provided with unique identifiers (UIDs) and the ability to transfer data over a network
without requiring human-to-human or human-to-computer interaction.
A thing in the internet of things can be a person with a heart monitor implant, a farm animal
with a biochip transponder, an automobile that has built-in sensors to alert the driver when
tire pressure is low or any other natural or man-made object that can be assigned an Internet
Protocol (IP) address and is able to transfer data over a network.
Increasingly, organizations in a variety of industries are using IoT to operate more efficiently,
better understand customers to deliver enhanced customer service, improve decision-making
and increase the value of the business.

Internet of things (IoT)

The Internet of Things (IoT) describes the network of physical objects—“things”—that are

embedded with sensors, software, and other technologies for the purpose of connecting and

exchanging data with other devices and systems over the internet. These devices range from

ordinary household objects to sophisticated industrial tools. With more than 7 billion

connected IoT devices today, experts are expecting this number to grow to 10 billion by 2020

and 22 billion by 2025. Oracle has a network of device partners.

3
ARDUINO:
It is an open-source platform used for building electronics projects. Arduino consists of both
a physical programmable circuit board (often referred to as a microcontroller) and a piece of
software, or IDE (Integrated Development Environment) that runs on your computer, used to
write and upload computer code to the physical board.

The Arduino platform has become quite popular with people just starting out with electronics,
and for good reason. Unlike most previous programmable circuit boards, the Arduino does not
need a separate piece of hardware (called a programmer) in order to load new code onto the board
- you can simply use a USB cable. Additionally, the Arduino IDE uses a simplified version of
C++, making it easier to learn to program. Finally, Arduino provides a standard form factor that
breaks out the functions of the micro-controller into a more accessible package.

The Arduino hardware and software was designed for artists, designers, hobbyists, hackers,
newbies, and anyone interested in creating interactive objects or environments. Arduino can
interact with buttons, LEDs, motors, speakers, GPS units, cameras, the internet, and even
your smartphone or your TV! This flexibility combined with the fact that the Arduino
software is free, the hardware boards are pretty cheap, and both the software and hardware
are easy to learn has led to a large community of users who have contributed code and
released instructions for a huge variety of Arduino-based projects.

For everything from robots and a heating pad hand warming blanket to honest fortune-telling
machines, and even a Dungeons and Dragons dice-throwing gauntlet, the Arduino can be
used as the brains behind almost any electronics project.

Every Arduino board needs a way to be connected to a power source. The Arduino UNO can
be powered from a USB cable coming from your computer or a wall power supply (like this)
that is terminated in a barrel jack. In the picture above the USB connection is labelled (1) and
the barrel jack is labelled (2).

The USB connection is also how you will load code onto your Arduino board. More on how
to program with Arduino can be found in our Installing and Programming Arduino tutorial.

4
Pins (5V, 3.3V, GND, Analog, Digital, PWM, AREF)

The pins on your Arduino are the places where you connect wires to construct a circuit (probably
in conjunction with a breadboard and some wire. They usually have black plastic ‘headers’ that
allow you to just plug a wire right into the board. The Arduino has several different kinds of pins,
each of which is labelled on the board and used for different functions.

● GND (3): Short for ‘Ground’. There are several GND pins on the Arduino, any
of which can be used to ground your circuit.
● 5V (4) & 3.3V (5): As you might guess, the 5V pin supplies 5 volts of power, and the
3.3V pin supplies 3.3 volts of power. Most of the simple components used with the
Arduino run happily off of 5 or 3.3 volts.
● Analog (6): The area of pins under the ‘Analog In’ label (A0 through A5 on the
UNO) are Analog In pins. These pins can read the signal from an analog sensor (like a
temperature sensor) and convert it into a digital value that we can read.
● Digital (7): Across from the analog pins are the digital pins (0 through 13 on the
UNO). These pins can be used for both digital input (like telling if a button is pushed)
and digital output (like powering an LED).
● PWM (8): You may have noticed the tilde (~) next to some of the digital pins (3, 5, 6,
9, 10, and 11 on the UNO). These pins act as normal digital pins but can also be used
for something called Pulse-Width Modulation (PWM). We have a tutorial on PWM,
but for now, think of these pins as being able to simulate analog output (like fading an
LED in and out).
● AREF (9): Stands for Analog Reference. Most of the time you can leave this pin
alone. It is sometimes used to set an external reference voltage (between 0 and 5
Volts) as the upper limit for the analog input pins.

Reset Button

Just like the original Nintendo, the Arduino has a reset button (10). Pushing it will temporarily
connect the reset pin to ground and restart any code that is loaded on the Arduino. This can be
very useful if your code doesn’t repeat, but you want to test it multiple times. Unlike the
original Nintendo however, blowing on the Arduino doesn't usually fix any problems.

6
Power LED Indicator

Just beneath and to the right of the word “UNO” on your circuit board, there’s a tiny LED
next to the word ‘ON’ (11). This LED should light up whenever you plug your Arduino into a
power source. If this light doesn’t turn on, there’s a good chance something is wrong. Time to
re-check your circuit!

TX RX LEDs

TX is short for transmit; RX is short for receive. These markings appear quite a bit in
electronics to indicate the pins responsible for serial communication. In our case, there are
two places on the Arduino UNO where TX and RX appear -- once by digital pins 0 and 1,
and a second time next to the TX and RX indicator LEDs (12). These LEDs will give us
some nice visual indications whenever our Arduino is receiving or transmitting data (like
when we’re loading a new program onto the board).

Main IC

The black thing with all the metal legs is an IC, or Integrated Circuit (13). Think of it as the
brains of our Arduino. The main IC on the Arduino is slightly different from board type to
board type but is usually from the AT mega line of IC’s from the ATMEL
company. This can be important, as you may need to know the IC type (along with
your board type) before loading up a new program from the Arduino software. This
information can usually be found in writing on the top side of the IC. If you want
to know more about the difference between various IC's, reading the datasheets is
often a good idea.

Voltage Regulator

The voltage regulator (14) is not actually something you can (or should) interact with on the
Arduino. But it is potentially useful to know that it is there and what it’s for. The voltage

7
regulator does exactly what it says -- it controls the amount of voltage that is let into the
Arduino board. Think of it as a kind of gatekeeper; it will turn away an extra voltage that
might harm the circuit. Of course, it has its limits, so don’t hook up your Arduino to anything
greater than 20 volts.

The Arduino Family

Arduino makes several different boards, each with different capabilities. In addition, part of
being open source hardware means that others can modify and produce derivatives of
Arduino boards that provide even more form factors and functionality. If you’re not sure
which one is right for your project.

Arduino Uno (R3)

The Uno is a great choice for your first Arduino. It's got everything you need to get started,
and nothing you don't. It has 14 digital input/output pins (of which 6 can be used as PWM
outputs), 6 analog inputs, a USB connection, a power jack, a reset button and more. It
contains everything needed to support the microcontroller; simply connect it to a computer
with a USB cable or power it with a AC-to-DC adapter or battery to get started.

This is Lilypad Arduino main board! Lilypad is a wearable e-textile technology developed
by Leah Buechley and cooperatively designed by Leah and Spark Fun. Each Lilypad was
creatively designed with large connecting pads and a flat back to allow them to be sewn into
clothing with conductive thread. The Lilypad also has its own family of input, output, power,
and sensor boards that are also built specifically for e-textiles. They're even washable!

Red Board

At Spark Fun we use many Arduinos and we're always looking for the simplest, most stable
one. Each board is a bit different and no one board has everything we want -- so we decided
to make our own version that combines all our favourite features.

The Red Board can be programmed over a USB Mini-B cable using the Arduino IDE. It'll work
on Windows 8 without having to change your security settings (we used signed drivers, unlike the
UNO). It's more stable due to the USB/FTDI chip we used, plus it's completely flat on the back,
making it easier to embed in your projects. Just plug in the board, select "Arduino UNO"

8
from the board menu and you're ready to upload code. You can power the Red Board over
USB or through the barrel jack. The on-board power regulator can handle anything from 7 to
15VDC.

Arduino Mega (R3)

The Arduino Mega is like the UNO's big brother. It has lots (54!) of digital input/output pins
(14 can be used as PWM outputs), 16 analog inputs, a USB connection, a power jack, and a
reset button. It contains everything needed to support the microcontroller; simply connect it
to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started.
The large number of pins make this board very handy for projects that require a bunch of
digital inputs or outputs (like lots of LEDs or buttons).

Arduino Leonardo

The Leonardo is Arduino's first development board to use one microcontroller with built-in
USB. This means that it can be cheaper and simpler. Also, because the board is handling
USB directly, code libraries are available which allow the board to emulate a computer
keyboard, mouse, and more!

The Extended Family

While your Arduino board sure is pretty, it can't do a whole lot on its own -- you've got to
hook it up to something. There are lots of tutorials here on learn as well as the links back in
the 'What does it do' section, but rarely do we talk about the general kinds of things you can
easily hook into. In this section we'll introduce basic sensors as well as Arduino shields, two
of the handiest tools to use in bringing your projects to life.

9
NodeMCU:

The NodeMCU (Node MicroController Unit) is an open-source software and hardware


development environment built around an inexpensive System-on-a-Chip (SoC) called the
ESP8266. The ESP8266, designed and manufactured by Espressif Systems, contains the
crucial elements of a computer: CPU, RAM, networking (WiFi), and even a modern
operating system and SDK. That makes it an excellent choice for Internet of Things (IoT)
projects of all kinds.

However, as a chip, the ESP8266 is also hard to access and use. You must solder wires, with
the appropriate analog voltage, to its pins for the simplest tasks such as powering it on or
sending a keystroke to the “computer” on the chip. You also have to program it in low-level
machine instructions that can be interpreted by the chip hardware. This level of integration is
not a problem using the ESP8266 as an embedded controller chip in mass-produced
electronics. It is a huge burden for hobbyists, hackers, or students who want to experiment
with it in their own IoT projects.

But, what about Arduino? The Arduino project created an open-source hardware design and
software SDK for their versatile IoT controller. Similar to NodeMCU, the Arduino hardware
is a microcontroller board with a USB connector, LED lights, and standard data pins. It also
defines standard interfaces to interact with sensors or other boards. But unlike NodeMCU, the
Arduino board can have different types of CPU chips (typically an ARM or Intel x86 chip)
with memory chips, and a variety of programming environments. There is an Arduino
reference design for the ESP8266 chip as well. However, the flexibility of Arduino also
means significant variations across different vendors. For example, most Arduino boards do
not have WiFi capabilities, and some even have a serial data port instead of a USB port.

10
NodeMCU Specifications
The NodeMCU is available in various package styles. Common to all the designs is the base
ESP8266 core. Designs based on the architecture have maintained the standard 30-pin layout.
Some designs use the more common narrow (0.9″) footprint, while others use a wide (1.1″)
footprint – an important consideration to be aware of.

The most common models of the NodeMCU are the Amica (based on the standard narrow
pin-spacing) and the LoLin which has the wider pin spacing and larger board. The open-
source design of the base ESP8266 enables the market to design new variants of the
NodeMCU continually.

xiv

11
Power Pins There are four power pins. VIN pin and three 3.3V pins.

VIN can be used to directly supply the NodeMCU/ESP8266 and its peripherals. Power
delivered on VIN is regulated through the onboard regulator on the NodeMCU module –
you can also supply 5V regulated to the VIN pin

3.3V pins are the output of the onboard voltage regulator and can be used to supply power
to external components.

GND are the ground pins of NodeMCU/ESP8266

I2C Pins are used to connect I2C sensors and peripherals. Both I2C Master and I2C Slave
are supported. I2C interface functionality can be realized programmatically, and the clock
frequency is 100 kHz at a maximum. It should be noted that I2C clock frequency should
be higher than the slowest clock frequency of the slave device.

GPIO Pins NodeMCU/ESP8266 has 17 GPIO pins which can be assigned to functions
such as I2C, I2S, UART, PWM, IR Remote Control, LED Light and Button
programmatically. Each digital enabled GPIO can be configured to internal pull-up or
pull-down, or set to high impedance. When configured as an input, it can also be set to
edge-trigger or level-trigger to generate CPU interrupts.

12
ADC Channel The NodeMCU is embedded with a 10-bit precision SAR ADC. The two
functions can be implemented using ADC. Testing power supply voltage of VDD3P3 pin
and testing input voltage of TOUT pin. However, they cannot be implemented at the same
time.

UART Pins NodeMCU/ESP8266 has 2 UART interfaces (UART0 and UART1) which
provide asynchronous communication (RS232 and RS485), and can communicate at up to
4.5 Mbps. UART0 (TXD0, RXD0, RST0 & CTS0 pins) can be used for communication.
However, UART1 (TXD1 pin) features only data transmit signal so, it is usually used for
printing log.

SPI Pins NodeMCU/ESP8266 features two SPIs (SPI and HSPI) in slave and
master modes. These SPIs also support the following general-purpose SPI features:

4 timing modes of the SPI format transfer

Up to 80 MHz and the divided clocks of 80 MHz

SDIO Pins NodeMCU/ESP8266 features Secure Digital Input/Output Interface (SDIO)


which is used to directly interface SD cards. 4-bit 25 MHz SDIO v1.1 and 4-bit 50 MHz
SDIO v2.0 are supported.

PWM Pins The board has 4 channels of Pulse Width Modulation (PWM). The PWM
output can be implemented programmatically and used for driving digital motors and
LEDs. PWM frequency range is adjustable from 1000 μs to 10000 μs (100 Hz and 1
kHz).

Control Pins are used to control the NodeMCU/ESP8266. These pins include Chip Enable
pin (EN), Reset pin (RST) and WAKE pin.

EN: The ESP8266 chip is enabled when EN pin is pulled HIGH. When pulled LOW the
chip works at minimum power.

RST: RST pin is used to reset the ESP8266 chip.

WAKE: Wake pin is used to wake the chip from deep-sleep.

13
Control Pins are used to control the NodeMCU/ESP8266. These pins include Chip
Enable pin (EN), Reset pin (RST) and WAKE pin.

EN: The ESP8266 chip is enabled when EN pin is pulled HIGH. When pulled LOW the
chip works at minimum power.

RST: RST pin is used to reset the ESP8266 chip.

WAKE: Wake pin is used to wake the chip from deep-sleep.

NodeMCU Compatibility with Arduino IDE:

The NodeMCU offers a variety of development environments, including compatibility with


the Arduino IDE (Integrated Development Environment). The NodeMCU/ESP8266
community took the IDE selection a step further by creating an Arduino add-on. If you’re
just getting started programming the ESP8266 or even an established developer, this is the
highly recommended environment. Visit our dedicated page on setting up and configuring the
Arduino IDE for a NodeMCU ESP8266.

14
Sensor:
There are numerous definitions as to what a sensor is but I would like to define a Sensor as an
input device which provides an output (signal) with respect to a specific physical quantity
(input). The term “input device” in the definition of a Sensor means that it is part of a bigger
system which provides input to a main control system (like a Processor or a
Microcontroller).Another unique definition of a Sensor is as follows: It is a device that
converts signals from one energy domain to electrical domain. The definition of the Sensor
can be better understood if we take an example in to consideration.

Different Types of Sensors


The following is a list of different types of sensors that are commonly used in various
applications. All these sensors are used for measuring one of the physical properties like
Temperature, Resistance, Capacitance, Conduction, Heat Transfer etc.

1. Temperature Sensor
2. pH Sensor
3. Accelerometer
4. IR Sensor (Infrared Sensor)
5. Pressure Sensor
6. Light Sensor
7. Ultrasonic Sensor
8. Smoke, Gas and Alcohol Sensor
9. Touch Sensor
10. Color Sensor
11. Humidity Sensor
12. Position Sensor
13. Magnetic Sensor (Hall Effect Sensor)
14. Microphone (Sound Sensor)
15. Tilt Sensor
16. Flow and Level Sensor
17. PIR Sensor
18. Touch Sensor
19. Strain and Weight Sen

15
We will see about few of the above-mentioned sensors in brief.

Temperature Sensor:
One of the most common and most popular sensors is the Temperature Sensor. A
Temperature Sensor, as the name suggests, senses the temperature i.e., it measures
the changes in the temperature.

There are different types of Temperature Sensors like Temperature Sensor ICs (like LM35,
DS18B20), Thermistors, Thermocouples, RTD (Resistive Temperature Devices), etc.

Temperature Sensors can be analog or digital. In an Analog Temperature Sensor, the changes
in the Temperature correspond to change in its physical property like resistance or voltage.
LM35 is a classic Analog Temperature Sensor.

Coming to the Digital Temperature Sensor, the output is a discrete digital value (usually,
some numerical data after converting analog value to digital value). DS18B20 is a simple
Digital Temperature Sensor.

Temperature Sensors are used everywhere like computers, mobile phones, automobiles, air
conditioning systems, industries etc. A simple project using LM35 (Celsius Scale
Temperature Sensor) is implemented in this project: TEMPERATURE CONTROLLED
SYSTEM.

16
pH Sensors:

A pH sensor is one of the most essential tools that’s typically used for water measurements.
This type of sensor is able to measure the amount of alkalinity and acidity in water and
other solutions. When used correctly, pH sensors are able to ensure the safety and quality of
a product and the processes that occur within a wastewater.

pH scale is used to measure the acidity and basicity of a liquid. It can have readings ranging
from 1-14 where 1 shows the most acidic liquid and 14 shows the most basic liquid. 7 pH is
for neutral substances that are neither acidic nor basic.

pH Value
The unit that we use to measure the acidity of a substance is called pH. The term “H” is
defined as the negative log of the hydrogen ion concentration. The range of pH can have
values from 0 to 14. A pH value of 7 is neutral, as pure water has a pH value of exactly
7. Values lower than 7 are acidic and values greater than 7 are basic or alkaline.

xv
i

How Does Gravity Analog pH Sensor Work?


Analog pH sensor is designed to measure the pH value of a solution and show the acidity or
alkalinity of the substance. It is commonly used in various applications such as agriculture,
wastewater treatment, industries, environmental monitoring, etc. The module has an on-board
voltage regulator chip which supports the wide voltage supply of 3.3-5.5V DC, which is
compatible with 5V and 3.3V of any control board like Arduino. The output signal is being
filtered by hardware low jitter.

17
Technical Features:

Signal Conversion Module:

 Supply Voltage: 3.3~5.5V


 BNC Probe Connector
 High Accuracy: ±0.1@25°C
 Detection Range: 0~14
PH electrode:

 Operating Temperature Range: 5~60°C


 Zero (Neutral) Point: 7±0.5
 Easy calibration
 Internal Resistance: <250MΩ

pH Signal Conversion Board:

Pin Description:

V+: 5V DC input G: Ground pin

Po: pH analog output Do: 3.3V DC output

To: Temperature output

18
pH Electrode Construction:

The construction of a pH sensor is shown above. The pH Sensor looks like a rod usually
made of a glass material having a tip called “Glass membrane”.
This membrane is filled with a buffer solution of known pH (typically pH = 7). This electrode
design ensures an environment with the constant binding of H+ ions on the inside of the glass
membrane.
When the probe is dipped into the solution to be tested, hydrogen ions in the test solution start
exchanging with other positively charged ions on
the glass membrane, which creates an electrochemical potential across the membrane which
is fed to the electronic amplifier module which measures the potential between both
electrodes and converts it to pH units.
The difference between these potentials determines the pH value based on the Nernst
equation.

19
Circuit diagram:
CIRCUIT DIAGRAM

List of Functions

20
xviii
List of functions:
List of functions

1. Serial.begin(): Sets the data rate in bits per second (baud) for serial data transmission.
For communicating with Serial Monitor, make sure to use one of the baud rates listed
in the menu at the bottom right corner of its screen. You can, however, specify other
rates - for example, to communicate over pins 0 and 1 with a component that requires
a particular baud rate.

2. digitalRead(): Reads the value from a specified digital pin, either HIGH or LOW. If the

pin isn’t connected to anything, digitalRead () can return either HIGH or LOW .

The analog input pins can be used as digital pins, referred to as A0,A1,etc. The
exception is the Arduino Nano , Pro MINI, and Mini’s A6 and A7 pins, which can
only be used as analog inputs.

3. digitalWrite(): Write a HIGH or a LOW value to a digital pin. If the pin has been
configured as an OUTPUT with pinMode(), its voltage will be set to the
corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.
If the pin is configured as an INPUT, digitalWrite() will enable (HIGH) or disable
(LOW) the internal pullup on the input pin. It is recommended to set the pinMode() to
INPUT_PULLUP to enable the internal pull-up resistor. See the Digital Pins tutorial
for more information.

4. Serial.println(): Prints data to the serial port as human-readable ASCII text followed
by a carriage return character (ASCII 13, or '\r') and a newline character (ASCII 10, or
'\n'). This command takes the same forms as Serial.println().

5. Blynk.virtualWrite(pin, value): Virtual Pins are commonly used to interface with


other libraries (Servo, LCD and others) and implement custom logic. The device can
send data to the App using Blynk.virtualWrite(pin, value) and receive data from the
App using BLYNK_WRITE(vPIN).

21
pH Sensor Kit Interfacing with Arduino:

 For the step by step, interface connections watch the video Tutorial given at the end of
this Article.

 Connect the red wire with the Arduino’s 5v…

 Connect the black wire with the Arduino’s Ground…

 Connect the blue wire with the Arduino’s Analog pin A0.

 Connect the TX and RX Pins of the Nodemcu ESP8266 wifi module with Pin
number2 and Pin number3 of the Arduino.

 Connect Ground Pin of the Nodemcu module with the Arduino’s ground.

Blynk Application for the Water Quality Monitoring System:


 First of all, open the Blynk application.

 set the project name as pH meter.

 Click on the Choose device and select Nodemcu.

 Make sure you set the connection type to wifi and then click on the create button, an
authentication token will be sent on your email id, which will be then used in the
programming, simply copy and paste it in programming.
 Now click on the screen and search for the LCD widget and add it.

 Now Click on the LCD, Select Advanced.

 Click on the Pin and select Virtual Pin V2.

22
Body of the Project
IoT water Quality Monitoring Programming:
In this project two Programs are used, one program is written for the Arduino while the other
Program is written for the Nodemcu ESP8266 wifi module. Let’s first of all start with the
Arduino Programming.

Arduino Programming for the Water Quality Monitoring System:

This is the same Program I used in Version1 of the pH sensor water quality monitoring
system. This time I made a few changes, I added these two libraries. The stdlib.h library has a
standard function which is used for converting the float value into the String, while the \
softwareserial.h library is used for creating multiple Serial Ports. As I always say never use
the Arduino’s default serial port for communication with other devices. As you know in
Arduino we have only one Serial port which is on pin number 0 and pin number 1. The
Arduino’s default Serial Port should only be used for debugging purposes.
Now the question is if we are using the Arduino’s default Serial port for the debugging
purposes then how we will connect the Nodemcu Module with the Arduino? Well, no worries
at all we can use the software serial library for creating multiple Serial Ports. So that’s the
reason I added the software serial library and defined a Serial Port with the name Nodemcu
on Pin number 2 and Pin number 3. So the Nodemcu module TX and RX Pins will be
connected with the Arduino’s Pin number 2 and Pin number 3…

Another change that I made to the program is I added this function which is used to convert a
float value into the String value. Then I added this String value along with the comma which
is used as the delimiter. Finally, the String message is sent to the Nodemcu module and at the
end, we empty the String for the new day.

23
CODE:

#include <stdlib.h>

#include <SoftwareSerial.h>

SoftwareSerial nodemcu(2,3);

#define SensorPin 0 //pH meter Analog output to Arduino Analog Input 0

unsigned long int avgValue; //Store the average value of the sensor feedback

float b;

int buf[10],temp;

/ for float value to string converstion

int f;

float val; // also works with double.

char buff2[10];

String valueString =

""; String Value = "";

void setup()

{ pinMode(13,OUTPUT);

Serial.begin(9600);

nodemcu.begin(9600);

}void loop(){ for(int

i=0;i<10;i++) //Get 10 sample value from the sensor for smooth the value
24
{ buf[i]=analogRead(SensorPin);

delay(10); }

for(int i=0;i<9;i++) //sort the analog from small to large

for(int j=i+1;j<10;j++)

{ if(buf[i]>buf[j])

{ temp=buf[i];

buf[i]=buf[j];

buf[j]=temp;

} }}

avgValue=0;

for(int i=2;i<8;i++) //take the average value of 6 center sample


avgValue+=buf[i];

float phValue=(float)avgValue*5.0/1024/6; //convert the analog into millivolt

phValue=3.5*phValue; //convert the millivolt into pH value Value =

dtostrf(phValue, 4, 2, buff2); //4 is mininum width, 6 is precision

valueString = valueString + Value +",";

Serial.println(valueString);

nodemcu.println(valueString);

valueString = "";

delay(1000);}

25
Nodemcu Programming for the Water Quality Monitoring
System

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

#include <SoftwareSerial.h>

#include <SimpleTimer.h>

WidgetLCD lcd(V2);

String data;

String I;

char auth[] = "1748acab0e3c4c7baca832f4a9d9e3fb";

/ Your WiFi credentials.

/ Set password to "" for open networks.

char ssid[] = "khan";

char pass[] = "kabir.01717";

SimpleTimer timer;

String myString; // complete message from arduino, which consistors of snesors data

char rdata; // received charactors

/ This function sends Arduino's up time every second to Virtual Pin (1).

/ In the app, Widget's reading frequency should be set to PUSH. This means

26
/ that you define how often to send data to Blynk App.

void myTimerEvent()

/ You can send any value at any time.

/ Please don't send more that 10 values per second.

Blynk.virtualWrite(V1, millis() / 1000);

void setup()

/ Debug console

Serial.begin(9600);

Blynk.begin(auth, ssid, pass);

timer.setInterval(1000L,sensorvalue1);

void loop()

if (Serial.available() == 0 )

Blynk.run();

timer.run(); // Initiates BlynkTimer

27
if (Serial.available() > 0 )

rdata = Serial.read();

myString = myString+ rdata;

Serial.print(rdata);

if( rdata == '\n')

I = getValue(myString, ',', 0);

myString = "";

/ Serial.println(I);

lcd.print(0,0,"pH Value:");

void sensorvalue1()

data = data + I;

lcd.print(0,0,"pH Value:");

lcd.print(0,1,data);

data = "";

28
String getValue(String data, char separator, int index)

int found = 0;

int strIndex[] = { 0, -1 };

int maxIndex = data.length() - 1;

for (int i = 0; i <= maxIndex && found <= index; i++) {

if (data.charAt(i) == separator || i == maxIndex) {

found++;

strIndex[0] = strIndex[1] + 1;

strIndex[1] = (i == maxIndex) ? i+1 : i;

return found > index ? data.substring(strIndex[0], strIndex[1]) : "";

29
RESULTS:
The pH of pure water is 7. In general water with a pH lower than 7 is considered acidic,
and with a pH greater than 7 is considered basic.
The normal range for pH in surface water systems is 6.5 to 8.5, and the pH range for
groundwater systems is between 6 to 8.5.
Waters taken from underground sources and not treated or modified in any way will have
a pH between 7.2 and 7.8,
which is the ideal range for good health.

xxvi

30
PURE WATER

LEMON JUICE

xxvii

31
Budget:
The team was provided with the standard budget of 4500 taka for the project.
The budget summary table of purchased expenditures is shown below:

Cost(Tk) Sensor
Hardware Cost(Tk)
Arduino 750 pH Sensor
2500
Temperature
Esp8266 350 sensor 100

Breadboard 100

Wires 90

Battery 60

Total= 1350 Total= 2600

32
FUTURE SCOPE

Currently, the project lacks a full integrated backend to make it function out of the box
without preconfiguration. The Android application itself requires more development/testing to
ensure that the end user can intuitively and without fail use the interface. To achieve the out of
box performance, the process of being able to connect to any sensor interface device without
large amounts user interaction is required, meaning configuring and saving wifi connection to a
Sensor Interface device. Once data can be reliably sent to and logged on the phone, the ability to
view data graphically can be implemented. Furthermore, the timestamp needs to be integrated
into the system as well for being able to know the date and time of the data recorded.
In terms of the microcontroller software, more sensors should be tested to show true
compatibility, and Bluetooth 4.0 needs to be fully implemented for lower power consumption,
updating from the use of the current HC-05 Nodemcu esp8266 module. Code for the
microcontroller should be reviewed/revised to achieve optimal performance and utilize the
available resources as best as possible. Additions to the microcontroller for entering separate
modes such as sleep, configuration, and communication modes need to be programmed in. A
sensor application protocol should be further developed for communicating the sensor data
necessary identifying processing the sensor data for easier use.

Switching to the Sensor Interface hardware, the printed circuit board should be redesigned to
use the surface components necessary in order to produce at the minimal size possible. Without a
fully developed printed circuit board, power consumption of the device could not be measured
which is necessary to decide on the battery that would be required. Lack of a printed circuit
board with surface mount components also makes knowing the optimized board size difficult.
Though it’s arbitrary, choosing a connection method to connect sensors to the Sensor Interface in
an efficient and expandable manner needs to be developed. Other than fixing small errors that
may result in the initial production phases, different wireless modules for communicating with
sensors could be implemented in future versions of the product. Beyond these minor setbacks,
the foundation created by the team will lead the Sensor Interface towards success.

33
CONCLUSION:
This project involves the design of attendance system using esp8266 and Blynk android app.
This project also help us learn and implement more on the Arduino software. And mainly
help to our fish farmer.
During the course , a successful prototype for the Sensor Technology Interface, as
well as designs for both the final printed circuit board and the server-side supported backend
library, has been completed. The prototype consisted of devices running versions 9.0 and
11.0 of the Android mobile operating system, the Arduino Uno microcontroller, as well as
various sensors. A wide range of sensors were tested, including analog and digital sensors
both wired and wireless, as well as sensors using different protocols. However, the final
prototype will showcase a digital temperature and humidity sensor, as well as analog light
and water level sensors, as well as a potentiometer to sense angle.

34
References:
● "RFduino - Home." RFduino - Home. N.p., n.d. Web.
21 Feb. 2014. <http://www.rfduino.com/>.

● "ArduDroid: Simple Bluetooth control for Arduino and Android - TechBitar"


ArduDroid. N.p., n.d. Web. 21 Feb. 2014.
<http://www.techbitar.com/ardudroid-simple-bluetooth-control-for-
arduino-and-android.html>.

● "Arduino - Serial." Arduino - Serial. N.p., n.d. Web.


22 Apr. 2014. <http://arduino.cc/en/reference/serial>.

● "Arduino - SPI." Arduino - SPI. N.p., n.d. Web. 22 Apr. 2014.


<http://arduino.cc/en/Reference/SPI>.

3. "Arduino - Wire." Arduino - Wire. N.p., n.d. Web.


22 Apr. 2014. <http://arduino.cc/en/reference/wire>.

4. "Bluetooth." Android Developers. N.p., n.d. Web. 22 Apr. 2014.


<http://developer.android.com/guide/topics/connectivity/bluetooth.html>.

5. Blynk Android application


<https://examples.blynk.cc/?board=ESP8266&shield=ESP8266%20WiFi&example=More%2F
DHT11>
6. NodeMcu esp8266
< https://www.esp8266.com/>

35

You might also like