Download as pdf or txt
Download as pdf or txt
You are on page 1of 44

IOT DEVICE FOR SEWAGE GAS MONITORING AND ALERT

SYSTEM
Project Report Submitted in Partial fulfillment of the degree of the

MASTER OF TECHNOLOGY

IN
EMBEDDED SYSTEMS
By

NAZIYA THAHMEEN - 20C41D5507


Under the esteemed guidance of
Mr. HAMEED PASHA MOHAMMED
Associate Professor
&
Head Dept of ECE

Department of Electronics & Communication Engineering

JAYAMUKHI INSTITUTE OF TECHNOLOGICAL SCIENCES


(UGC-AUTONOMOUS, Affiliated to JNTUH, Accredited by NAAC)
NARSAMPET, WARANGAL-506 332
JAYAMUKHI INSTITUTE OF TECHNOLOGICAL
SCIENCES
(UGC-AUTONOMOUS, Affiliated to JNTUH, Accredited by NAAC)
NARSAMPET, WARANGAL-506 332

CERTIFICATE

This is to certify that the Technical Seminar Report entitled “ Iot Device For
Sewage Gas Monitoring And Alert System ” is submitted by Naziya
Thahmeen bearing Roll No : 20C41D5507 in Master of Technology in
Embedded Systems.

Guide Head of Department

Principal
ACKNOWLEDGEMENT

I write this acknowledgement with great honor, pride and pleasure to pay my gratitude to
all who enabled me either directly in reaching this stage.
I express my immense gratitude and sincere thanks to Dr.V. JANAKI Principal of
Jayamukhi Institute of Technological Sciences, Narsampet, and Warangal for their
support and kind co-operation.
I express my gratitude and sincere thanks to Mr.MD. HAMEED PASHA, Dean
Academics & Head of The Department of Electronics and Communication Engineering,
Jayamukhi Institute of Technological Sciences, Narsampet, Warangal for his constant
motivation and support.
I am grateful to my graduate and sincere thanks to Mr. MD. HAMEED PASHA
Associate Professor for his valuable guidance and giving me the opportunity to do my work
in a better manner.
Last but not least I wish to thank my parents and friends, for their understanding and
cooperation without those encouragement and blessings it would not have been possible to
complete this work.

By
Naziya Thahmeen - 20C41D5507
DECLARATION
I do here by declare that the Technical seminar report titled by “ Iot Device For
Sewage Gas Monitoring And Alert System” submitted by me to the Jayamukhi
Institute of Technological Sciences in a partial fulfillment of the requirement for the
award of Master of Technology in Embedded Systems is my original work. The
analysis, design and implementation of this project is done by me, and it has not submitted
anywhere else for the award of degree.

By
Naziya Thahmeen - 20C41D5507
ABSTRACT
This project aims at providing smart solutions to monitor poisonous sewage gases and
works on a system of live sewage level detection and monitoring. Whenever, a certain
threshold is crossed, an alert is sent to the observer who is examining the conditions from
a remote location. The information is then forwarded along with different gas ppm values
indicating whether it is safe for the worker to clean or work in that environment or not.
The remotely placed IoT monitoring equipment and IoT platform are integrated to create
proposed system. This requires calibration of gas sensors for industrial purposes and
determining the correct threshold levels for septic plants and facilities. The hardware is
designed such that it shall send a prior alert to the sewage worker to ensure their safety,
if damaging gaseous constituents increase in concentration over time. Various types of
sensors are utilized to monitor parameters present in sewage like gas, temperature etc.
When the threshold value is lesser than the sensed values, this system alerts the sewage
worker/cleaner by sending SMS and call alerts by analyzing concentrations of different
toxic gases and graphing out their results for real-time monitoring thereby aiding in
protection from hazardous diseases and hence serves a social cause as well. In the
proposed system, sample values for sensors have been recorded and plotted on
ThingSpeak analysis tool. Carbon monoxide and methane sensors charted values up-to
2.3 and 60 ppm respectively, and this breached threshold and WIFI module was utilized
for sending alert to mobile number fed in the code.
Table of Contents
CHAPTER-1 ........................................................................................................................................ 7
1.1 INTRODUCTION TO EMBEDDED SYSTEM .................................................................................. 7
1.2 APPLICATIONS OF EMBEDDED SYSTEM .................................................................................... 8
1.3 MICROCONTROLLERS FOR EMBEDDED SYSTEMS ...................................................................... 9
CHAPTER-2 ...................................................................................................................................... 10
2.1 INTRODUCTION ..................................................................................................................... 10
2.2 LITERATURE REVIEW .............................................................................................................. 11
2.3 PROPOSED METHOD: ............................................................................................................. 12
2.4 BLOCK DIAGRAM ................................................................................................................... 13
CHAPTER 3 ...................................................................................................................................... 14
HARDWARE COMPONENTS.......................................................................................................... 14
3.1 Microcontroller (ATMEGA16) ............................................................................................. 14
3.2 Serial Communication ........................................................................................................ 20
3.3 MQ4 Gas sensor ................................................................................................................. 20
3.4 MQ7 Carbon Monoxide sensor........................................................................................... 21
3.5 ESP 8266-01 WiFi Module .................................................................................................. 22
3.6 Regulated Power Supply .................................................................................................... 29
CHAPTER 4 ...................................................................................................................................... 31
4.1 ARDUINO IDE TOOL................................................................................................................ 31
CHAPTER-5 ...................................................................................................................................... 33
5.1 INTERNET OF THINGS ............................................................................................................. 33
5.2 What is ThingSpeak ................................................................................................................ 34
5.3 Getting Started ...................................................................................................................... 34
5.4 ThingSpeak Apps .................................................................................................................... 41
CHAPTER-6 ...................................................................................................................................... 43
6.1 SCHEMATIC DIAGRAM ........................................................................................................... 43
6.2 CONCLUSION ......................................................................................................................... 44
CHAPTER-1

1.1 INTRODUCTION TO EMBEDDED SYSTEM


An embedded system is a special-purpose computer system designed to perform one or
a few dedicated functions, sometimes with real-time computing constraints. It is usually
embedded as part of a complete device including hardware and mechanical parts. In contrast,
a general-purpose computer, such as a personal computer, can do many different tasks
depending on programming. Embedded systems have become very important today as they
control many of the common devices we use. Since the embedded system is dedicated to
specific tasks, design engineers can optimize it, reducing the size and cost of the product, or
increasing the reliability and performance. Some embedded systems are mass-produced,
benefiting from economies of scale.

