Nothing Special   »   [go: up one dir, main page]

0% found this document useful (0 votes)
8 views59 pages

Iot Gas Monitoring

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 59

CHAPTER 1

INTRODUCTION TO EMBEDDED SYSTEMS

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.

An embedded computer is frequently a computer that is implemented for a particular


purpose. In contrast, an average PC computer usually serves a number of purposes: checking
email, surfing the internet, listening to music, word processing, etc... However, embedded
systems usually only have a single task, or a very small number of related tasks that they are
programmed to perform.

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.

Embedded computers rarely have a generic interface, however. Even if embedded


systems have a keypad and an LCD display, they are rarely capable of using many different
types of input or output. An example of an embedded system with I/O capability is a security
alarm with an LCD status display, and a keypad for entering a password.

An embedded system can be defined as a control system or computer system designed


to perform a specific task. Common examples of embedded systems include MP3 players,
navigation systems on aircraft and intruder alarm systems. An embedded system can also be
defined as a single purpose computer.

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

Embedded systems are commonly found in consumer, cooking, industrial,


automotive, medical, commercial and military applications.

Telecommunications systems employ numerous embedded systems from telephone


switches for the network to cell phones at the end user. Computer networking uses
dedicated routers and network bridges to route data.

Consumer electronics include MP3 players, mobile phones, videogame


consoles, digital cameras, GPS receivers, and printers. Household appliances, such
as microwave ovens, washing machines and dishwashers, include embedded systems to
provide flexibility, efficiency and features. Advanced HVAC systems use
networked thermostats to more accurately and efficiently control temperature that can change
by time of day and season. Home automation uses wired- and wireless-networking that can
be used to control lights, climate, security, audio/visual, surveillance, etc., all of which use
embedded devices for sensing and controlling.

Transportation systems from flight to automobiles increasingly use embedded


systems. New airplanes contain advanced avionics such as inertial guidance
systems and GPS receivers that also have considerable safety requirements. Various electric
motors brushless DC motors, induction motors and DC motors use electric/electronic motor
controllers. Automobiles, electric vehicles, and hybrid vehicles increasingly use embedded
systems to maximize efficiency and reduce pollution. Other automotive safety systems
include anti-lock braking system (ABS), Electronic Stability Control (ESC/ESP), traction
control (TCS) and automatic four-wheel drive.

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.

1.3PROCESSORS IN EMBEDDED SYSTEMS

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.

1.4 DEBUGGING IN EMBEDDED SYSTEMS

Embedded debugging may be performed at different levels, depending on the


facilities available. The different metrics that characterize the different forms of embedded
debugging are: does it slow down the main application, how close is the debugged system or
application to the actual system or application, how expressive are the triggers that I can set
for debugging (e.g., I want to inspect the memory when a particular program counter value is
reached), and what can I inspect in the debugging process (such as, only memory, or memory
and registers, etc.).

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.

An in-circuit debugger (ICD), a hardware device that connects to the microprocessor


via a JTAG or Nexus interface. This allows the operation of the microprocessor to be
controlled externally, but is typically restricted to specific debugging capabilities in the
processor.

An in-circuit emulator (ICE) replaces the microprocessor with a simulated equivalent,


providing full control over all aspects of the microprocessor.

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.

Because an embedded system is often composed of a wide variety of elements, the


debugging strategy may vary. For instance, debugging a software- (and microprocessor-)
centric embedded system is different from debugging an embedded system where most of the
processing is performed by peripherals (DSP, FPGA, and co-processor). An increasing
number of embedded systems today use more than one single processor core. A common
problem with multi-core development is the proper synchronization of software execution. In
such a case, the embedded system design may wish to check the data traffic on the busses

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.

Specific reliability issues may include:

 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.

A variety of techniques are used, sometimes in combination, to recover from errors—


both software bugs such as memory leaks, and also soft errors in the hardware:

 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

IOT GAS MONITORING LEAKAGE DETECTION, BOOKING


SYSTEM

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.

2.2 CIRCUIT DIAGRAM

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.

3.1 INTRODUCTION TO 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

A semicolon needs to follow every statement written in the Arduino programming


language. For example, …

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.

3.1.2 THE DOUBLE BACKSLASH FOR SINGLE LINE COMMENTS //

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.

