Iot Gas Monitoring
Iot Gas Monitoring
Iot Gas Monitoring
Embedded Technology is now in its prime and the wealth of knowledge available is
mind blowing. However, most embedded systems engineers have a common complaint.
There are no comprehensive resources available over the internet which deal with the various
design and implementation issues of this technology. Intellectual property regulations of
many corporations are partly to blame for this and also the tendency to keep technical know-
how within a restricted group of researchers.
Every home has several examples of embedded computers. Any appliance that has a
digital clock, for instance, has a small embedded micro-controller that performs no other task
than to display the clock. Modern cars have embedded computers onboard that control such
things as ignition timing and anti-lock brakes using input from a number of different sensors.
Most embedded systems are time critical applications meaning that the embedded
system is working in an environment where timing is very important: the results of an
operation are only relevant if they take place in a specific time frame. An autopilot in an
aircraft is a time critical embedded system. If the autopilot detects that the plane for some
reason is going into a stall then it should take steps to correct this within milliseconds or there
would be catastrophic results.
1
1.1APPLICATIONS OF EMBEDDED SYSTEM
Medical equipment uses embedded systems for vital signs monitoring, electronic
stethoscopes for amplifying sounds, and various medical imaging (PET, SPECT, CT,
and MRI) for non-invasive internal inspections. Embedded systems within medical
equipment are often powered by industrial computers.[9]
Embedded systems are used in transportation, fire safety, safety and security, medical
applications and life critical systems, as these systems can be isolated from hacking and thus,
be more reliable. For fire safety, the systems can be designed to have greater ability to handle
higher temperatures and continue to operate. In dealing with security, the embedded systems
can be self-sufficient and be able to deal with cut electrical and communication systems.
2
1.2CHARACTERISTICS OF EMBEDDED SYSTEM
Embedded systems are designed to do some specific task, rather than be a general-
purpose computer for multiple tasks. Some also have real-time performance constraints that
must be met, for reasons such as safety and usability; others may have low or no performance
requirements, allowing the system hardware to be simplified to reduce costs.
Embedded systems are not always standalone devices. Many embedded systems consist
of small parts within a larger device that serves a more general purpose. For example,
the Gibson Robot Guitar features an embedded system for tuning the strings, but the overall
purpose of the Robot Guitar is, of course, to play music. Similarly, an embedded system in
an automobile provides a specific function as a subsystem of the car itself.
Embedded systems range from no user interface at all, in systems dedicated only to one
task, to complex graphical user interfaces that resemble modern computer desktop operating
systems. Simple embedded devices use buttons, LEDs, graphic or character LCDs (HD44780
LCD for example) with a simple menu system.
More sophisticated devices which use a graphical screen with touch sensing or screen-
edge buttons provide flexibility while minimizing space used: the meaning of the buttons can
change with the screen, and selection involves the natural behavior of pointing at what is
desired. Handheld systems often have a screen with a "joystick button" for a pointing device.
Some systems provide user interface remotely with the help of a serial (e.g. RS-
232, USB, I²C, etc.) or network (e.g. Ethernet) connection. This approach gives several
advantages: extends the capabilities of embedded system, avoids the cost of a display,
simplifies BSP and allows one to build a rich user interface on the PC. A good example of
this is the combination of an embedded web server running on an embedded device (such as
an IP camera) or a network router. The user interface is displayed in a web browser on a PC
connected to the device, therefore needing no software to be installed.
Embedded processors can be broken into two broad categories. Ordinary microprocessors
Embedded processors can be broken into two broad categories. Ordinary microprocessors
(μP) use separate integrated circuits for memory and peripherals. Microcontrollers (μC) have
on-chip peripherals, thus reducing power consumption, size and cost. In contrast to the
personal computer market, many different basic CPU architectures are used, since software is
3
custom-developed for an application and is not a commodity product installed by the end
user. Both Von Neumann as well as various degrees of Harvard architectures are
used. RISC as well as non-RISC processors are found. Word lengths vary from 4-bit to 64-
bits and beyond, although the most typical remain 8/16-bit. Most architectures come in a
large number of different variants and shapes, many of which are also manufactured by
several different companies.
Numerous microcontrollers have been developed for embedded systems use. General-
purpose microprocessors are also used in embedded systems, but generally require more
support circuitry than microcontrollers.
(μP) use separate integrated circuits for memory and peripherals. Microcontrollers (μC)
have on-chip peripherals, thus reducing power consumption, size and cost. In contrast to the
personal computer market, many different basic CPU architectures are used, since software is
custom-developed for an application and is not a commodity product installed by the end
user. Both Von Neumann as well as various degrees of Harvard architectures are
used. RISC as well as non-RISC processors are found. Word lengths vary from 4-bit to 64-
bits and beyond, although the most typical remain 8/16-bit. Most architectures come in a
large number of different variants and shapes, many of which are also manufactured by
several different companies.
Numerous microcontrollers have been developed for embedded systems use. General-
purpose microprocessors are also used in embedded systems, but generally require more
support circuitry than microcontrollers.
From simplest to most sophisticated they can be roughly grouped into the following areas:
4
Interactive resident debugging, using the simple shell provided by the embedded
operating system (e.g. Forth and Basic)
External debugging using logging or serial port output to trace operation using either
a monitor in flash or using a debug server like the Remedy Debugger which even works for
heterogeneous multicore systems.
A complete emulator provides a simulation of all aspects of the hardware, allowing all
of it to be controlled and modified, and allowing debugging on a normal PC. The downsides
are expense and slow operation, in some cases up to 100 times slower than the final system.
For SoC designs, the typical approach is to verify and debug the design on an FPGA
prototype board. Tools such as Certus [11] are used to insert probes in the FPGA RTL that
make signals available for observation. This is used to debug hardware, firmware and
software interactions across multiple FPGA with capabilities similar to a logic analyzer.
Unless restricted to external debugging, the programmer can typically load and run
software through the tools, view the code running in the processor, and start or stop its
operation. The view of the code may be as HLL source-code, assembly code or mixture of
both.
5
between the processor cores, which requires very low-level debugging, at signal/bus level,
with a logic analyzer, for instance.
1.5 RELIABILITY
Embedded systems often reside in machines that are expected to run continuously for
years without errors, and in some cases recover by themselves if an error occurs. Therefore,
the software is usually developed and tested more carefully than that for personal computers,
and unreliable mechanical moving parts such as disk drives, switches or buttons are avoided.
The system cannot safely be shut down for repair, or it is too inaccessible to repair.
Examples include space systems, undersea cables, navigational beacons, bore-hole
systems, and automobiles.
The system must be kept running for safety reasons. "Limp modes" are less tolerable.
Often backups are selected by an operator. Examples include aircraft navigation, reactor
control systems, safety-critical chemical factory controls, train signals.
The system will lose large amounts of money when shut down: Telephone switches,
factory controls, bridge and elevator controls, funds transfer and market making,
automated sales and service.
watchdog timer that resets the computer unless the software periodically notifies the
watchdog subsystems with redundant spares that can be switched over to software "limp
modes" that provide partial function
Designing with a Trusted Computing Base (TCB) architecture[12] ensures a highly secure
& reliable system environment
A hypervisor designed for embedded systems, is able to provide secure encapsulation for
any subsystem component, so that a compromised software component cannot interfere
with other subsystems, or privileged-level system software. This encapsulation keeps
faults from propagating from one subsystem to another, improving reliability. This may
also allow a subsystem to be automatically shut down and restarted on fault detection.
Immunity Aware Programming
6
1.6 TRACING
Real-time operating systems (RTOS) often supports tracing of operating system events. A
graphical view is presented by a host PC tool, based on a recording of the system behavior.
The trace recording can be performed in software, by the RTOS, or by special tracing
hardware. RTOS tracing allows developers to understand timing and performance issues of
the software system and gives a good understanding of the high-level system behaviors.
Commercial tools like RTXC Quadros or IAR Systems exists.
7
CHAPTER 2
2.1 INTRODUCTION
IoT is an expanding network of physical devices that are linked with different types of
sensors and with the help of connectivity to the internet, they are able to exchange data.
Through IoT, internet has now extended its roots to almost every possible thing present
around us and is no more limited to our personal computers and mobile phones. Safety, the
elementary concern of any project, has not been left untouched by IoT. Gas Leakages in open
or closed areas can prove to be dangerous and lethal. The traditional Gas Leakage Detector
Systems though have great precision, fail to acknowledge a few factors in the field of alerting
the people about the leakage. Therefore we have used the IoT technology to make a Gas
Leakage Detector having Smart Alerting techniques involving calling, sending text message
and an e-mail to the concerned authority and an ability to predict hazardous situation so that
people could be made aware in advance by performing data analytics on sensor readings.
8
2.3 WHAT IS IOT
The term “IoT” stands for the internet of things, can be defined as the interconnection
between the individually identifiable embedded computing apparatus in the accessible
internet infrastructure. The ‘IoT’ connects various devices and transportations with an help of
internet as well as electronic sensors. Please refer to this link to know more about Experts
Opinion on Application of Internet of Things (IoT) in Future.
9
CHAPTER 3
SOFTWARE REQUIREMENTS
Software used in this project for uploading code onto Arduino is Arduino IDE.
IDE stands for Integrated Development Environment. Pretty fancy sounding, and
should make you feel smart any time you use it. The IDE is a text editor-like program that
allows you to write Arduino code. When you open the Arduino program, you are opening the
IDE. It is intentionally streamlined to keep things as simple and straightforward as possible.
When you save a file in Arduino, the file is called a sketch – a sketch is where you save the
computer code you have written. The coding language that Arduino uses is very much like
C++ (“see plus plus”), which is a common language in the world of computing. The code you
learn to write for Arduino will be very similar to the code you write in any other computer
language – all the basic concepts remain the same – it is just a matter of learning a new
dialect should you pursue other programming languages.
The code you write is “human readable”, that is, it will make sense to you
(sometimes), and will be organized for a human to follow. Part of the job of the IDE is to take
the human readable code and translate it into machine-readable code to be executed by the
Arduino. This process is called compiling. The process of compiling is seamless to the user.
All you have to do is press a button. If you have errors in your computer code, the compiler
10
will display an error message at the bottom of the IDE and highlight the line of code that
seems to be the issue. The error message is meant to help you identify what you might have
done wrong – sometimes the message is very explicit, like saying, “Hey – you forget a
semicolon”, sometimes the error message is vague. Why be concerned with a semicolon you
ask? A semicolon is part of the Arduino language syntax, the rules that govern how the code
is written. It is like grammar in writing. Say for example we didn’t use periods when we
wrote – everyone would have a heck of a time trying to figure out when sentences started and
ended. Or if we didn’t employ the comma, how would we convey a dramatic pause to the
reader?
11
And let me tell you, if you ever had an English teacher with an overactive red pen, the
compiler is ten times worse. In fact – your programs WILL NOT compile without perfect
syntax. This might drive you crazy at first because it is very natural to forget syntax. As you
gain experience programming you will learn to be assiduous about coding grammar.
12
3.1.1 THE SEMICOLON
Int LedPin=9;
In this statement, I am assigning a value to an integer variable (we will cover this
later), notice the semicolon at the end. This tells the compiler that you have finished a chunk
of code and are moving on to the next piece. A semicolon is to Arduino code, as a period is to
a sentence. It signifies a complete statement.
Comments are what you use to annotate code. Good code is commented well.
Comments are meant to inform you and anyone else who might stumble across your code,
what the heck you were thinking when you wrote it. A good comment would be something
like this…
Now, in 3 months when I review this program, I know where to stick my LED. Comments
will be ignored by the compiler – so you can write whatever you like in them. If you have a
lot you need to explain, you can use a multi-line comment, shown below…
//This is an example
Comments are like the footnotes of code, except far more prevalent and not at the bottom of
the page.
13
Curly braces are used to enclose further instructions carried out by a function (we
discuss functions next). There is always an opening curly bracket and a closing curly bracket.
If you forget to close a curly bracket, the compiler will not like it and throw an error code .
3.1.4 FUNCTION ( )
Functions are pieces of code that are used so often that they are encapsulated in
certain keywords so that you can use them more easily. For example, a function could be the
following set of instructions…
What’s the deal with the parentheses following the function pinMode? Many
functions require arguments to work. An argument is information the function uses when it
runs. For our WashDog function, the arguments might be dog name and soap type, or
temperature and size of a bucket.
pinMode(13, OUTPUT);
The argument 13 refers to pin 13, and OUTPUT is the mode in which you want the
pin to operate. When you enter these arguments the terminology is called passing. You pass
14
the necessary information to the functions. Not all functions require arguments, but opening
and closing parentheses will stay regardless though empty.
Notice that the word OUTPUT is blue. There are certain keywords in Arduino that are
used frequently and the color blue helps identify them. The IDE turns them blue
automatically. Now we won’t get into it here, but you can easily make your own functions in
Arduino, and you can even get the IDE to color them for you. We will, however, talk about
the two functions used in nearly EVERY Arduino program.
The function, setup(), as the name implies, is used to set up the Arduino board. The Arduino
executes all the code that is contained between the curly braces of setup() only once. Typical
things that happen in setup() are setting the modes of pins, starting You might be wondering
what void means before the function setup(). Void means that the function does not return
information. Some functions do return values – our DogWash function might return the
number of buckets it required to clean the dog. The function analogRead() returns an integer
value between 0-1023. If this seems a bit odd now, don’t worry as we will cover every
common Arduino function in depth as we continue the course.
You have to love the Arduino developers because the function names are so telling.
As the name implies, all the code between the curly braces in loop() is repeated over and over
15
again – in a loop. The loop() function is where the body of your program will reside. As with
setup(), the function loop() does not return any values, therefore the word void precedes it.
Does it seem odd to you that the code runs in one big loop? This apparent lack of
variation is an illusion. Most of your code will have specific conditions laying in wait which
will trigger new actions.
If you have a temperature sensor connected to your Arduino for example, then when
the temperature gets to a predefined threshold you might have a fan kick on. The looping
code is constantly checking the temperature waiting to trigger the fan. So even though the
code loops over and over, not every piece of the code will be executed every iteration of the
loop.
Libraries are a collection of code that makes it easy for you to connect to a sensor,
display, module, etc. For example, the built-in LiquidCrystal library makes it easy to talk to
character LCD displays. There are hundreds of additional libraries available on the Internet
for download. The built-in libraries and some of these additional libraries are listed in the
reference. To use the additional libraries, you will need to install them.
Arduino libraries are managed in three different places: inside the IDE installation
folder, inside the core folder and in the libraries folder inside your sketchbook. The way
libraries are chosen during compilation is designed to allow the update of libraries present in
the distribution. This means that placing a library in the “libraries” folder in your sketchbook
overrides the other libraries versions.
The same happens for the libraries present in additional cores installations. It is also
important to note that the version of the library you put in your sketchbook may be lower
than the one in the distribution or core folders, nevertheless it will be the one used during
compilation. When you select a specific core for your board, the libraries present in the core’s
16
folder are used instead of the same libraries present in the IDE distribution folder.
Last, but not least important is the way the Arduino Software (IDE) upgrades itself:
all the files in Programs/Arduino (or the folder where you installed the IDE) are deleted and a
new folder is created with fresh content. This is why we recommend that you only install
libraries to the sketchbook folder so they are not deleted during the Arduino IDE update
process.
To install a new library into your Arduino IDE you can use the Library Manager
(available from IDE version 1.6.2). Open the IDE and click to the "Sketch" menu and
then Include Library > Manage Libraries.
Then the Library Manager will open and you will find a list of libraries that are
already installed or ready for installation. In this example we will install the Bridge library.
17
Scroll the list to find it, click on it, then select the version of the library you want to install.
Sometimes only one version of the library is available. If the version selection menu does not
appear, don't worry: it is normal.
Finally click on install and wait for the IDE to install the new library. Downloading
may take time depending on your connection speed. Once it has finished, an Installed tag
should appear next to the Bridge library. You can close the library manager. You can now
find the new library available in the Sketch > Include Library menu. If you want to add your
own library to Library Manager, follow these instructions.
If you're using a serial board, power the board with an external power supply (6 to 25
volts DC, with the core of the connector positive). Connect the board to a serial port on your
18
computer. On the USB boards, the power source is selected by the jumper between the USB
and power plugs. To power the board from the USB port (good for controlling low power
devices like LEDs), place the jumper on the two pins closest to the USB plug. To power the
board from an external power supply (needed for motors and other high current devices),
place the jumper on the two pins closest to the power plug. Either way, connect the board to a
USB port on your computer. On Windows, the Add New Hardware wizard will open; tell it
you want to specify the location to search for drivers and point to the folder containing the
USB drivers you unzipped in the previous step.
The content of circuits and Arduino sketches can vary greatly. Before you get started,
there is one simple process for uploading a sketch to an Arduino board that you can refer
back to.
The square end of the USB cable connects to your Arduino and the flat end connects to a
USB port on your computer.
You can also find all boards through this menu, such as the Arduino MEGA 2560 and
Arduino Leonardo.
You find a list of all the available serial ports by choosing Tools→Serial Port→ comX or
/dev/tty.usbmodemXXXXX. X marks a sequentially or randomly assigned number. In
Windows, if you have just connected your Arduino, the COM port will normally be the
highest number, such as com 3 or com 15.
Many devices can be listed on the COM port list, and if you plug in multiple Arduinos, each
one will be assigned a new number. On Mac OS X, the /dev/tty.usbmodem number will be
randomly assigned and can vary in length, such as /dev/tty.usbmodem1421 or
19
/dev/tty.usbmodem262471. Unless you have another Arduino connected, it should be the only
one visible.
This is the button that points to the right in the Arduino environment. You can also use the
keyboard shortcut Ctrl+U for Windows or Cmd+U for Mac OS X.
ThingSpeak has a close relationship with Mathworks, Inc. In fact, all of the ThingSpeak
documentation is incorporated into the Mathworks' Matlab documentation site and even
enabling registered Mathworks user accounts as valid login credentials on the ThingSpeak
website. The terms of service and privacy policy of ThingSpeak.com are between the
agreeing user and Mathworks, Inc.
20
CHAPTER 4
HARDWARE REQUIREMENTS
Hardware Components of this project are
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
21
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.
22
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.
23
4.1.3 FEATURES OF ARDUINO NANO
The Arduino Uno is a microcontroller board based on the ATmega328. Arduino is an open-
source, prototyping platform and its simplicity makes it ideal for hobbyists to use as well as
professionals. The Arduino Uno has 14 digital input/output pins (of which 6 can be used as
PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack,
an ICSP header, 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.
Microcontroller: ATmega328
Operating Voltage: 5V
Input Voltage (recommended): 7-12V
Input Voltage (limits): 6-20V
Digital I/O Pins: 14 (of which 6 provide PWM output)
Analog Input Pins: 6
DC Current per I/O Pin: 40 mA
DC Current for 3.3V Pin: 50 mA
Flash Memory: 32 KB of which 0.5 KB used by bootloader
SRAM: 2 KB (ATmega328)
EEPROM: 1 KB (ATmega328)
Clock Speed: 16 MHz
24
Fig 4.1 NodeMCU
NodeMCU was created shortly after the ESP8266 came out. On December 30,
2013, Espressif Systems began production of the ESP8266. The ESP8266 is a Wi-Fi SoC
integrated with a Tensilica Xtensa LX106 core, widely used in IoT applications (see related
projects). NodeMCU started on 13 Oct 2014, when Hong committed the first file of
nodemcu-firmware to GitHub. Two months later, the project expanded to include an open-
hardware platform when developer Huang R committed the gerber file of an ESP8266 board,
named devkit v0.9. Later that month, Tuan PM ported MQTT client library from Contiki to
the ESP8266 SoC platform, and committed to NodeMCU project, then NodeMCU was able
to support the MQTT IoT protocol, using Lua to access the MQTT broker. Another important
update was made on 30 Jan 2015, when Devsaurus ported the u8glib to NodeMCU
project, enabling NodeMCU to easily drive LCD, Screen, OLED, even VGA displays.
In summer 2015 the creators abandoned the firmware project and a group of independent but
dedicated contributors took over. By summer 2016 the NodeMCU included more than 40
different modules. Due to resource constraints users need to select the modules relevant for
their project and build a firmware tailored to their needs.
25
As Arduino.cc began developing new MCU boards based on non-AVR processors
like the ARM/SAM MCU and used in the Arduino Due, they needed to modify the Arduino
IDE so that it would be relatively easy to change the IDE to support alternate tool chains to
allow Arduino C/C++ to be compiled down to these new processors. They did this with the
introduction of the Board Manager and the SAM Core. A "core" is the collection of software
components required by the Board Manager and the Arduino IDE to compile an Arduino
C/C++ source file down to the target MCU's machine language. Some creative ESP8266
enthusiasts have developed an Arduino core for the ESP8266 WiFi SoC that is available at
the GitHub ESP8266 Core webpage. This is what is popularly called the "ESP8266 Core for
the Arduino IDE" and it has become one of the leading software development platforms for
the various ESP8266 based modules and development boards, including NodeMCUs.
NodeMCU provides access to the GPIO (General Purpose Input/Output) and for developing
purposes below pin mapping table from the API documentation should be referenced.
26
0 GPIO16 7 GPIO13
1 GPIO5 8 GPIO15
2 GPIO4 9 GPIO3
3 GPIO0 10 GPIO1
4 GPIO2 11 GPIO9
5 GPIO14 12 GPIO10
6 GPIO12
27
and clocks. LCD screens have replaced heavy, bulky cathode ray tube (CRT) displays in
nearly all applications. LCD screens are available in a wider range of screen sizes than CRT
and plasma displays, with LCD screens available in sizes ranging from tiny digital watches to
huge, big-screen television sets.
Since LCD screens do not use phosphors, they do not suffer image burn-in when a
static image is displayed on a screen for a long time (e.g., the table frame for an aircraft
schedule on an indoor sign). LCDs are, however, susceptible to image persistence.[2] The
LCD screen is more energy-efficient and can be disposed of more safely than a CRT can. Its
low electrical power consumption enables it to be used in battery-
powered electronic equipment more efficiently than CRTs can be. By 2008, annual sales of
televisions with LCD screens exceeded sales of CRT units worldwide, and the CRT became
obsolete for most purposes.
A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In
this LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers,
namely, Command and Data.
28
The command register stores the command instructions given to the LCD. A
command is an instruction given to LCD to do a predefined task like initializing it, clearing
its screen, setting the cursor position, controlling display etc. The data register stores the data
to be displayed on the LCD. The data is the ASCII value of the character to be displayed on
the LCD. Click to learn more about internal structure of a LCD.
Pin
Function Name
No
1 Ground (0V) Ground
2 Supply voltage; 5V (4.7V – 5.3V) Vcc
3 Contrast adjustment; through a variable resistor VEE
Selects command register when low; and data register Register
4
when high Select
29
5 Low to write to the register; High to read from the register Read/write
6 Sends data to data pins when a high to low pulse is given Enable
7 DB0
8 DB1
9 DB2
10 DB3
8-bit data pins
11 DB4
12 DB5
13 DB6
14 DB7
15 Backlight VCC (5V) Led+
16 Backlight Ground (0V) Led-
Low cost
3 to 5V power and I/O
30
2.5mA max current use during conversion (while requesting data)
Good for 20-80% humidity readings with 5% accuracy
Good for 0-50°C temperature readings ±2°C accuracy
No more than 1 Hz sampling rate (once every second)
Body size 15.5mm x 12mm x 5.5mm
4 pins with 0.1" spacing
External power supplies are used both with equipment with no other source of power
and with battery-powered equipment, where the supply, when plugged in, can sometimes
charge the battery in addition to powering the equipment.
31
Fig 4.5 9V, 1Ampere Adapter
32
losses; and the switching regulator can be much more efficient than a linear regulator. The
result is a much more efficient, smaller, and lighter device. Safety is ensured, as in the older
linear circuit, because there is still a transformer which electrically isolates the output from
the mains.
A linear circuit must be designed for a specific, narrow range of input voltages (e.g.,
220–240 VAC) and must use a transformer appropriate for the frequency (usually 50 or
60 Hz), but a switched-mode supply can work efficiently over a very wide range of voltages
and frequencies; a single 100–240 VAC unit will handle almost any mains supply in the
world.
However, unless very carefully designed and using suitable components, switching
adapters are more likely to fail than the older type, due in part to complex circuitry and the
use of semiconductors. Unless designed well, these adapters may be easily damaged by
overloads, even transient ones, which can come from lightning, brief mains overvoltage
(sometimes caused by an incandescent light on the same power circuit failing), component
degradation, etc. A very common mode of failure is due to the use of electrolytic
capacitors whose equivalent series resistance (ESR) increases with age; switching regulators
are very sensitive to high ESR (the older linear circuit also used electrolytic capacitors, but
the effect of degradation is much less dramatic). Well-designed circuits pay attention to the
ESR, ripple current rating, pulse operation, and temperature rating of capacitors.
Safety – External power adapters can free product designers from worrying about some
safety issues. Much of this style of equipment uses only voltages low enough not to be
a safety hazard internally, although the power supply must out of necessity use dangerous
mains voltage. If an external power supply is used (usually via a power connector, often
of coaxial type), the equipment need not be designed with concern for hazardous voltages
inside the enclosure. This is particularly relevant for equipment with lightweight cases
which may break and expose internal electrical parts.
33
Heat reduction – Heat reduces reliability and longevity of electronic components, and can
cause sensitive circuits to become inaccurate or malfunction. A separate power supply
removes a source of heat from the apparatus.
Electrical noise reduction – Because radiated electrical noise falls off with the square of
the distance, it is to the manufacturer's advantage to convert potentially noisy AC line
power or automotive power to "clean", filtered DC in an external adapter, at a safe
distance from noise-sensitive circuitry.
Weight and size reduction – Removing power components and the mains connection plug
from equipment powered by rechargeable batteries reduces the weight and size which
must be carried.
Ease of replacement – Power supplies are more prone to failure than other circuitry due
to their exposure to power spikes and their internal generation of waste heat. External
power supplies can be replaced quickly by a user without the need to have the powered
device repaired.
Problems with this type of power supply include, but are not limited to:
34
Size – Power supplies which plug into the mains directly without using a plug on a cable
(true wall warts) are bulkier than bare plugs; sometimes they are too large to plug into
power sockets with restricted space, or into adjacent sockets on power strips (due to the
fact that they can block other plugs also).
Weight – Some AC adapters can be heavy, exerting excess weight on the power socket
(this depends on the socket design of the country in question). Some external power
supplies are "power bricks" (also known as "line lumps") having a short AC cord so they
can lie on the floor, thus relieving strain, at the expense of clutter. Other wall-hanging
types are made long and thin, minimizing the leverage of their weight vector that pulls
the plug out, but exacerbating the size problem. The weight for equipment that must be
carried (e.g. for traveling) is not a disadvantage of external supplies, as the alternative is
an equally heavy internal supply; but in many cases a single universal supply could
replace several proprietary ones.
Inefficiency – Some idling power is wasted as the power supply is left running when the
equipment power switch is off or the equipment is disconnected from the power supply.
In recent years it has become common for equipment with internal supplies to share this
problem due to the use of a "soft" power switch.
Confusion – External power supplies are often generic and not clearly marked to identify
the equipment they are designed to power. It is very easy to separate power supply and
equipment, and can be difficult to re-match the many devices with their power supplies.
Compatibility problems – There is no standardization of connectors; the same connector
is often used for different voltages, and for both DC supplies and AC-to-AC
transformers. Incompatible voltage or polarity may be present on physically
interchangeable connectors. This easily leads to using the wrong power supply, which
can destroy equipment.
4.5.4 DANGEROUS AND UNRELIABLE ADAPTERS
35
(e.g. poor regulation and ripple, maximum power capacity lower than specified, hot running),
unreliability (e.g. overheating to temperatures exceeding component ratings), and electrical or
fire danger to users (e.g. insulation which frays with wear, lack of fuse).
Spurious marks of conformity to standards may be present; in one case it was reported
that "Chinese manufacturers were submitting well-engineered electrical products to obtain
conformity testing reports, but then removing non-essential components in production to
reduce costs". A test of 27 chargers found that all the eight legitimately branded with a
reputable name met safety standards, but none of those unbranded or with minor names did,
despite bearing the mark of conformity.
Some universal adapters automatically set their output voltage and maximum current
according to which of a range of interchangeable tips is fitted; tips are available to fit and
supply appropriate power to many notebook computers and mobile devices. Different tips
may use the same connector, but automatically supply different power; it is essential to use
the right tip for the apparatus being powered, but no switch needs to be set correctly by the
user. The advent of switch-mode power supplies has allowed adapters to work from any AC
mains supply from 100 to 240V with an appropriate plug; operation from standard 12V DC
36
vehicle and aircraft supplies can also be supported. With the appropriate adapter, accessories,
and tips, a variety of equipment can be powered from almost any source of power.
A "Green Plug" system has been proposed, based on USB technology, by which the
consuming device would tell the external power supply what kind of power is needed.
"GSM" is a trademark owned by the GSM Association. It may also refer to the (initially)
most common voice codec used, Full Rate.
37
Fig 4.5 SIM900A GSM MODULE
GSM is a cellular network, which means that cell phones connect to it by searching
for cells in the immediate vicinity. There are five different cell sizes in a GSM network—
macro, micro, pico, femto, and umbrella cells. The coverage area of each cell varies
according to the implementation environment. Macro cells can be regarded as cells where
the base station antenna is installed on a mast or a building above average rooftop level.
Micro cells are cells whose antenna height is under average rooftop level; they are typically
used in urban areas. Picocells are small cells whose coverage diameter is a few dozen meters;
they are mainly used indoors. Femtocells are cells designed for use in residential or small
business environments and connect to the service provider’s network via a broadband internet
connection. Umbrella cells are used to cover shadowed regions of smaller cells and fill in
gaps in coverage between those cells.
Cell horizontal radius varies depending on antenna height, antenna gain, and
propagation conditions from a couple of hundred meters to several tens of kilometres. The
longest distance the GSM specification supports in practical use is 35 kilometres (22 mi).
There are also several implementations of the concept of an extended cell, [16] where the cell
38
radius could be double or even more, depending on the antenna system, the type of terrain,
and the timing advance.
Indoor coverage is also supported by GSM and may be achieved by using an indoor
picocell base station, or an indoor repeater with distributed indoor antennas fed through
power splitters, to deliver the radio signals from an antenna outdoors to the separate indoor
distributed antenna system. These are typically deployed when significant call capacity is
needed indoors, like in shopping centers or airports. However, this is not a prerequisite, since
indoor coverage is also provided by in-building penetration of the radio signals from any
nearby cell.
For comparison, most 3G networks in Europe operate in the 2100 MHz frequency
band. For more information on worldwide GSM frequency usage, see GSM frequency bands.
GSM has used a variety of voice codecs to squeeze 3.1 kHz audio into between 6.5
and 13 kbit/s. Originally, two codecs, named after the types of data channel they were
39
allocated, were used, called Half Rate (6.5 kbit/s) and Full Rate (13 kbit/s). These used a
system based on linear predictive coding (LPC). In addition to being efficient with bitrates,
these codecs also made it easier to identify more important parts of the audio, allowing the air
interface layer to prioritize and better protect these parts of the signal. GSM was further
enhanced in 1997[17] with the Enhanced Full Rate (EFR) codec, a 12.2 kbit/s codec that uses a
full-rate channel. Finally, with the development of UMTS, EFR was refactored into a
variable-rate codec called AMR-Narrowband, which is high quality and robust against
interference when used on full-rate channels, or less robust but still relatively high quality
when used in good radio conditions on half-rate channel.
One of the key features of GSM is the Subscriber Identity Module, commonly known
as a SIM card. The SIM is a detachable smart card containing the user's subscription
information and phone book. This allows the user to retain his or her information after
switching handsets. Alternatively, the user can also change operators while retaining the
handset simply by changing the SIM. Some operators will block this by allowing the phone to
use only a single SIM, or only a SIM issued by them; this practice is known as SIM locking.
GSM was intended to be a secure wireless system. It has considered the user
authentication using a pre-shared key and challenge-response, and over-the-air encryption.
However, GSM is vulnerable to different types of attack, each of them aimed at a different
part of the network.
GSM uses several cryptographic algorithms for security. The A5/1, A5/2,
and A5/3 stream ciphers are used for ensuring over-the-air voice privacy. A5/1 was
developed first and is a stronger algorithm used within Europe and the United States; A5/2 is
weaker and used in other countries. Serious weaknesses have been found in both algorithms:
it is possible to break A5/2 in real-time with a ciphertext-only attack, and in January
40
2007, The Hacker's Choice started the A5/1 cracking project with plans to use FPGAs that
allow A5/1 to be broken with a rainbow table attack. The system supports multiple
algorithms so operators may replace that cipher with a stronger one.
Since 2000, different efforts have been made in order to crack the A5 encryption
algorithms. Both A5/1 and A5/2 algorithms have been broken, and their cryptanalysis has
been revealed in the literature. As an example, Karsten Nohl (de) developed a number
of rainbow tables (static values which reduce the time needed to carry out an attack) and have
found new sources for known plaintext attacks. He said that it is possible to build "a full
GSM interceptor...from open-source components" but that they had not done so because of
legal concerns. Nohl claimed that he was able to intercept voice and text conversations by
impersonating another user to listen to voicemail, make calls, or send text messages using a
seven-year-old Motorola cellphone and decryption software available for free online.
New attacks have been observed that take advantage of poor security implementations,
architecture, and development for smartphone applications. Some wiretapping and
eavesdropping techniques hijack the audio input and output providing an opportunity for a
third party to listen in to the conversation.
GSM uses General Packet Radio Service (GPRS) for data transmissions like browsing
the web. The most commonly deployed GPRS ciphers were publicly broken in 2011.
The researchers revealed flaws in the commonly used GEA/1 and GEA/2 ciphers and
published the open-source "gprsdecode" software for sniffing GPRS networks. They also
noted that some carriers do not encrypt the data (i.e., using GEA/0) in order to detect the use
of traffic or protocols they do not like (e.g., Skype), leaving customers unprotected. GEA/3
seems to remain relatively hard to break and is said to be in use on some more modern
networks. If used with USIM to prevent connections to fake base stations and downgrade
attacks, users will be protected in the medium term, though migration to 128-bit GEA/4 is
still recommended.
The MQ series of gas sensors utilizes a small heater inside with an electro chemical
sensor these sensors are sensitive to a range of gasses are used at room temperature. MQ 2
alcohol sensor is a Sno2 with a lower conductivity of clean air. When the target explosive gas
exists, then the sensor’s conductivity increases more increasing more along with the gas
41
concentration rising levels. By using simple electronic circuits, it converts the charge of
conductivity to correspond output signal of gas concentration
The MQ 2 SMOKE sensor has high sensitivity in ammonia, sulfide, benze steam,
smoke and in other harm full gas. It is low cost and suitable for different applications. There
are different types of GAS sensors like MQ-2, MQ-3, MQ-4, MQ-5, MQ-6, etc.
An SMOKE sensor detects the attentiveness of SMOKE gas in the air and an analog
voltage is an output reading. The sensor can activate at temperatures ranging from -10 to 50°
C with a power supply is less than 150 Ma to 5V. The sensing range is from 0.04 mg/L to 4
mg/L..
The MQ-2 gas sensor consists of total 6-pins including A, H, B and the other three
pins are A, H, B out of the total 6-pins we use only 4 pins. The two pins A, H are used for the
heating purpose and the other two pins are used for the ground and power. There is a heating
system inside the sensor, which is made up of aluminium oxide, tin dioxide. It has heat coils
to produce heat, and thus it is used as a heat sensor. The below diagram shows the pin
diagram and the configuration of the MQ-2 sensor.
4.7.4 FEATURES
42
Stable and long life
A load cell is a transducer that is used to create an electrical signal whose magnitude
is directly proportional to the force being measured. The various load cell types include
hydraulic, pneumatic, and strain gauge.
Strain gauge load cells are the most common in industry. These load cells are
particularly stiff, have very good resonance values, and tend to have long life cycles in
application. Strain gauge load cells work on the principle that the strain gauge (a planar
resistor) deforms when the material of the load cells deforms appropriately. Deformation of
the strain gauge changes its electrical resistance, by an amount that is proportional to the
strain. The change in resistance of the strain gauge provides an electrical value change that is
calibrated to the load placed on the load cell.
A load cell usually consists of four strain gauges in a Wheatstone bridge configuration. Load
cells of one strain gauge (quarter bridge) or two strain gauges (half bridge) are also
available. The electrical signal output is typically in the order of a few millivolts (mV) and
requires amplification by an instrumentation amplifier before it can be used. The output of
the transducer can be scaled to calculate the force applied to the transducer. Sometimes a high
resolution ADC, typically 24-bit, can be used directly.
43
4.8.2 COMMON TYPES OF LOAD CELL
Shear beam, a straight block of material fixed on one end and loaded on the other
Bending beam, a compact, extremely versatile load cell that can easily fit into
components where space is limited. These devices are commonly used in industrial and
commercial measurement applications.
Pancake, low-profile compression and wheel tension load cells that have a wide surface
area for absorbing shock loads.
Single point / platform load cells, allow the construction of a weighing scale or machine
with only one load cell. Used in small / medium sized platform scales.
Double-ended shear beam, a straight block of material fixed at both ends and loaded in
the center
Compression load cell, a block of material designed to be loaded at one point or area in
compression
S-type load cell, a S-shaped block of material that can be used in both compression and
tension (load links and tension load cells are designed for tension only)
Rope clamps, an assembly attached to a rope and measures its tension. Rope clamps are
popular in hoist, crane and elevator applications due to the ease of their installation; they
have to be designed for a large range of loads, including dynamic peak loads, so their
output for the rated load tends to be lower than of the other types
44
Load pin, used for sensing loads on e.g. axles
Load cells are an integral part of most weighing systems in industrial, aerospace and
automotive industries, enduring rigorous daily use. Over time, load cells will drift, age and
misalign therefore they will need to be calibrated regularly to ensure accurate results are
maintained. ISO9000 and most other standards specify a maximum period of around 18
months to 2 years between re-calibration procedures, dependant on the level of load cell
deterioration. Annual re-calibration is considered best practice by many load cell users for
ensuring the most accurate measurements.
Standard calibration tests will use linearity and repeatability as a calibration guideline
as these are both used to determine accuracy. Calibration is conducted incrementally starting
working in ascending or descending order. For example, if you have a 60 tonne load cell,
then you way use specific test weights that measure in 5, 10, 20, 40 and 60 tonne increments
– A five step calibration process is usually sufficient for ensuring your device is accurately
calibrated. Repeating this five-step calibration procedure 2-3 times is recommended for
consistent results.
CHAPTER 5
PROGRAM CODE
45
5.1 ARDUINO CODE
#include <LiquidCrystal.h>
#include "HX711.h"
HX711 scale;
void setup() {
pinMode(8,INPUT);
pinMode(9,OUTPUT);
Serial.begin(9600);
Serial.println("ATE1");
Serial.println("AT+CNMI=2,2,0,0,0");
scale.begin(A1, A0);
scale.read();
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.setCursor(0,1);
lcd.print("MONITORING SYSTM");
delay(3000);
46
lcd.clear();
scale.tare();
lcd.setCursor(0,0);
lcd.setCursor(0,1);
delay(15000);
lcd.clear();
void loop(){
w=scale.get_units(10)*5.7286;
if(w>400)
lcd.clear();
lcd.setCursor(0,0);
//digitalWrite(8,HIGH);
digitalWrite(9,HIGH);
delay(100);
47
}
if((w>300)&&(w<400))
lcd.clear();
lcd.setCursor(0,0);
//digitalWrite(8,LOW);
digitalWrite(9,HIGH);
delay(100);
if((w>200)&&(w<300))
lcd.clear();
lcd.setCursor(0,0);
//digitalWrite(8,HIGH);
digitalWrite(9,LOW);
delay(100);
if(w<100)
48
{
lcd.clear();
lcd.setCursor(0,0);
//digitalWrite(8,LOW);
digitalWrite(9,LOW);
book();
lcd.clear();
lcd.setCursor(0,0);
lcd.setCursor(0,1);
delay(100);
if(digitalRead(8)==LOW)
Serial.println("AT");
delay(500);
Serial.println("AT+CMGF=1");
49
delay(500);
Serial.print("AT+CMGS=");
Serial.print('"');
Serial.println('"');
delay(500);
Serial.write(26);
delay(1000);
void book()
Serial.println("AT");
delay(500);
Serial.println("AT+CMGF=1");
50
delay(500);
Serial.print("AT+CMGS=");
Serial.print('"');
Serial.println('"');
delay(500);
Serial.write(26);
delay(12000);
Serial.println("AT");
delay(500);
Serial.println("AT+CMGF=1");
delay(500);
Serial.print("AT+CMGS=");
Serial.print('"');
51
Serial.println('"');
delay(500);
Serial.write(26);
delay(10000);
#include "ThingSpeak.h"
#include "secrets.h"
#include <ESP8266WiFi.h>
int keyIndex = 0; // your network key Index number (needed only for WEP)
WiFiClient client;
#define gas D5
52
int level, leak;
void setup() {
pinMode(D1,INPUT);
pinMode(D7,INPUT);
pinMode(D6,OUTPUT);
digitalWrite(D6,HIGH);
pinMode(gas, INPUT);
WiFi.mode(WIFI_STA);
void loop() {
if(WiFi.status() != WL_CONNECTED){
53
Serial.println(SECRET_SSID);
while(WiFi.status() != WL_CONNECTED){
Serial.print(".");
delay(5000);
Serial.println("\nConnected.");
if(digitalRead(gas)==LOW){
leak = 100;
digitalWrite(D6,LOW);}
if(digitalRead(gas)==HIGH){
leak = 0;
digitalWrite(D6,HIGH);}
/* if((digitalRead(D1)==HIGH)&&(digitalRead(D7)==HIGH))
level=100;
if((digitalRead(D1)==LOW)&&(digitalRead(D7)==HIGH))
54
level=75;
if((digitalRead(D1)==HIGH)&&(digitalRead(D7)==LOW))
level=50;
if((digitalRead(D1)==LOW)&&(digitalRead(D7)==LOW))
level=20;*/
if(leak == 100){
/* if(level==100)
if(level==75)
if(level==50)
if(level==20)*/
ThingSpeak.setField(1, temp);
ThingSpeak.setField(2, humi);
ThingSpeak.setField(3, leak);
// ThingSpeak.setField(4, level);
55
// set the status
ThingSpeak.setStatus(myStatus);
if(x == 200){
else{
CHAPTER 6
RESULT OF THE PROJECT
56
THINGSPEAK IOT PLATFORM
CHAPTER 7
57
CONCLUSION
Therefore, we have used the IoT technology to make a Gas Leakage Detector having
Smart Alerting techniques involving calling, sending text message and an e-mail to the
concerned authority and an ability to predict hazardous situation so that people could be
made aware in advance by performing data analytics on sensor readings.
BIBLIOGRAPHY
58
Ahmad, N.A.N. and Zamri, S.A.S., 2014, September. The cross platform application
development adapted Spring framework to support front-end tendering services. In
Computer, Communications, and Control Technology (I4CT), 2014 International Conference
on (pp. 58-62). IEEE.
Alarcon, R. and Wilde, E., 2010, April. Linking data from restful services. In Third
Workshop on Linked Data on the Web, Raleigh, North Carolina (April 2010).
Anthes, G., 2012. HTML5 leads a web revolution. Communications of the ACM, 55(7),
pp.16-17.
Armando, A., Carbone, R., Chekole, E.G. and Ranise, S., 2014, June. Attribute based access
control for APIs in spring security. In Proceedings of the 19th ACM symposium on Access
control models and technologies (pp. 85-88). ACM.
Atighetchi, M., Soule, N., Pal, P., Loyall, J., Sinclair, A. and Grant, R., 2013, October. Safe
configuration of TLS connections. In Communications and Network Security (CNS), 2013
IEEE Conference on (pp. 415- 422). IEEE.
Bormann, C., Castellani, A.P. and Shelby, Z., 2012. Coap: An application protocol for
billions of tiny internet nodes. IEEE Internet Computing, 16(2), p.62.
59