Physically embedded systems range from portable devices such as digital watches and
MP3 players, to large stationary installations like traffic lights, factory controllers, or the
systems controlling nuclear power plants. In general, "embedded system" is not an exactly
defined term, as many systems have some element of programmability. For example, Handheld
computers share some elements with embedded systems — such as the operating systems and
microprocessors which power them — but are not truly embedded systems, because they allow
different applications to be loaded and peripherals to be connected.

An embedded system is some combination of computer hardware and software, either


fixed in capability or programmable, that is specifically designed for a particular kind of
application device. Industrial machines, automobiles, medical equipment, cameras, household
appliances, airplanes, vending machines, and toys (as well as the more obvious cellular phone
and PDA) are among the myriad possible hosts of an embedded system. Embedded systems
that are programmable are provided with a programming interface, and embedded systems
programming is a specialized occupation.

Certain operating systems or language platforms are tailored for the embedded market,
such as Embedded Java and Windows XP Embedded. However, some low-end consumer
products use very inexpensive microprocessors and limited storage, with the application and
operating system both part of a single program. The program is written permanently into the
system's memory in this case, rather than being loaded into RAM (random access memory), as
programs on a personal computer.

1.2 APPLICATIONS OF EMBEDDED SYSTEM


We are living in the Embedded World. You are surrounded with many embedded
products and your daily life largely depends on the proper functioning of these gadgets.
Television, Radio, CD player of your living room, Washing Machine or Microwave Oven in
your kitchen, Card readers, Access Controllers, Palm devices of your work space enable you
to do many of your tasks very effectively. Apart from all these, many controllers embedded in
your car take care of car operations between the bumpers and most of the times you tend to
ignore all these controllers.

In recent days, you are showered with variety of information about these embedded
controllers in many places. All kinds of magazines and journals regularly dish out details about
latest technologies, new devices; fast applications which make you believe that your basic
survival is controlled by these embedded products. Now you can agree to the fact that these
embedded products have successfully invaded into our world. You must be wondering about
these embedded controllers or systems.

The computer you use to compose your mails, or create a document or analyze the
database is known as the standard desktop computer. These desktop computers are
manufactured to serve many purposes and applications.

You need to install the relevant software to get the required processing facility. So,
these desktop computers can do many things. In contrast, embedded controllers carryout a
specific work for which they are designed. Most of the time, engineers design these embedded
controllers with a specific goal in mind. So these controllers cannot be used in any other place.

Theoretically, an embedded controller is a combination of a piece of microprocessor


based hardware and the suitable software to undertake a specific task.

These days designers have many choices in microprocessors/microcontrollers.


Especially, in 8 bit and 32 bit, the available variety really may overwhelm even an experienced
designer. Selecting a right microprocessor may turn out as a most difficult first step and it is
getting complicated as new devices continue to pop-up very often.
In the 8 bit segment, the most popular and used architecture is Intel's 8031. Market
acceptance of this particular family has driven many semiconductor manufacturers to develop
something new based on this particular architecture. Even after 25 years of existence,
semiconductor manufacturers still come out with some kind of device using this 8031 core.

1.3 MICROCONTROLLERS FOR EMBEDDED SYSTEMS


In the Literature discussing microprocessors, we often see the term Embedded System.
Microprocessors and Microcontrollers are widely used in embedded system products. An
embedded system product uses a microprocessor (or Microcontroller) to do one task only. A
printer is an example of embedded system since the processor inside it performs one task only;
namely getting the data and printing it. Contrast this with a Pentium based PC. A PC can be
used for any number of applications such as word processor, print-server, bank teller terminal,
Video game, network server, or Internet terminal. Software for a variety of applications can be
loaded and run. Of course the reason a pc can perform myriad tasks is that it has RAM memory
and an operating system that loads the application software into RAM memory and lets the
CPU run it.

In an Embedded system, there is only one application software that is typically burned
into ROM. An x86 PC contains or is connected to various embedded products such as
keyboard, printer, modem, disk controller, sound card, CD-ROM drives, mouse, and so on.
Each one of these peripherals has a Microcontroller inside it that performs only one task. For
example, inside every mouse there is a Microcontroller to perform the task of finding the mouse
position and sending it to the PC.
CHAPTER-2

2.1 INTRODUCTION
Sewage environment IoT device and IoT platform to monitor poisonous gas has been
proposed as a solution to help the sewer workers who put their lives risk. Because of these
poisonous gases, the death rate of sewer workers has increased in the recent years. The lack of
treatment of sewage after crossing dangerous levels leads to the deaths of thousands of sewage
cleaners throughout the year from accidents and various diseases such as hepatitis and typhoid
that occur due to sudden or sustained exposure to hazardous gases. Septic tanks are devices
which are found commonly in different types of localities, ranging from residential areas to
largely developed industrial areas to provide solutions for treatment of sewage wastes. Sewage
gases generally arise from the natural decomposition of sewage and their mixtures formed by
slurries which leads to the production of toxic wastes that release hazardous gases. These gases
can be lethal if inhaled in high concentrations or for a prolonged period of time. Septic tank
gases are primarily constituted of methane, carbon dioxide, ammonia, hydrogen sulphide and
traces of carbon monoxide. In order to evaluate the gases which are present in sewage
environment, sensors have been used to analyse the amount of hazardous gas and send an alert.
The hazardous gases like hydrogen sulphide, methane and carbon monoxide emitted from
sewage are sensed by gas sensors every moment and updated when it surpasses the normal
grade. The project aims at designing a prototype for monitoring a sewage plant or septic tank
in real-time for keeping a check on concentration levels of gases.

The designed system can be installed in various sewage facilities, both rural and urban.
The system can be made to work properly in both domestic as well as industrial plants, by
changing small specifications of design. For accessing the ppm concentrations, an user-friendly
android application was developed with multiple facilities integrated. The death rate of sewage
workers has been increased day by day.
Even by such understated estimates, the NCSK identified 817 sewer workers’ deaths
since 1993 from 20 states. By official estimates, Tamil Nadu recorded 210 deaths, Gujarat
recorded 156, followed by UP and Haryana with 77 and 70 deaths, respectively.
Reason for the deaths include: 1. Forcing the workers by the supervisors 2.
Unawareness about the poisonous gases present in sewage system.