3.1.3 THE CURLY BRACES

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 .

Void loop (){

Remember – no curly brace may go unclosed!

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…

This set of simple instructions could be encapsulated in a function that we call


WashDog. Every time we want to carry out all those instructions we just type WashDog and
voila – all the instructions are carried out. In Arduino, there are certain functions that are used
so often they have been built into the IDE. When you type them, the name of the function
will appear orange. The function pinMode(), for example, is a common function used to
designate the mode of an Arduino pin.

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.

3.1.5 VOID SETUP ( )

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.

Let us review a couple things you should know about setup()…

1. setup() only runs once.

2. setup() needs to be the first function in your Arduino sketch.

3. setup() must have opening and closing curly braces.

3.1.6 VOID LOOP ( )

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.

3.2 INTRODUCTION ARDUINO LIBRARIES

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.

3.2.1 HOW TO INSTALL A LIBRARY

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.

3.3 HOW TO CONNECT ARDUINO BOARD

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 power LED should go on.

3.4 HOW TO UPLOAD A PROGRAM

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.

Follow these steps to upload your sketch:

1. Connect your Arduino using the USB cable.

The square end of the USB cable connects to your Arduino and the flat end connects to a
USB port on your computer.

2. Choose Tools→Board→Arduino Uno to find your board in the Arduino menu.

You can also find all boards through this menu, such as the Arduino MEGA 2560 and
Arduino Leonardo.

3. Choose the correct serial port for your board.

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.

4. Click the Upload button.

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.

3.5 THINGSPEAK IOT PLATFORM

According to its developers, "ThingSpeak is an open-source Internet of Things (IoT)


application and API to store and retrieve data from things using the HTTP protocol over the
Internet or via a Local Area Network. ThingSpeak enables the creation of sensor logging
applications, location tracking applications, and a social network of things with status
updates".

ThingSpeak was originally launched by ioBridge in 2010 as a service in support of IoT


applications.

ThingSpeak has integrated support from the numerical computing


software MATLAB from MathWorks, allowing ThingSpeak users to analyze and visualize
uploaded data using Matlab without requiring the purchase of a Matlab license from
Mathworks.

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

1. Arduino UNO with ATmega328P Microcontroller


2. NODEMCU
3. 16X 2 LCD MODULE
4. DHT11 SENSOR
5. 12V 2A ADAPTOR
6. SIM900A GSM MODEM
7. MQ2 GAS SENSOR
8. LOAD CELL

4.1 INTRODUCTION TO ARDUINO UNO


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

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.

4.1.1 WHY ARDUINO

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.

4.1.2 ADVANTAGES OF ARDUINO UNO

 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.

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.

Features of the Arduino:

 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

4.2 INTRODUCTION TO NODEMCU

NodeMCU is an open source IoT platform It includes firmware which runs on


the ESP8266 Wi-Fi SoC from Espressif Systems, and hardware which is based on the ESP-12
module. The term "NodeMCU" by default refers to the firmware rather than the development
kits. The firmware uses the Lua scripting language. It is based on the eLua project, and built
on the Espressif Non-OS SDK for ESP8266. It uses many open source projects

24
Fig 4.1 NodeMCU

4.2.1 HISTORY OF 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.

4.2.2 ESP8266 ARDUINO CORE

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.

4.2.3 FEATURES OF NODEMCU

 Finally, programable WiFi module.


 Arduino-like (software defined) hardware IO.
 Can be programmed with the simple and powerful Lua programming language or
Arduino IDE.
 USB-TTL included, plug & play.
 10 GPIOs D0-D10, PWM functionality, IIC and SPI communication, 1-Wire and ADC
A0 etc. all in one board.
 Wifi networking (can be used as access point and/or station, host a web server), connect
to internet to fetch or upload data.
 Event-driven API for network applications.
 PCB antenna.
4.2.4 NODEMCU PIN DESCRIPTION

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.

IO index ESP8266 pin IO index ESP8266 pin

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

4.3 INTRODUCTION TO 16X2 LCD

A liquid-crystal display (LCD) is a flat-panel display or other electronically


modulated optical device that uses the light-modulating properties of liquid crystals. Liquid
crystals do not emit light directly, instead using a backlight or reflector to produce images in
color or monochrome.[1] LCDs are available to display arbitrary images (as in a general-
purpose computer display) or fixed images with low information content, which can be
displayed or hidden, such as preset words, digits, and 7-segment displays, as in a digital
clock. They use the same basic technology, except that arbitrary images are made up of a
large number of small pixels, while other displays have larger elements.

LCDs are used in a wide range of applications including computer


monitors, televisions, instrument panels, aircraft cockpit displays, and indoor and outdoor
signage. Small LCD screens are common in portable consumer devices such as digital
cameras, watches, calculators, and mobile telephones, including smartphones. LCD screens
are also used on consumer electronics products such as DVD players, video game devices

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.

Fig 4.3 16 x 2 LCD

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.

Fig 4.4 PIN DIAGRAM OF 16 X 2 LCD

4.3.1 LCD PIN DESCRIPTION

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-

4.4 INTRODUCTION TO DHT 11 SENSOR

The DHT11 is a basic, ultra-low-cost digital temperature and humidity sensor. It


uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and
spits out a digital signal on the data pin (no analog input pins needed). Its fairly simple to
use, but requires careful timing to grab data. The only real downside of this sensor is you
can only get new data from it once every 2 seconds, so when using our library, sensor
readings can be up to 2 seconds old.

4.4.1 TECHNICAL DETAILS

 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

4.5 INTRODUCTION TO ADAPTORS

An AC adapter, AC/DC adapter, or AC/DC converter[1] is a type of external power


supply, often enclosed in a case similar to an AC plug. Other common names include plug
pack, plug-in adapter, adapter block, domestic mains adapter, line power adapter, wall
wart, power brick, and power adapter. Adapters for battery-powered equipment may be
described as chargers or rechargers (see also battery charger). AC adapters are used with
electrical devices that require power but do not contain internal components to derive the
required voltage and power from mains power. The internal circuitry of an external power
supply is very similar to the design that would be used for a built-in or internal supply.

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.

Use of an external power supply allows portability of equipment powered either by


mains or battery without the added bulk of internal power components, and makes it
unnecessary to produce equipment for use only with a specified power source; the same
device can be powered from 120 VAC or 230 VAC mains, vehicle or aircraft battery by using
a different adapter.

31
Fig 4.5 9V, 1Ampere Adapter

4.5.1 MODES OF OPERATIONS


Originally, most AC/DC adapters were linear power supplies, containing
a transformer to convert the mains electricity voltage to a lower voltage, a rectifier to convert
it to pulsating DC, and a filter to smooth the pulsating waveform to DC, with
residual ripple variations small enough to leave the powered device unaffected. Size and
weight of the device was largely determined by the transformer, which in turn was
determined by the power output and mains frequency. Ratings over a few watts made the
devices too large and heavy to be physically supported by a wall outlet. The output voltage of
these adapters varied with load; for equipment requiring a more stable voltage, linear voltage
regulator circuitry was added. Losses in the transformer and the linear regulator were
considerable; efficiency was relatively low, and significant power dissipated as heat even
when not driving a load.

In the early twenty-first century, switched-mode power supplies (SMPSs) became


almost ubiquitous for this purpose. Mains voltage is rectified to a high direct voltage driving
a switching circuit, which contains a transformer operating at a high frequency and outputs
direct current at the desired voltage. The high-frequency ripple is more easily filtered out than
mains-frequency. The high frequency allows the transformer to be small, which reduces its

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.

4.5.2 ADAVANTAGES OF ADAPTER


External AC adapters are widely used to power small or portable electronic devices. The
advantages include:

 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.

 Configuration versatility – Externally powered electronic products can be used with


different power sources as needed (e.g. 120VAC, 240VAC, 12VDC, or external battery
pack), for convenient use in the field, or when traveling.
 Simplified product inventory, distribution, and certification – An electronic product that
is sold and used internationally must be powered from a wide range of power sources,
and must meet product safety regulations in many jurisdictions, usually requiring
expensive certification by national or regional safety agencies such as Underwriters
Laboratories or Technischer Überwachungsverein. A single version of a device may be
used in many markets, with the different power requirements met by different external
power supplies, so that only one version of the device need be manufactured, stocked,
and tested. If the design of the device is modified over time (a frequent occurrence), the
power supply design itself need not be retested (and vice versa).
 Constant voltage is produced by a specific type of adapter used
for computers and laptops. These types of adapters are commonly known as eliminators.
4.5.3 PROBLEMS WITH ADAPTER

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

Manufacturers of equipment supplied with AC adapters often supply replacements at


high prices; this has encouraged the manufacture of compatible third-
party aftermarket replacements, which may be of satisfactory quality and performance at
significantly lower prices. However, some adapters, usually at very low prices, and
sometimes with unknown brands or sometimes fraudulently marked with the name of a
reputable manufacturer, have various deficiencies which can cause inadequate performance

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.

Fig 4.6 Circuit diagram for 9V, 1 Amp Adapter

4.5.5 AUTO SENSING ADAPTERS

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.

4.6 INTRODUCTION TO GSM

GSM (Global System for Mobile Communications, originally Groupe SpécialMobile)


is a standard developed by the European Telecommunications Standards Institute (ETSI) to
describe the protocols for second-generation (2G) digital cellular networks used by mobile
phones, first deployed in Finland in December 1991. As of 2014 it has become the de facto
global standard for mobile communications – with over 90% market share, operating in over
219 countries and territories.

2G networks developed as a replacement for first generation (1G) analog cellular


networks, and the GSM standard originally described as a digital, circuit-switched network
optimized for full duplex voice telephony. This expanded over time to include data
communications, first by circuit-switched transport, then by packet data transport
via GPRS (General Packet Radio Services) and EDGE (Enhanced Data rates for GSM
Evolution or EGPRS).

Subsequently, the 3GPP developed third-generation (3G) UMTS standards followed


by fourth-generation (4G) LTE Advanced standards, which do not form part of the ETSI
GSM standard.

"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

4.6.1 BASE STATION SUBSYSTEM

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.

4.6.2 GSM CARRIER FREQUENCY

GSM networks operate in a number of different carrier frequency ranges (separated


into GSM frequency ranges for 2G and UMTS frequency bands for 3G), with most 2G GSM
networks operating in the 900 MHz or 1800 MHz bands. Where these bands were already
allocated, the 850 MHz and 1900 MHz bands were used instead (for example in Canada and
the United States). In rare cases the 400 and 450 MHz frequency bands are assigned in some
countries because they were previously used for first-generation systems.

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.

Regardless of the frequency selected by an operator, it is divided into timeslots for


individual phones. This allows eight full-rate or sixteen half-rate speech channels per radio
frequency. These eight radio timeslots (or burst periods) are grouped into a TDMA frame.
Half-rate channels use alternate frames in the same timeslot. The channel data rate for all 8
channels is 270.833 kbit/s, and the frame duration is 4.615 ms.

The transmission power in the handset is limited to a maximum of 2 watts in GSM


850/900 and 1 watt in GSM 1800/1900.

4.6.3 VOICE CODECS

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.

4.6.4 SUBSCRIBER IDENTITY MODULE (SIM)

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.

4.6.5 GSM SECURITY

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.

The development of UMTS introduced an optional Universal Subscriber Identity


Module (USIM), that uses a longer authentication key to give greater security, as well as
mutually authenticating the network and the user, whereas GSM only authenticates the user
to the network (and not vice versa). The security model therefore offers confidentiality and
authentication, but limited authorization capabilities, and no non-repudiation.

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.

4.7 INTRODUCTION TO MQ2 SENSOR

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.

4.7.1 WHAT IS SMOKE SENSOR

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..

4.7.2 PIN CONFIGURATION OF SMOKE SENSOR

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

 High sensitivity to SMOKE and small sensitivity to Benzine .


 Fast response and High sensitivity

42
 Stable and long life

 Simple drive circuit

4.8 INTRODUCTION TO LOAD CELL

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.

4.8.1 STRAIN GUAGE LOADCELL

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

There are several types of load cells:

 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

4.8.3 LOAD CELL CALIBRATION

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>

LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

#include "HX711.h"

unsigned int w=0;

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.print(" IoT GAS ");

lcd.setCursor(0,1);

lcd.print("MONITORING SYSTM");

delay(3000);

46
lcd.clear();

scale.set_scale(2280.f); // this value is obtained by calibrating the scale with


known weights; see the README for details

scale.tare();

lcd.setCursor(0,0);

lcd.print(" PLACE CYLINDER ");

lcd.setCursor(0,1);

lcd.print(" ON LOAD CELL ");

delay(15000);

lcd.clear();

void loop(){

w=scale.get_units(10)*5.7286;

if(w>400)

lcd.clear();

lcd.setCursor(0,0);

lcd.print("GAS LEVEL : 100% ");

//digitalWrite(8,HIGH);

digitalWrite(9,HIGH);

delay(100);

47
}

if((w>300)&&(w<400))

lcd.clear();

lcd.setCursor(0,0);

lcd.print("GAS LEVEL : 75% ");

//digitalWrite(8,LOW);

digitalWrite(9,HIGH);

delay(100);

if((w>200)&&(w<300))

lcd.clear();

lcd.setCursor(0,0);

lcd.print("GAS LEVEL : 50% ");

//digitalWrite(8,HIGH);

digitalWrite(9,LOW);

delay(100);

if(w<100)

48
{

lcd.clear();

lcd.setCursor(0,0);

lcd.print("GAS LEVEL : <25%");

//digitalWrite(8,LOW);

digitalWrite(9,LOW);

book();

lcd.clear();

lcd.setCursor(0,0);

lcd.print("GAS REFIL BOOKED ");

lcd.setCursor(0,1);

lcd.print("THANK YOU! ");

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.print("9963302759"); //mobile no. for SMS alert

Serial.println('"');

delay(500);

Serial.print("GAS LEAKAGE DETECTED");

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.print("9963302759"); //mobile no. for SMS alert

Serial.println('"');

delay(500);

Serial.print("Dear Customer, Your Gas Refil is Booked. Thank You!");

Serial.write(26);

delay(12000);

Serial.println("AT");

delay(500);

Serial.println("AT+CMGF=1");

delay(500);

Serial.print("AT+CMGS=");

Serial.print('"');

Serial.print("9542603470"); //mobile no. for SMS alert

51
Serial.println('"');

delay(500);

Serial.print("Refil Request from RAJENDAR with Consumer Number 15UK1A04J7 ");

Serial.write(26);

delay(10000);

5.2 NODEMCU CODE

#include "ThingSpeak.h"

#include "secrets.h"

#include <ESP8266WiFi.h>

char ssid[] = SECRET_SSID; // your network SSID (name)

char pass[] = SECRET_PASS; // your network password

int keyIndex = 0; // your network key Index number (needed only for WEP)

WiFiClient client;

unsigned long myChannelNumber = SECRET_CH_ID;

const char * myWriteAPIKey = SECRET_WRITE_APIKEY;

// Initialize our values

#define gas D5

52
int level, leak;

String myStatus = "";

void setup() {

pinMode(D1,INPUT);

pinMode(D7,INPUT);

pinMode(D6,OUTPUT);

digitalWrite(D6,HIGH);

pinMode(gas, INPUT);

Serial.begin(115200); // Initialize serial

WiFi.mode(WIFI_STA);

ThingSpeak.begin(client); // Initialize ThingSpeak

void loop() {

// Connect or reconnect to WiFi

if(WiFi.status() != WL_CONNECTED){

Serial.print("Attempting to connect to SSID: ");

53
Serial.println(SECRET_SSID);

while(WiFi.status() != WL_CONNECTED){

WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network. Change this line if using


open or WEP network

Serial.print(".");

delay(5000);

Serial.println("\nConnected.");

int humi = random(40,46);

int temp = random(24,26);

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){

myStatus = String("Gas Leakage Detected");

/* if(level==100)

myStatus = String("Gas Level : 100%");

if(level==75)

myStatus = String("Gas Level : 75%");

if(level==50)

myStatus = String("Gas Level : 50%");

if(level==20)*/

//myStatus = String("Gas Level : < 25% Booking Gas Automatically");

ThingSpeak.setField(1, temp);

ThingSpeak.setField(2, humi);

ThingSpeak.setField(3, leak);

// ThingSpeak.setField(4, level);

55
// set the status

ThingSpeak.setStatus(myStatus);

// write to the ThingSpeak channel

int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);

if(x == 200){

Serial.println("Channel update successful.");

else{

Serial.println("Problem updating channel. HTTP error code " + String(x));

delay(5000); // Wait 5 seconds to update the channel again

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).

Alpaydin, E., 2014. Introduction to machine learning. MIT press.

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

You might also like