Report Title:
Smoke and Natural Gas Detector an IoT
device
Prepared by:
Hassan Ali Butt
1|Page
Contents
Introduction .................................................................................................................................... 3
Project Objectives: ......................................................................................................................... 3
Components Used ...................................................................................................................... 4
1) PIC 18F452 .............................................................................................................................. 4
2) NodeMCU ............................................................................................................................... 5
3) Sensors .................................................................................................................................... 5
5) 6V Relay’s ................................................................................................................................ 6
7) ULN2003A ............................................................................................................................... 7
Block Diagram ................................................................................................................................. 7
Working .......................................................................................................................................... 7
Input from sensors; ..................................................................................................................... 8
PIC18 Reading data and giving NodeMCU Further Signal ........................................................... 8
NodeMCU sending massage ....................................................................................................... 8
Proteus Simulation ......................................................................................................................... 9
Breadboard Patching...................................................................................................................... 9
Final Look ...................................................................................................................................... 10
Power Calculation ........................................................................................................................ 10
Cost: .............................................................................................................................................. 11
Observations: ............................................................................................................................... 11
2|Page
Introduction
Pakistan is a developing country. Here people are advancing their lives by every means. New
industries are being made everywhere even within the cities and near human population. But
while doing this they often neglect safety measures even there, where they shouldn’t. Like the
one we are trying to compensate.
In Pakistan there are great resources of natural gases. Natural gases are being used in factories
to run generators, in cars as fuels and in home for cooking and other purposes. In many places
people use other means like wood & cylinders too where natural gas isn’t available. Indeed
natural gas has its benefits, but at the same time it has many hazards.
Most of factories in Pakistan and even in many parts of world don’t follow major safety measures
to ensure the safety of their workers. That has caused major incidents like Baldia Factory incident
in Karachi, Bhopal Gas tragedy that caused the death of thousands of people. Only in Punjab,
more than 18,379 incidents were reported due to gas leakage or fire. i
In Northern Areas of Pakistan where in winters temperature drops up to -10. There locals use gas
heaters or woods and it cause many accidents. Many times from smoke of woods or natural gas
from heaters cause suffocation. Smoke contains carbon monoxide, carbon dioxide, nitrogen
oxide, irritant volatile organic compounds, air toxics and very small particles. All these elements
together suffocate a human to death in sleep without even realizing its victim that something is
wrong. Hundreds of these events has already occurred killing thousands throughout the world.
Same kind of dangers are attach with natural gas too. In Natural Gas most prominent element
are Methane (CH4). That is a combustible gas and responsible for most of the explosions occur
in houses and gas leakage is not just a problem of Pakistan but a worldwide problem. Like a
person is out and somehow gas leakage occurs, they return home lights a bulb and BOOOOM!
These are some very dangerous problems that want a simple and motivates us to make
something simple but very effective.
Project Objectives:
1. Make a system that can detect Natural Gas and Smoke. System or Product need to detect
both Natural gas, Smoke or Methane from any other source.
2. It will be an IoT product. Use WI-FI to send a message to the mobile of user once it detects
anything no matter where ever user is. This is what that makes it effective. Many time
carbon monoxide makes people unconscious so they can’t detect Alarm. We can fed
emergency number in it like 115 or 1122 and it will send the report of leakage to the
nearest fire department with current location. Thus can avoid many accidents.
3. It triggers alarm once it sense anything and keep ringing until leakage is fixed.
4. It should be able to Power on Water Shower (If necessary)
3|Page
5. It should be cheap and easy to install.
Components Used
PIC 18F452
NodeMCU
MQ2 (Smoke Sensor)
MQ5 (Gas Sensor)
6V Relay’s
ULN2003AN
Buzzer
1) PIC 18F452
PIC (usually pronounced as "pick") is a family of microcontrollers made by Microchip Technology,
originally developed by General Instrument's Microelectronics Division. The name PIC initially
referred to Peripheral Interface Controller and is currently expanded as Programmable Intelligent
Computer. It is one of the simplest Microcontroller with 40 pins and has a series of controllers in
its family.PIC Microcontroller has its own RAM, ROM, input output ports and its own Digital to
Analog convertor and Analog to Digital Convertor. ii
We are here using PIC18F family and using MPLAB IDE v8.92. It is the latest series of PIC
microcontroller series. It has 8 bit CPU and can do 12 Million Instructions per Second. To make
an IoT device it should be this fast to work and function properly. C language is used to do its
programming. After writing code, it is embed on PIC with certain protocols.
PICF452 is our main MC of project that will take input from sensors and will send pulse and signals
to microcontroller attach to it to perform further functions.
Image Courtesy: https://www.microchip.com
4|Page
2) NodeMCU
The NodeMCU (Node Microcontroller Unit) is an open source software and hardware
development environment that is built around a very inexpensive System-on-a-Chip (SoC)
called the ESP8266.It is an open form of IoT. It is a type of Arduino and use the same compiler
to do its programming The ESP8266, designed and manufactured by Espressif Systems, contains
all crucial elements of the modern computer: CPU, RAM, networking (Wi-Fi), and even a
modern operating system and SDK.
It will be connected to PIC with its TX pin for USART (Universal Synchronous Asynchronous
Receiver Transmitter) communication. GPS will be add on this and it will send SMS too. It can
be made user friendly to add home Wi-Fi name and password on it.
Sending SMS and current location will be its one of the Key functions. There are many built in
apps that can perform this task. We will use Blynk Iot Platform as it performs functions with
least error. It will be connected in series with PIC and get power from same source. It’s a type
of Arduino so same compiler is used to write its code.
Image courtesy: https://hallroad.org/nodemcu
3) Sensors
A number of smoke sensors are available in the market with different price and sensitivity range.
The sensor available in market looks like the one shown below:
5|Page
Image Courtesy: https://www.indiamart.com/
But if we go inside it has combination of simple and small sensors in it that help it work.
One of the simplest one is The Grove - Gas Sensor (MQ2). This module is useful for gas leakage
detection (home and industry). It is suitable for detecting H2, LPG, CH4, CO, Alcohol or Propane.
Due to its high sensitivity and fast response time, measurement can be taken as soon as possible.
The sensitivity of the sensor can be adjusted by potentiometer.
Image Courtesy: https://electrobes.com/
Another important sensor we will use is MQ2. It is another sensor of MQ sensor series. It is can
detect smoke that can cause suffocation like from woods, plastic or from any other source in its
surroundings and its sensitivity can also be changed and adjusted.
Image Courtesy: https://electrobes.com/
Both these sensors will be the input of PIC from environment. Input from these will be the
primary trigger to the response. PIC receive data from sensors and will trigger Alarm and give
signal to NodeMCU. After receiving signal from PIC, NodeMCU will perform its task of sending
SMS and location. The sensitivity of both will be adjust according to need.
5) 6V Relay’s
Relay is an electromechanical device to control Electrical Circuits. It works on DC power and can
be used to control AC or DC power sources. Relays basically are switching devices. That trigger
on pulse signal.
6|Page
Here we are using relays to trigger Alarm. We can connect with it with both PIC and NodeMCU
to trigger Alarm and water.
7) ULN2003A
ULN2003 is the ULN2003 is known for its high-current, high-voltage capacity. The drivers can be
paralleled for even higher current output. Even further, stacking one chip on top of another, both
electrically and physically, has been done .We are using it here to prevent our relays from back
EMF.
Block Diagram
Working
Project consists of 3 Parts
Input from sensors
PIC18 Reading data and giving NodeMCU Further Signal
NodeMCU sending massage
7|Page
Input from sensors
The primary or starting point of Project are sensors. Sensors take input from room or wherever
they are planted. We are taking Digital output from them and it is acting as Input for PIC18. Sensor
can work on two ways.
Give 5V on conducting and 0V on normal conditions
Give 0V on conducting and 5V on normal conditions
We are using 2nd form our sensors are normally on 5V but when they sense anything like smoke
or gas it gives 0V that act as input for PIC18 that perform further functions. Once there is a
leakage in the room or sensors detect any smoke or gas they give pulse to PIC on its input ports.
PIC18 Reading data and giving NodeMCU Further Signal
PIC18 receive digital signal from sensors. We are using its PORTB as Input from Sensors and
PORTC as Output that will give further signal to NodeMCU. PIC18 has the code that compare and
make decision that weather give signal to NodeMCU to send text Message to Phone or not. If
sensors are not detecting anything PIC will receive 5V means logic 1. When sensors sense
anything like smoke or gas it will receive logic 0 thus will instantly trigger alarm and tell NodeMCU
to send message.
In the project PIC18 is the master. The code embed in it will be the actual decision maker. While
NodeMCU and other features are slaves and their actions depends upon PIC signal.
NodeMCU sending massage
NodeMCU is our Wi-Fi module and it is responsible for communication between our project and
Phone on any location. We are using Blynk app for that. NodeMCU is what that makes it a IoT
product.
NodeMCU is the slave microcontroller that depends upon PIC18. While programming it we need
to enter Wi-Fi name and its code.
It will be easy to installed and used product. It has a small box that has its main components in it
and only sensors are visible outside from it. Only sensors are need to be installed on certain
locations like near burner, furnace or in a room where there is a heater or chimney and it will
start working. For power supply it need just 5V to operate and that can be given by a regular
mobile charger or the one that comes with it in package.
It has no motor so doesn’t make any noise until alarm is triggered. Once the alarm is triggered it
will not close until problem is fixed and sensors stop sensing any other gas or smoke from
enviorment.
8|Page
Proteus Simulation
Explanation:
Here PIC is visible and on right sides button represents sensors. Code is already embed in PIC and
LEDs represent Alarm, NodeMCU and water shower.
Breadboard Patching
9|Page
Final Look
Explanation
In final look we see a 5x5 inches PCB that has all components attach on it. Both sensors are attach
and working properly .PIC, NodeMCU are relays are also visible along side with alarm.
Power Calculation
Both Microcontrollers operate on 5V DC. We have separate supply for it. 5V and 1A.
Power =5Vx1A=5W
5W/1000=0.005 per hour Unit consumption
0.005x24=0.12 per day Unit consumption
It doesn’t have any mechanical part or motor that consume any extra power. It’s just an electrical
based components that require 5V to operate. But 5V should be constant and will never be closed
even during the power cut or load shedding. So, other than power supply it will have a battery
attach to it that power it in case of emergency.
10 | P a g e
Cost:
Sr. No. Product Quantity Prize
1 PIC18F452 1 700
2 NodeMCU 1 450
3 MQ2 1 250
4 MQ5 1 250
5 Resistors 5 2
6 6V Relay 3 3*35=105
7 Buzzer 1 100
8 Supply 12V 2A 1 130
9 Supply 5V 1A 1 150
10 ULN2003AN 1 35
Total =
2172/-
Observations:
Safety of humans is one thing that should never be undermine. Smoke and Natural gas detector
is a 21st century IoT based device that will help to revolutionize the concept of safety in houses
and small industries who can’t afford a big system. It is cost effective, small in size and
constructive system. It will not only reduce death with suffocation but in industries where human
senses can’t detect Methane and Natural gas leakage that caused big blasts if left unchecked for
a long time and will surely save many lives.
References
i
https://tribune.com.pk/story/2129343/2019-witnesses-4-4-surge-fire-incidents
ii http://ww1.microchip.com/downloads/en/DeviceDoc/39630C.pdf
11 | P a g e