2.2 LITERATURE REVIEW


The utilization of a sewage monitoring system sets in place a useful approach to remind
individuals or facilities employing the workers and to evacuate areas when ppm levels of
certain gases exceeds the threshold value. This saves lives of the employees working in harmful
environments and saves them from hazards. Many Organizations often employs sewage tanks
and chemical treatment of sewage sites in industries prior to sending in manual workers on site
and there is no system is in place to check on hazardous levels. A smart system is defined as a
cyber-physical system or an embedded system, that can process sensor data and assure a
wireless communication to the server. There are many different proposed systems researched
by the scientist about the environmental pollution and air hazards due to industrial sewage. For
example, IoT can be mainly be used to address the air pollution problem, as proposed in
pollunio [2] which checks the Ground-level ozone and particulate matter that causes respiratory
diseases such as sulphur dioxide, nitrogen oxides or airborne particles caused by emission of
polluting gases from vehicles that degrade air quality. In survey [9] which brings in Wireless
Sensor Networks(WSN)for air pollution monitoring system called Wireless Sensor Network
and Air Pollution Monitoring System (WAPMS). This mainly utilize the Air Quality Index
(AQI) as the main parameter and employs data aggregation algorithm to merge data to remove
duplicate information’s and filter out invalid readings. Proposal [5], the authors have designed
an intelligent residential security alarm and remote-control system to check on toxic gas
leakage in homes. The Internet of Things [6-9] is being perceived by analysts as a stand out
amongst most of the modern advancements with the plan to significantly change the wellbeing,
security and security and addresses real effects inside the general public. This technology can
be used in collaboration with sensors, and a smart system is designed for industrial purposes.

2.3 PROPOSED METHOD:


In the proposed system we use various gas sensors inclusive of MQ4 (Methane
sensor) and MQ7(Carbon Monoxide sensor) for detecting the presence of hazardous
gases in sewage. The control of the setup present at different nodal locations is provided
to a single receiver end. The sensor produces a wide range of values which are emitted
from sewage to the controlling kit. The calibration of these sensors is done by defining
resistor networks to make them usable for industrial and domestic utilization. Depending
on a set predefined condition, the output is transmitted via the WIFI module to the cloud.
Here we have used Things Speak IoT platform for this project. The prototype is deployed
at strategic locations by analyzing the sewer map and forming a basis such as inspection
demands to find the most accessible location. Normally, they are placed at a sewer entry
location. The dispensing schedule can be organized based on the application which is to
be fulfilled. For instance, if the operators want to understand how in-sewer gas level
changes over time, they can analyze the graph plotted by the system on the ThingSpeak
IoT platform.
2.4 BLOCK DIAGRAM:

In this proposed system we have MQ4 gas sensor (consist of methane, carbon monoxide
and hydrogen sulphide) which is used to detect harmful gases present in the sewage. Different
nodal locations are provided to a single receiver end. The gas sensor produces values(ppm)
which are emitted from sewage to the kit. Depending on a set of conditions, the output obtained
by the gas sensor is transmitted via the WIFI module to the cloud. In this project we have used
ThinkSpeak cloud to store the values.
CHAPTER 3

HARDWARE COMPONENTS

3.1 Microcontroller (ATMEGA16)


A microcontroller is a small computer on a single integrated circuit containing a processor core,
memory, and programmable input/output peripherals. The one we used is Arduino Uno. Arduino is a
single-board microcontroller designed to make the process of using electronics in multidisciplinary
projects more accessible. The hardware consists of a simple open source hardware board designed
around an 8-bit Atmel AVR microcontroller. An Arduino board consists of an Atmel 8-bit AVR
microcontroller with complementary components to facilitate programming and incorporation into
other circuits. An important aspect of the Arduino is the standard way that connectors are exposed,
allowing the CPU board to be connected to a variety of interchangeable add-on modules known as
shields. The software consists of a standard programming language compiler and a boot loader that
executes on the microcontroller.

Features of ATMEGA 328P controller includes:

High performance, low power AVR® 8-bit microcontroller

Advanced RISC architecture

131 powerful instructions – most single clock cycle execution

32  8 general purpose working registers

Fully static operation

Up to 16MIPS throughput at 16MHz

On-chip 2-cycle multiplier

High endurance non-volatile memory segments


32K bytes of in-system self-programmable flash program memory

1Kbytes EEPROM

2Kbytes internal SRAM

Write/erase cycles: 10,000 flash /100,000 EEPROM

Optional boot code section with independent lock bits

In-system programming by on-chip boot program

True read-while-write operation

Programming lock for software security

Peripheral features includes

Two 8-bit Timer/Counters with separate prescaler and compare mode

One 16-bit Timer/Counter with separate prescaler, compare mode, and capture mode

Real time counter with separate oscillator

Six PWM channels

8-channel 10-bit ADC in TQFP and QFN/MLF package

Temperature measurement

Programmable serial USART

Master/slave SPI serial interface

Byte-oriented 2-wire serial interface (Phillips I2 C compatible)

Programmable watchdog timer with separate on-chip oscillator

On-chip analog comparator

Interrupt and wake-up on pin change

Special microcontroller features

Power-on reset and programmable brown-out detection

Internal calibrated oscillator


External and internal interrupt sources

Six sleep modes: Idle, ADC noise reduction, power-save, power-down, standby, and extended standby
I/O and packages

23 programmable I/O lines

32-lead TQFP, and 32-pad QFN/MLF

Operating voltage: 2.7V to 5.5V for ATmega328P

Temperature range:

Automotive temperature range: –40°C to +125°C

Speed grade: 0 to 8MHz at 2.7 to 5.5V (automotive temperature range: –40°C to +125°C)

0 to 16MHz at 4.5 to 5.5V (automotive temperature range: –40°C to +125°C)

Low power consumption

Active mode: 1.5mA at 3V - 4MHz

Power-down mode: 1µA at 3V


Figure 3.1: Internal architecture of ATMEGA328P

The AVR® core combines a rich instruction set with 32 general purpose working
registers. All the 32 registers are directly connected to the arithmetic logic unit (ALU), allowing
two independent registers to be accessed in one single instruction executed in one clock cycle.
The resulting architecture is more code efficient while achieving throughputs up to ten times
faster than conventional CISC microcontrollers. The Atmel® ATmega328P provides the
following features: 32K bytes of in-system programmable flash with read-while-write
capabilities, 1K bytes EEPROM, 2K bytes SRAM, 23 general purpose I/O lines, 32 general
purpose working registers, three flexible Timer/Counters with compare modes, internal and
external interrupts, a serial programmable USART, a byteoriented 2-wire serial interface, an
SPI serial port, a 6-channel 10-bit ADC (8 channels in TQFP and QFN/MLF packages), a
programmable watchdog timer with internal oscillator, and five software selectable power
saving modes. The idle mode stops the CPU while allowing the SRAM, Timer/Counters,
USART, 2-wire serial interface, SPI port, and interrupt system to continue functioning. The
power-down mode saves the register contents but freezes the oscillator, disabling all other chip
functions until the next interrupt or hardware reset. In power-save mode, the asynchronous
timer continues to run, allowing the user to maintain a timer base while the rest of the device
is sleeping. The ADC noise reduction mode stops the CPU and all I/O modules except
asynchronous timer and ADC, to minimize switching noise during ADC conversions. In
standby mode, the crystal/resonator oscillator is running while the rest of the device is sleeping.
This allows very fast start-up combined with low power consumption. The device is
manufactured using Atmel high density non-volatile memory technology. The on-chip ISP
flash allows the program memory to be reprogrammed in-system through an SPI serial
interface, by a conventional non-volatile memory programmer, or by an on-chip boot program
running on the AVR core. The boot program can use any interface to download the application
program in the application flash memory. Software in the boot flash section will continue to
run while the application flash section is updated, providing true read-while-write operation.
By combining an 8-bit RISC CPU with in-system self-programmable flash on a monolithic
chip, the Atmel ATmega328P is a powerful microcontroller that provides a highly flexible and
cost effective solution to many embedded control applications. The ATmega328P AVR is
supported with a full suite of program and system development tools including: C compilers,
macro assemblers, program debugger/simulators, in-circuit emulators, and evaluation kits.

In order to maximize performance and parallelism, the AVR uses a harvard architecture
– with separate memories and buses for program and data. Instructions in the program memory
are executed with a single level pipelining. While one instruction is being executed, the next
instruction is pre-fetched from the program memory. This concept enables instructions to be
executed in every clock cycle. The program memory is in-system reprogrammable flash
memory.
The fast-access register file contains 32  8-bit general purpose working registers with
a single clock cycle access time. This allows single-cycle arithmetic logic unit (ALU)
operation. In a typical ALU operation, two operands are output from the register file, the
operation is executed, and the result is stored back in the register file – in one clock cycle. Six
of the 32 registers can be used as three 16-bit indirect addresses register pointers for data space
addressing – enabling efficient address calculations. One of the address pointers can also be
used as an address pointer for look up tables in flash program memory. These added function
registers are the 16-bit X-, Y-, and Z-register, described later in this section. The ALU supports
arithmetic and logic operations between registers or between a constant and a register. Single
register operations can also be executed in the ALU. After an arithmetic operation, the status
register is updated to reflect information about the result of the operation. Program flow is
provided by conditional and unconditional jump and call instructions, able to directly address
the whole address space. Most AVR® instructions have a single 16-bit word format. Every
program memory address contains a 16- or 32-bit instruction. Program flash memory space is
divided in two sections, the boot program section and the application program section. Both
sections have dedicated lock bits for write and read/write protection. The SPM instruction that
writes into the application flash memory section must reside in the boot program section.
During interrupts and subroutine calls, the return address program counter (PC) is stored on the
stack. The stack is effectively allocated in the general data SRAM, and consequently the stack
size is only limited by the total SRAM size and the usage of the SRAM. All user programs
must initialize the SP in the reset routine (before subroutines or interrupts are executed). The
stack pointer (SP) is read/write accessible in the I/O space. The data SRAM can easily be
accessed through the five different addressing modes supported in the AVR architecture. The
memory spaces in the AVR architecture are all linear and regular memory maps. A flexible
interrupt module has its control registers in the I/O space with an additional global interrupt
enable bit in the status register. All interrupts have a separate interrupt vector in the interrupt
vector table. The interrupts have priority in accordance with their interrupt vector position. The
lower the interrupt vector address, the higher the priority. The I/O memory space contains 64
addresses for CPU peripheral functions as control registers, SPI, and other I/O functions. The
I/O memory can be accessed directly, or as the data space locations following those of the
register file, 0x20 - 0x5F. In addition, the ATmega328P has extended I/O space from 0x60 -
0xFF in SRAM where only the ST/STS/STD and LD/LDS/LDD instructions can be used.
3.2 Serial Communication
Computers can transfer data in two ways: parallel and serial. In parallel data transfers,
often 8 or more lines (wire conductors) are used to transfer data to a device that is only a few
feet away. Examples of parallel data transfer are printers and hard disks; each uses cables with
many wire strips. Although in such cases a lot of data can be transferred in a short amount of
time by using many wires in parallel, the distance cannot be great. To transfer to a device
located many meters away, the serial method is used. In serial communication, the data
is sent one bit at a time, in contrast to parallel communication, in which the data is sent a
byte or more at a time.

3.3 MQ4 Gas sensor


It is a Metal Oxide Semiconductor (MOS) type Gas Sensor mainly used to detect
the Methane (CNG) gas concentration in the air either at home or in industry. This sensor
contains a sensing element, mainly aluminum-oxide based ceramic, coated with Tin
dioxide, enclosed in a stainless-steel mesh. Whenever gas comes into contact with the
sensing element, the resistivity of the element changes. The change is then measured to
get the concentration of the gases present. Its sensing range of 300-10000 PPM is suitable
for gas leak detection. The combustion of Methane is highly exothermal means it will
release a vast amount of heat if ignited which when used in a controlled way is beneficial
but if an accident occurs it will be devastating.

Specifications

 Power requirements: VCC - 5V±0.1


 DO output: TTL digital 0 and 1 (0.1 and 5V)
 AO output: 0.1-0 .3 V (relative to pollution), for maximum concentration of a voltage of
about 4V
 Detection Gas: Natural gas/Methane
 Detection Concentration: 200-10000ppm (Natural gas / Methane)
 Interface: 1 TTL compatible input (HSW), 1 TTL compatible output (ALR)
 Heater consumption: less than 750mw
 Operating temperature: 14 to 122 °F (-10 to 50°C)
 Preheat time: Over 24 hours
Product Description

To use the Sensor Module, you have power the device with 5V supply and the
Power LED will start to glow. You should give it some time for its preheating period before
start reading the output. While measuring the gas present, the Output LED will glow in a
specific concentration of the gas. You can change it by using the potentiometer. Else you
can also use the Analog Output to see how your program reacts to different
concentrations of gases present.

3.4 MQ7 Carbon Monoxide sensor


It is another one of Metal Oxide Semiconductor (MOS) type Gas Sensor of MQ Gas
Sensors family involving MQ 2, MQ 4, MQ 3, MQ 8, MQ 135, etc. It is mainly used to
detect Carbon Monoxide. This sensor contains a sensing element, mainly aluminum-
oxide based ceramic, coated with Tin dioxide (SnO2), enclosed in a stainless-steel mesh.
Whenever CO gas comes into contact with the sensing element, the resistivity of the
element changes. The change is then measured to get the concentration of the gases
present. The MQ7 Sensor has a small heating element present which is needed to preheat
the sensor to get it in the working window. It can detect Carbon Monoxide Gas in the
range of 20 PPM to 2000 PPM in the air. It finds uses in Alarm application in case of CO
gas concentration build-up in the home or your car as CO is a very harmful gas and can
kill a person if present over 300PPM.
SPECIFICATIONS

 Operating Voltage is +5V


 Can be used to Measure or detect CO
 Analog output voltage: 0V to 5V
 Digital Output Voltage: 0V or 5V
 Stable, Long life and Low Cost
 Fast Response time
 Heater consumption about 350mW
 The Sensitivity of Digital Output pin can be varied using the potentiometer

PRODUCT DESCRIPTION

To use the Sensor Module, you have power the device with 5V supply and the
Power LED will start to glow. To power it, you can use external supply or connect +5V
and GND pin of Arduino. You should give it some preheating time before start reading the
output. While measuring the gas present, the Output LED will glow in a specific
concentration of the gas. You can change it by using the potentiometer. Else you can also
use the Analog Output to see how your program reacts to different concentrations of
gases present.

3.5 ESP 8266-01 WiFi Module:

ESP-01 WiFi encapsulates module is developed by module is developed by Ai-


thinker Team. core processor ESP8266 in smaller sizes of the module Tensilica L106 integrates
industry-leading ultra low power 32bit MCU micro, with the 16 Clock speed support 80 MHz,
160 MHz, supports the RTOS, integrated Wi-Fi MAC The module supports standard
IEEE802.11 Tensilica L106 integrates industry Clock speed support 80 MHz, 160 MHz,
supports the RTOS, integrated Wi The module supports standard IEEE802.11 add modules to
an existing device networking, or building a separate network controller. ESP8266 is high
integration core processor ESP8266 in smaller sizes of the module bit MCU micro, with the
16-bit short mode, /BB/RF/PA/LNA, on-board antenna. b/g/n agreement, complete TCP/IP
protocol stack. Users can use the /BB/RF/PA/LNA, on b/g/n agreement, complete TCP/IP
protocol stack. Users can use the add modules to an existing device networking, or building a
separate network controller. wireless SOCs, designed for space and power constrained mobile
platform unsurpassed ability to embed Wiwireless SOCs, designed for space and power
constrained mobile platform It provides wireless SOCs, designed for space and power
constrained mobile platform designers. Fi capabilities within other systems, or to function as a
standalone unsurpassed ability to embed Wi application, with the lowest cost, and minimal
space requirement. Fi capabilities within other systems, or to function as a standalone
application, with the lowest cost, and minimal space requirement.

ESP8266EX offers a complete and or to offload Wiself self-contained WiFi


networking solution; it can be used to host Fi networking solution; it can be used to host the
application Fi networking functions from another application processor. When ESP8266EX
hosts the application, it boots up directly from an external flash. In has Fi networking functions
from another application processor When ESP8266EX hosts the application, it boots up
directly from an external flash. In has improve the performance of the system in such
applications. improve the performance of the system in such applications. Alternately, serving
as a integrated cache to Fi adapter, wireless internet access can be added to any micro controller
based design Fi adapter, wireless internet access can be added to any micro controller based
design with simple connectivity (SPI/SDIO or I2C/UART interface).

The ESP8266 ESP-01 is a Wi-Fi module that allows microcontrollers access to


a Wi-Fi network. This module is a self-contained SOC (System On a Chip) that doesn’t
necessarily need a microcontroller to manipulate inputs and outputs as you would normally do
with an Arduino, for example, because the ESP-01 acts as a small computer. Depending on
the version of the ESP8266, it is possible to have up to 9 GPIOs (General Purpose Input
Output). Thus, we can give a microcontroller internet access like the Wi-Fi shield does to the
Arduino, or we can simply program the ESP8266 to not only have access to a Wi-Fi network,
but to act as a microcontroller as well. This makes the ESP8266 very versatile, and it can save
you some money and space in your projects.

3.7 LIQUID CRYSTAL DISPLAY


LCD stands for Liquid Crystal Display. LCD is finding wide spread use replacing LEDs
(seven segment LEDs or other multi segment LEDs) because of the following reasons:
1. The declining prices of LCDs.
2. The ability to display numbers, characters and graphics. This is in contrast to LEDs, which are
limited to numbers and a few characters.
3. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of the task of
refreshing the LCD. In contrast, the LED must be refreshed by the CPU to keep displaying the
data.
4. Ease of programming for characters and graphics.
These components are “specialized” for being used with the microcontrollers, which
means that they cannot be activated by standard IC circuits. They are used for writing different
messages on a miniature LCD.
Fig:. LCD Display

A model described here is for its low price and great possibilities most frequently used
in practice. It is based on the HD44780 microcontroller (Hitachi) and can display messages in
two lines with 16 characters each. It displays all the alphabets, Greek letters, punctuation marks,
mathematical symbols etc. In addition, it is possible to display symbols that user makes up on
its own. Automatic shifting message on display (shift left and right), appearance of the pointer,
backlight etc. are considered as useful characteristics.
PINS FUNCTIONS

There are pins along one side of the small printed board used for connection to the
microcontroller. There are total of 14 pins marked with numbers (16 in case the background
light is built in). Their function is described in the table below:
Pin Logic
Function Name Description
Number State

Ground 1 Vss - 0V

Power supply 2 Vdd - +5V

Contrast 3 Vee - 0 – Vdd

D0 – D7 are interpreted as
0
4 RS commands
1
D0 – D7 are interpreted as data

Write data (from controller to


0 LCD)
Control of 5 R/W
1 Read data (from LCD to
operating
controller)

0 Access to LCD disabled


1 Normal operating
6 E
From 1 to Data/commands are transferred
0 to LCD

7 D0 0/1 Bit 0 LSB

8 D1 0/1 Bit 1

9 D2 0/1 Bit 2
Data /
commands
10 D3 0/1 Bit 3

11 D4 0/1 Bit 4

12 D5 0/1 Bit 5
13 D6 0/1 Bit 6

14 D7 0/1 Bit 7 MSB

Table 1: Pin Functions


LCD SCREEN:
LCD screen consists of two lines with 16 characters each. Each character consists of
5x7 dot matrix. Contrast on display depends on the power supply voltage and whether messages
are displayed in one or two lines. For that reason, variable voltage 0-Vdd is applied on pin
marked as Vee. Trimmer potentiometer is usually used for that purpose. Some versions of
displays have built in backlight (blue or green diodes). When used during operating, a resistor
for current limitation should be used (like with any LE diode).

Fig: 7.2 LCD Pin Connections


LCD BASIC COMMANDS
All data transferred to LCD through outputs D0-D7 will be interpreted as commands or
as data, which depends on logic state on pin RS:
RS = 1 - Bits D0 - D7 are addresses of characters that should be displayed. Built in
processor addresses built in “map of characters” and displays corresponding symbols.
Displaying position is determined by DDRAM address. This address is either previously
defined or the address of previously transferred character is automatically incremented.
RS = 0 - Bits D0 - D7 are commands which determine display mode. List of commands
which LCD recognizes are given in the table below:
Command Execution
RS RW D7 D6 D5 D4 D3 D2 D1 D0
Time

Clear display 0 0 0 0 0 0 0 0 0 1 1.64mS

Cursor home 0 0 0 0 0 0 0 0 1 X 1.64mS

Entry mode set 0 0 0 0 0 0 0 1 I/D S 40uS

Display on/off
0 0 0 0 0 0 1 D U B 40uS
control

Cursor/Display
0 0 0 0 0 1 D/C R/L x X 40uS
Shift

Function set 0 0 0 0 1 DL N F x X 40uS

Set CGRAM
0 0 0 1 CGRAM address 40uS
address

Set DDRAM
0 0 1 DDRAM address 40uS
address

Read “BUSY” flag


0 1 BF DDRAM address -
(BF)

Write to CGRAM
1 0 D7 D6 D5 D4 D3 D2 D1 D0 40uS
or DDRAM

Read from 40uS


CGRAM or 1 1 D7 D6 D5 D4 D3 D2 D1 D0
DDRAM

Table 6: LCD Commands


I/D 1 = Increment (by 1) R/L 1 = Shift right
0 = Decrement (by 1) 0 = Shift left
S 1 = Display shift on DL 1 = 8-bit interface
0 = Display shift off 0 = 4-bit interface
D 1 = Display on N 1 = Display in two lines
0 = Display off 0 = Display in one line

U 1 = Cursor on F 1 = Character format 5x10 dots


0 = Cursor off 0 = Character format 5x7 dots
B 1 = Cursor blink on D/C 1 = Display shift
0 = Cursor blink off 0 = Cursor shift
LCD Initialization:
Once the power supply is turned on, LCD is automatically cleared. This process lasts
for approximately 15mS. After that, display is ready to operate. The mode of operating is set
by default. This means that:
1. Display is cleared
2. Mode
DL = 1 Communication through 8-bit interface
N = 0 Messages are displayed in one line
F = 0 Character font 5 x 8 dots
3. Display/Cursor on/off
D = 0 Display off
U = 0 Cursor off
B = 0 Cursor blink off
4. Character entry
ID = 1 Addresses on display are automatically incremented by 1
S = 0 Display shift off
Automatic reset is mainly performed without any problems. Mainly but not always! If
for any reason power supply voltage does not reach full value in the course of 10mS, display
will start perform completely unpredictably. If voltage supply unit cannot meet this condition
or if it is needed to provide completely safe operating, the process of initialization by which a
new reset enabling display to operate normally must be applied.
Algorithm according to the initialization is being performed depends on whether
connection to the microcontroller is through 4- or 8-bit interface. All left over to be done after
that is to give basic commands and of course- to display messages.
Fig 3.2: Procedure on 8-bit initialization

3.6 Regulated Power Supply


The power supplies are designed to convert high voltage AC mains electricity to a suitable
low voltage supply for electronics circuits and other devices. A RPS (Regulated Power
Supply) is the Power Supply with Rectification, Filtering and Regulation being done on the
AC mains to get a Regulated power supply for Microcontroller and for the other devices being
interfaced to it.
A power supply can by broken down into a series of blocks, each of which performs a
particular function. A d.c power supply which maintains the output voltage constant
irrespective of a.c mains fluctuations or load variations is known as “Regulated D.C Power
Supply”
For example a 5V regulated power supply system as shown below:

Fig.3.: Block Diagram of the Power Supply


CHAPTER 4

4.1 ARDUINO IDE TOOL


Arduino is an open-source electronics platform based on easy-to-use hardware and
software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a
Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing
something online. You can tell your board what to do by sending a set of instructions to the
microcontroller on the board. To do so you use the Arduino programming language (based
on Wiring), and the Arduino Software (IDE), based on Processing.

Over the years Arduino has been the brain of thousands of projects, from everyday
objects to complex scientific instruments. A worldwide community of makers - students,
hobbyists, artists, programmers, and professionals - has gathered around this open-source
platform, their contributions have added up to an incredible amount of accessible
knowledge that can be of great help to novices and experts alike.

Arduino was born at the Ivrea Interaction Design Institute as an easy tool for fast
prototyping, aimed at students without a background in electronics and programming. As soon
as it reached a wider community, the Arduino board started changing to adapt to new needs
and challenges, differentiating its offer from simple 8-bit boards to products
for IoT applications, wearable, 3D printing, and embedded environments. All Arduino boards
are completely open-source, empowering users to build them independently and eventually
adapt them to their particular needs. The software, too, is open-source, and it is growing
through the contributions of users worldwide.

Why Arduino?

Thanks to its simple and accessible user experience, Arduino has been used in thousands of
different projects and applications. The Arduino software is easy-to-use for beginners, yet
flexible enough for advanced users. It runs on Mac, Windows, and Linux. Teachers and
students use it to build low cost scientific instruments, to prove chemistry and physics
principles, or to get started with programming and robotics. Designers and architects build
interactive prototypes, musicians and artists use it for installations and to experiment with new
musical instruments. Makers, of course, use it to build many of the projects exhibited at the
Maker Faire, for example. Arduino is a key tool to learn new things. Anyone - children,
hobbyists, artists, programmers - can start tinkering just following the step by step instructions
of a kit, or sharing ideas online with other members of the Arduino community.

There are many other microcontrollers and microcontroller platforms available for
physical computing. Parallax Basic Stamp, Netmedia's BX-24, Phidgets, MIT's Handyboard,
and many others offer similar functionality. All of these tools take the messy details of
microcontroller programming and wrap it up in an easy-to-use package. Arduino also simplifies
the process of working with microcontrollers, but it offers some advantage for teachers,
students, and interested amateurs over other systems:

 Inexpensive - Arduino boards are relatively inexpensive compared to other microcontroller

platforms. The least expensive version of the Arduino module can be assembled by hand, and
even the pre-assembled Arduino modules cost less than $50
 Cross-platform - The Arduino Software (IDE) runs on Windows, Macintosh OSX, and Linux

operating systems. Most microcontroller systems are limited to Windows.


 Simple, clear programming environment - The Arduino Software (IDE) is easy-to-use for

beginners, yet flexible enough for advanced users to take advantage of as well. For teachers,
it's conveniently based on the Processing programming environment, so students learning to
program in that environment will be familiar with how the Arduino IDE works.
 Open source and extensible software - The Arduino software is published as open source

tools, available for extension by experienced programmers. The language can be expanded
through C++ libraries, and people wanting to understand the technical details can make the
leap from Arduino to the AVR C programming language on which it's based. Similarly, you
can add AVR-C code directly into your Arduino programs if you want to.
 Open source and extensible hardware - The plans of the Arduino boards are published
under a Creative Commons license, so experienced circuit designers can make their own
version of the module, extending it and improving it. Even relatively inexperienced users can
build the breadboard version of the module in order to understand how it works and save
money.
CHAPTER-5

5.1 INTERNET OF THINGS


The Internet of Things(IoT) is a system of ‘connected things’. The things generally
comprise of an embedded operating system and an ability to communicate with the
internet or with the neighbouring things. One of the key elements of a generic IoT system
that bridges the various ‘things’ is an IoT service. An interesting implication from the
‘things’ comprising the IoT systems is that the things by themselves cannot do anything.
At a bare minimum, they should have an ability to connect to other ‘things’. But the real
power of IoT is harnessed when the things connect to a ‘service’ either directly or via
other ‘things’. In such systems, the service plays the role of an invisible manager by
providing capabilities ranging from simple data collection and monitoring to complex
data analytics. The below diagram illustrates where an IoT service fits in an IoT
ecosystem:

One such IoT application platform that offers a wide variety of analysis,
monitoring and counter-action capabilities is ‘ThingSpeak’. Let us consider ThingSpeak
in detail.
5.2 What is ThingSpeak
ThingSpeak is a platform providing various services exclusively targeted for
building IoT applications. It offers the capabilities of real-time data collection, visualizing
the collected data in the form of charts, ability to create plugins and apps for collaborating
with web services, social network and other APIs. We will consider each of these features
in detail below.
The core element of ThingSpeak is a ‘ThingSpeak Channel’. A channel stores
the data that wesend to ThingSpeak and comprises of the below elements:
 8 fields for storing data of any type - These can be used to store the data from a
sensor or froman embedded device.
 3 location fields - Can be used to store the latitude, longitude and the elevation.
These are veryuseful for tracking a moving device.
 1 status field - A short message to describe the data stored in the channel.

To use ThingSpeak, we need to signup and create a channel. Once we have a


channel, we can send the data, allow ThingSpeak to process it and also retrieve the
same. Let us start exploring ThingSpeak by signing up and setting up a channel.

5.3 Getting Started


Open https://thingspeak.com/ and click on the ‘Get Started Now’ button on the
center of the page and you will be redirected to the sign-up page(you will reach the same
page when you click the ‘Sign Up’ button on the extreme right). Fill out the required details
and click on the ‘Create Account’ button.
Now you should see a page with a confirmation that the account was successfully
created. The confirmation message disappears after a few seconds and the final page
should look as in the below screen:
Go ahead and click on ‘New Channel’. You should see a page like the below:

You can change the name to fit your need and you can add a description corresponding to
the channel. You can add any other useful description into the metadata field. In the same
page, you should see the fields for Latitude, Longitude and Elevation. Also, when you
scroll down you should see a check box that says ‘Make Public?’. Let us consider the
significance of the various fields and the tabs:

 Latitude, longitude and elevation - These fields correspond to the location of a ‘thing’
and are especially significant for moving things.
 Make Public? - If the channel is made public, anyone can view the channel's data feed
and the corresponding charts. If this check box is not checked, the channel is private,
which means for every read or write operation, the user has to pass a corresponding API
key.
 URL - This can be the URL of your blog or website and if specified, will appear on the
public view of the channel.
 Video ID - This is the ID corresponding to your YouTube or Vimeo ID. If specified,
the video appears on the public view of the channel.
 Fields 1 to 8 - These are the fields which correspond to the data sent by a sensor or a
‘thing’. A field has to be added before it can be used to store data. By default, Field 1 is
added. In case you try posting to fields that you have not added, your request will still be
successful, but you will not be able to see the field in the charts and the corresponding data.
You can click on the small box before the ‘add field’ text corresponding to each field to
add it. Once you click the ‘add field’ box, a default label name appears in the text box
corresponding to each field and the ‘add field’ text changes to ‘remove field’. You can
edit the field text that appears by default when a field is added to make more sense. For
example, in the below screen, I have modified the text for Field 2 to ‘SensorInput’. To
remove a field which is added, just check on the ‘remove field’ box. Once you click this,
the text ‘remove field’ changes back to ‘add field’ and the corresponding field text is
cleared.
Once you have edited the fields, click on ‘Save Channel’ button. You should now see

a page likethe below in which the ‘Private View’ tab is defaulted:


The Private View shows a chart corresponding to each of the fields that we have added.
Now click on the ‘Public View’ tab. This should look exactly similar to the what we see in the
‘Private View’ tab since our channel is public. In case your channel is not public('make public'
check box not checked in the ‘channel settings’ tab), the public view tab shows a message that
‘This channel is not public’.
Now click on the ‘API Keys’ tab. You should see a screen similar to the below. The
write API key is used for sending data to the channel and the read API key(s) is used to read
the channel data.
When we create a channel, by default, a write API key is generated. We generate read
API keys byclicking the ‘Generate New Read API Key’ button under this tab.You can also
add a note corresponding to each of the read API keys.
Note: Please note that clicking on the ‘Generate New Write API Key’ will over-write
the previous key. You will only have one Write API key at any point of time. Also, in case
your channel is private, others can only view the channel’s feed and charts by using a Read
API key. Please share the Read API keys with people who are approved and authorized to
view your channel.
Now click on the ‘Data Import/Export’ tab and you should see a screen similar to the
below. This tab is used to import the ‘Comma Separated Values(CSV)’ data from a file into
the channel. You can also download the channel’s feed from here in CSV format. This tab
also outlines how to send and view data by providing the URIs to the send and view APIs.

After a series of updates, the charts in the private view tab for each of the fields will look
like the below:
Each of the dots correspond to the value and the time at which the value was posted to the
channel. Place the mouse over a dot to get more details on the exact date and the GMT
offset from which the value was posted.

Please note that in the above example, I have sent some sample values to the channel. You
cansend any data here, say the periodic readings from a temperature sensor or RPM values
from a motor. The Y-axis show the names that we specified to each of the labels. I have used
Internet Explorer 11 to run this example. After running this, to check whether the feed got
updated, run the below URL:

http://api.thingspeak.com/channels/YOUR_CHANNEL_ID/feed.json?key=YOUR_KEY&lo
cation=tru e

NOTE: As mentioned above, you have to replace YOUR_KEY with your write API key and
replace YOUR_CHANNEL_ID with the ID corresponding to your channel. Also, if you
invoke the above URL without specifying location=true, you will not be able to see the latitude,
longitude and altitude fields.

The below is a screen after running the above URL after updating my location details for
few times:

5.4 ThingSpeak Apps


ThingSpeak provides apps that allow us for an easier integration with the web services,
social networks and other APIs. Below are some of the apps provided by ThingSpeak:
 ThingTweet - This allows you to post messages to twitter via ThingSpeak. In essence, this is
a TwitterProxy which re-directs your posts to twitter.
 ThingHTTP - This allows you to connect to web services and supports GET, PUT, POST
and DELETE methods of HTTP.
 TweetControl - Using this, you can monitor your Twitter feeds for a specific key word and
then process the request. Once the specific keyword is found in the twitter feed, you can then
use ThingHTTP to connect to a different web service or execute a specific action.
 React - Send a tweet or trigger a ThingHTTP request when the Channel meets a
certaincondition.
 TalkBack - Use this app to queue up commands and then allow a device to act uponthese
queued commands.
 Timecontrol - Using this app, we can do a ThingTweet, ThingHTTP or a TalkBack at a
specified time in the future. We can also use this to allow these actions to happen at a
specified time throughout the week.

In addition to the above, ThingSpeak allows us to create the ThingSpeak applications as


plugins using HTML, CSS and JavaScript which we can embed inside a website or inside
our ThingSpeak channel.

One of the key elements of an IoT system is an IoT service. ThingSpeak is one such
application platform offering a wide variety of features. At the heart of ThingSpeak is a
channel which can be used for storing and processing data collected from the ‘things’.
ThingSpeak also provides various apps for integration with web services, other APIs and
social networks and provides the capability to create the applications as plugins. It is a great
platform with extensive possibilities to explore the integration of the Internet of Things.
CHAPTER-6

6.1 SCHEMATIC DIAGRAM


Figure below shows the system methodology which includes Arduino UNO where
simulation of sensors, Software and tracking is done on this microcontroller.

Calibrating the sensors: MQ series sensors consist small heater with an electro-chemical
sensor in order to measure different kind of gases combinations. It is recommended to calibrate
the detector for 5000 ppm of gas concentration and use value of Load resistance (RL) about 20KΩ.
The sensor itself yields an analog voltage which is transferred using an ADC. The values
transferred can be used for designing to get the ppm values of the gas. Connecting WIFI Module
to Arduino: It creates a serial communication between Arduino and WIFI module. Hence, the serial
pins of Arduino (Rx and Tx) and WIFI is done by connecting Rx pin of WIFI module to Tx pin of
Arduino and Tx pin of WIFI module to Rx pin of Arduino.

ThingSpeak IOT platform uses channels to store data sent from devices. By altering the
settings in Channel configuration, and creation of a channel is done, and then data is sent to and
from to the channel and retrieved in the same way. Channels are made public to share data. Is done
by connecting MQTT publish method which can be also used to update the channel feed and the
MQTT subscriber to receive messages. Sending the readings to ThingSpeak server and analyzing
graphs using MATLAB in ThingSpeak- ThingSpeak IoT platform is an open source with
incorporate Wi-Fi chip. In the proposed design, it is used to take readings from sensors and upload
the value of ppm concentration of gas on the cloud using WIFI that using HTTP.

6.2 CONCLUSION:

Septic tanks are a method to check on hazardous release of gaseous components into the
environment in areas inclusive of both residential and industrial premises. Sewage, on
natural decomposition, often leads to production of toxic gases. These gases can be
poisonous if inhaled for a long period of time and may lead to chronic illnesses in work force,
if it is introduced in the body in high concentrations. Septic tank gases contain sulphur
dioxide, hydrogen sulphide (H2S), methane, ammonia, nitrogen dioxide, carbon dioxide and
traces of carbon monoxide. These toxic gases thus become dangerous especially for sewage
workers and cleaners and sometimes lead to their death. Therefore, to prevent exposure to
such workplace hazards, an IOT based monitoring system was proposed and designed which
monitored their levels and analyzed the quantities present in the environment. In this
project carbon monoxide gas was sensed using sensor module MQ-7 and methane gas using
sensor module MQ-4.

You might also like