You are on page 1of 43

AUTOMATI

CSMOKEANALYSERUSI
NG
MI
CROCONTROLLER

APr
ojectRepor
t
Submi
tt
edi
npar
ti
alf
ulf
il
lmentoft
her
equi
rementf
ort
heMai
n
pr
ojectof
BACHELOROFTECHNOLOGY
I
N
MECHANI
CALENGI
NEERI
NG
Submi
tt
edby

1. K.
RAVIKUMAR (17T91A0311)
2. GOWTHAM (17T91A0325)
3. K.
VIKAS (17T91A0312)
4. K.
SURYAPRAKASH(
18T95A0314)
5. J.
LAKSHMAN (17T91A0317)

Undert
heEst
eemedgui
danceof
Mr
.P.
VIPI
NRAJSI
RM .
Tech
Assi
stantpr
ofessor
DEPARTMENTOFMECHANI
CALENGI
NEERI
NG

Col
legeofEngi
neer
ing

(
APPROVEDBYAI
CTE,
AFFI
LATEDTOJNTUKAKI
NADA)
NH-
16,
Chai
tany
aKnowl
edgeCi
ty,
RAJAMAHENDRAVARAM-
533296A.
P

APRI
L-2020
DEPARTMENTOFMECHANI
CALENGI
NEERI
NGGI
ET

COLLEGEOFENGI
NEERI
NG

Col
legeofEngi
neer
ing

(
Appr
ovedbyA.
I.
C.T.
E,Af
fi
li
atedt
oJNTUKaki
nada)

NH-
16,
Vel
ugubanda,
Raj
amahendr
avar
am,
E.G.
Dist
,A.
P-533296.

BONAFI
DECERTI
FICATE

Thi
sist
ocer
ti
fyt
hatt
hepr
ojectr
epor
tent
it
led."
AUTOMATI
CSMOKE

ANALYSERUSI
NGMI
CROCONTROLLER”isabonafiderecordofworkofthefollowing
candi
dat
eswhocar
ri
edoutt
hepr
ojectwor
kunderoursuper
visi
ondur
ing2019-
2020.

1. K.
RAVI
KUMAR (
17T91A0311)

2. GOWTHAM (
17T91A0325)

3. K.
VIKAS (
17T91A0312)

4. K.
SURYAPRAKASH(
18T95A0314)

5. J.
LAKSHMAN (
17T91A0317)

Di
sser
tat
ionsubmi
tt
edi
spar
ti
alf
ulf
il
lmentoftherequi
rementf
ort
heawar
doft
he
Mainprojectof
BACHELOROFTECHNOLOGY
I
N
MECHANI
CALENGI
NEERI
NG

Mr
.P.
VIPI
NRAJSI
RM.
Tech Mr
.P.
POORNAMOHANM.
Tech,
PhD

(
HeadofDepar
tment
)

(
Proj
ectGui
de)

Cer
ti
fi
edt
hatt
hecandi
dat
eexami
nat
iont
hev
iva-
voi
ceexami
nat
iont
hehel
don
ACKNOWLEDGEMENT
Wet
hankwi
thdeepsenseofacknowl
edgementt
othemanagementofGI
ET

Col
l
egeofEngi
neer
ingandt
oourr
espect
edPr
i pal“
nci Dr.T.
VAMSIKI
RAN”PhD f
or
ext
endi
ngal
lfaci
l
iti
es.

Weexpr
essmysi
ncer
et o“
hankst Mr
.P.
VIPI
NRAJ”M.
Tech(
PhD)
.Associ
ate
pr
ofessor and Head of Depar
tment
, Mechani
cal Engi
neer
ing f
or hi
s excel
l
ent
encour
agementi
ncour
seoft
hiswor
k.

Wet
aket
hei
mmensepl
easur
einconv
eyi
ngourt
hanksanddeepsenseof
gr
ati
tudet
oourcoor
di or“
nat Mr.
M.SURYANARAYANA”M.
Tech.Assi
stantpr
ofessorand

o“
t Mr
.RAJESH”Mechani
cal
Engi
neer
ingl
abassi
stantf
orsuppor
ti
ngusi
nev
erymoment
ofourwor
k.

Lastbutnotl
eastwewoul
dli
ket
othankal
lthet
eachi
ng f
rat
erni
tyf
or
suppor
ti
ngadv
isi
ngaswhenev
eri
nneed,
co-
oper
ati
ngwi
thusandar
rangi
ngt
henecessar
y
f
aci
l
iti
es.

Wewoul
dli
ket
oconv
eygr
ati
tudet
oourpar
ent
swhosebl
essi
ngswer
eal
way
s
t
her
ewi
thus,
final
l
ywewoul
dli
ket
othankourf
ri
endswhodi
rect
lyori
ndi
rect
lyhel
pedusi
n
successf
ulcompl
eti
onoft
hiswor
k.

1.K.
RAVIKUMAR (
17T91A0311)
2.GOWTHAM (
17T91A0325)
3.K.
VIKAS (
17T91A0312)
4.K.
SURYAPRAKASH (
18T95A0314)
5.J.
LAKSHMAN (
17T91A0317)
DECELERATI
ON

Ther
esear
chwor
kcar
ri
edoutbyusi
ntheDepar
tmentofMechani
cal
Engi
neer
ing,

GI
ETCol
l
egeofEngi
neer
ing,
Raj
ahmundr
y“AUTOMATI
CSMOKE

ANALYSERUSI
NGMI
CROCONTROLLER”undert
heest
eemedgui
danceofAssi
stantpr
ofessorMr
.

P.
VIPI
NRAJM.
Tech.
Depar
tmentofMechani
cal
Engi
neer
ing,
GIETCol
l
egeof
Engi
neer
ing,

Raj
ahmundr
y.

Thi
srepor
tisor
igi
nal
andhasnotbeensubmi
tt
edi
npar
torf
ull
forot
herdegr
eeor

di
plomaoft
hisoranyot
heruni
ver
sit
y.Theext
entofi
nfor
mat
ionder
ivedf
rom t
heexi
sti
ngl
i
ter
atur
ehas

beeni
ncor
por
atedi
nthi
srepor
tatappr
opr
iat
epl
aces,
indi
cat
ingt
hesour
ceofi
nfor
mat
ion

1.
K.RAVI
KUMAR (17T91A03
11)
(17T91A03
2.
GOWTHAM
25)
(17T91A03
3.
K.VI
KAS
12)
(18T95A03
4.
K.SURYAPRAKASH
14)
(17T91A03
5.
J.LAKSHMAN 17)

5
ABSTRACT

Vehi clesandI ndust riesar et hemaj oror iginofEnv i


ronment al
Pol lut i
on.Ev eryv ehiclewi l
l hav eemi ssionbutt hepr oblem occur s,
whi chi sduet othei mpr opermai nt enanceofv ehicles. Thisemi ssion
from v ehi cl
escannotbecompl etelyav ertbut ,
itdef i
ni t
elycanbe
cont rolled.Asasol utiontot heabov epr oblemsweai mt obui ldan
aut omat edcont rolsy stem f oremi ssi onl eveldet ectioni nv ehicl es
andi ndicatet hislev elwithamet er.Whent hepol lution/emi ssi on
l
ev elshoot sbey ondt heal readysett hreshol dlevel,therewi llbea
buzzi nt hev ehicletoi ndicat et hatt hel imithasbeenbr eachedand
thisi nformat ionhasbeensendt ot rafficcont r
ol room whi ch
i
ncl udesv ehiclenumber ,ownerdet ailsandl ocat i
onoft hev ehi cleby
usi ngGPS. I
nf uturewecanaddaddi tional featuresliket rafficpol i
ce
hav eanaut horitytost opt hev ehicl er emot elybysendi ngaSMS
usi ngGSMI nthispr ojectwear ei mpl ement ingpol lutionmoni t oring
sy st em basedont heamountofpol l
ut i
onr eleasedf r
om v ehi cles. We
aredoi ngt hispr ojectusingr eal timeoper atingsy stem, Firstwewi l
l
fi
ndoutt hepol lutionl evelst hatwi l
lbedoneusi ngMQ7sensor .

6
CONTENTS

CHAPTER:
1
I
NTRODUCTION
1.
1 GENERALINTRODUCTI
ON
2GOALOFRESEARCHWORK13
1-
PROBLEM I
DENTI
FICATI
ON
14
PROJECTOBJECTIVES
1.
5
PROJECTSCOPE

CHAPTER:2
LI
TERATURESURVEY
CHAPTER:3
LI
NEDIAGRAM
3.
1 REQUIREDMODULES

3.
2 I
NPUTMODULES

3.
3 OUTPUTMODULES
3.
4 POWERSUPPLY
3.
5 TEMPERATURESENSOR
3.
6 MQ2SENSOR
3.
7 ARDUINOUNO
3.
8 LCDDISPLAY
3.
9 COSENSOR
CHAPTER4
CI
RCUITDI
AGRAM
4.
1 COSENSOR
4.
2 MQ2SENSOR
4.
3 ARDUINOUNO
4.
4 LCDDISPLAY
4.
5 TEMPARATURESENSOR
CHAPTER5

7
ARDUI
NOUNOANDESP8266MODULES
5.
1 ARDUINO
5.
2 ESP8266MODULE
CHAPTER6
SOFWAREUSED
6.
1 ARDUINOIDESOFTWARE

8
LI
STOFFI
GURES
3 No
S. LI
DN
EED
S I
AT
CRI
P G
IR
OA
NM 6
PageNo
4.
1 CARBONMONOXI DESENSOR 12
4.
2 SCHEMATICDIAGRAM 1
4.
23 CONFIGURATI
ON 2 1
4.
24 BASI
CTESTLOOP 4 1
4.
4.1 PINDIAGRAM 4 16
4.
5 TEMPARATURESENSOR 17
4.
5.1 MODULEOFTHECOMPONENT 2
5.
1.4 PINDI
SCRIPTI
ON 0 2
5
5.
2 ARDUINOUNO 27
5.
3 ESP8266MODULE 3
5.
4 PINDIAGRAM OFESP8266 1 3
1

11
Chapter-1 General Theory

CHAPTER-1

Chapter 1
Introduction

1.1 General Introduction


Now a day’s we easily see that vehicle becomes an important requirement of everyone’s life
may be indirectly or directly. Vehicle is the prime source of the air pollution The emission from
motor vehicle produce polluted air which cause human’s life in terms of health and
environmental issues also. The internal combustion of fuel in the engine approaches to the
environmental problems. All the types of the motor vehicles produce some level of air pollution
but the problem stands when the value of the emission is greater than the value of the maximum
threshold level. According the survey the two by third of air pollution is caused by the internal
combustion in the fuel of the motor vehicles. In such cases rules and the constitution made by
the government of India and most of them was not successful just because of people don’t
follow them seriously and they don’t checkup their vehicle’s pollution level at the regulated
interval. There is no alternative if the people don’t follow these constitution and regulation
made by the government. Therefore we should have such a system by which emission from the
vehicles can be controlled easily and automatically too. Through which people have to have
the proper maintenance of their vehicle and we can easily regulate the output of the emission
level of the motor vehicle. Air pollution is reasonable for the environment issues like climate
change, global warming and so on and human’s life in terms of diseases like lung cancer,
asthma etc. Motor vehicles are the main source of transportation but also the main source of air
pollution. We can’t completely avoid the emission from the vehicle but we can control this
emission. In small city most of the people don’t checkup their vehicle pollution level at regular
interval will cause of air pollution. So I have an aim to control the air pollution through smoke
sensor.The incomplete combustion in the engine of a vehicle leads to emission of different
gases contributing to increase in the pollution and adversely affecting the environment.
Detection and control of these gases is an important area of work. This emission from vehicles
cannot be completely avoided but, it definitely can be controlled. Now a day’s accidents are
common reason for deaths. These are critical things to control so here we come up with a
concept to reduce pollution and detect the location of accident using GPS. As a solution to the
above problems we aim to build an automated control system for emission level control of
vehicle and accident place detection. Smoke detector is used to detect the carbon percentage in
the smoke released by the vehicle due to combustion of fuel in it. Smoke detector is fixed at
the end of the exhaust of vehicle from where smoke is released into the environment. The smoke
detector detects carbon and gives it to the Microcontroller to check the maximum percentage
of carbon content in the smoke released by vehicles. Temperature sensor can be used to sense
the temperature in the vehicle. So the controller checks the percentage of carbon and
temperature, if it exceeds the threshold level the system gets triggered and the engine comes to
hault state and then it sends SMS about this to the nearby pollution control office through GSM.
1.2 Goal of the Research Work
The main purpose of this project is to design and implement an automatic fire alarm & fire
control system that can be produced at a low cost with effective and competitive usage. This
system is designed to be more users friendly and easy to operate at any level.
Chapter-1 General Theory

The project is also been designed to be further working vision using minimum hardware at the
lower level of processing. These systems are directed at specific applications.

1.3 Problem Identification


We see that there is no alternative if the people don’t check their vehicle’s pollution level.
During the period of checking some people are caught by the traffic police and some are not.
But during the period of no checking people ride their vehicle which causes the emission
beyond the maximum threshold pollution level on the road with any fear. According to the
survey in cities like Delhi and Gurgaon the quality of the air is very poor means to take a breath
in these cities regularly will be a cause of serious threats to the human’s health. Emission from
the motor vehicle is reasonable for the two by third of air pollution which causes of many
environmental issues like climate change, global warming etc. and affects human’s health in
terms of diseases. Therefore there is a need of system which can detect the level of percentage
of carbon present in the smoke and control automatically and easily without any need of hard
work. Population of India is increasing day by day and definitely the number of vehicles are
also increasing in correspond too. If we don’t give our efforts to reduce the emission from motor
vehicle right from today, it will be a very serious threat to human’s life and nature. So I proposed
system to detect and control the emission level from the motor vehicle.
1.4 Project Objectives
Our objective is to design a Vehicle Smoke analysis system that would fulfill the following
objectives:
i) The system should also provide the flexibility to adjust the temperature.
ii) The system should never be in any ambiguous state. Under normal conditions the
system should indicate the state of the room as ‘Safe’ in order to avoid any
confusion.
iii) The system should be detecting the smoke and alert the user by buzzer.
iv) The system should also show the real time readings on the Lcd panel
v) The system should also send sms to users for the pollutant level alert.

1.5 Project Scope

Nowadays the air condition is much polluted. In recent years, car emissions, chemicals from
factories, smoke and dust are everywhere. That is the reason why now air condition is much
polluted. The effect of air pollution is very bad for our health, especially for place where the
air in our body is taken for breathing. In our lungs may cause some diseases, such as asthma,
cough, and lung disorders.
Chapter-2 Literature survey

CHAPTER 2
LITERATURE SURVEY
Few locations, with usually high volume of traffic, may be identified to be monitored.
In this framework, for each monitored location, the RFID readers are placed on the
either side of a road with a fixed short distance in between them. Each vehicle passing
through the road is equipped with a passive RFID tag. Sensor nodes, composed of gas
sensors, are placed on the roadside. The sensor nodes may be identified and addressed
by unique IP address or a unique ID. These nodes gather sensor data continuously and
send it wirelessly to the server. Whenever the sensor nodes sense abrupt rise in
pollution, search is initiated for concerned RFID tags, i.e. vehicles causing pollution
are identified using the RFID tag attached on them. Pollution data is printed on arduino
terminal not sent on internet server.The RFID readers identify corresponding tag
number and transmit the same via the GPRS modem to the server. This framework also
generates alert when pollution level increases. Authorities may take appropriate actions
accordingly. All the gathered data may be monitored and analyzed by authorities
concerned. The system has a significant meaning in terms of cost and effectiveness in
comparison to other non-RFID based vehicle detection system as image processing
solution, GPS and satellites solution requires a large number of expensive and powerful
equipment for processing. Also Wireless sensor along with active RFID can be used in
the wireless sensor system to monitor the vehicular pollution based on IoT. At monitor
location, the RFID reader, wireless gas sensors are integrated along with
microcontroller. This entire system is placed in either of the road. Whenever the
vehicles equipped with RFID tags passed through the sensor node, RFID reader
presented in the monitoring system detects the vehicles and the sensors measures
quality of the air produced by that vehicle. The sensed continuous data is sent to the
microcontroller for verification of the pollution level of the vehicle. The
microcontroller verifies the levels of the pollutants of the air produced by the vehicle.
If the pollutants levels are beyond the threshold levels, then it sends the warning
message to the vehicle owner. The same data is displayed on the Liquid Crystal Display
(LCD). The information about the levels of CO2 and SOx, vehicular number, RFID of
the vehicle and time and date of vehicle are also sent to the server of the authorized
agencies. This information is stored in the server database for future analysis. In this
system using wireless sensor network that provides a framework for collecting the
sensor data at any place using IoT. Wireless sensor along with active RFID is used in
Chapter-2 Literature survey

the proposed wireless sensor system to monitor the vehicular pollution based on IoT.
Pollution data is displayed on LCD & Message alert sent to vehicle owner for exceeding
pollution level. Another proposed system consists of two modules vehicle unit and
remote monitoring unit. Vehicle units, which resides in a vehicle consists of CO2, LPG
GAS sensors, RFID tags and GSM modem. Remote monitoring server area holds the
server unit, GSM modem and Laptop. XAMPP is used as local host server to view the
Arduino contents in the remote area of server. From the proposed system, a low cost
RFID based application can be designed using Arduino and the applications of Home
automation, Industrial control, Transportation can be achieved easily. The vehicle unit
periodic monitoring of the sensor values are noted and send to the laptop via GSM
modem. Along with the Sensor values, Vehicle FC details, Insurance Details, Periodic
Service details are viewed on the laptop using VB. If any increase in the sensor
readings/Date expired of any insurance, FC, Service an alert will be send to the owner,
also the Transport service regarding vehicle insurance. A compact system can be
developed to detect the pollutants in the vehicle which could be assembled in the
vehicle itself. Tremendous innovations have been made in the technology and
manufacturing of cars as well as in the pollution control department but still nothing
significant achieved of it. This idea employs an MQ7 sensor which is economical and
capable of detecting Carbon Monoxide gas emitted from the vehicle. An initial warning
is given to the driver regarding the amount of CO gas with the help of LCD display and
later the same information is transferred to the Pollution Control Board in case of
negligence. This is done with the help of GSM system incorporated in the vehicle. The
AVR Microcontroller is used to transfer the information to the GSM system from the
MQ7 sensor. This paper is capable to measure the value of pollutants emitted by the
vehicle continuously and display it on 16x2 alphanumeric LCD display. Also if the
pollutant level exceeds the prescribed value, then a SMS will be sent to the respective
authority to take necessary disciplinary action. Over the years, there have been several
regulations made by the Government to control the emission from vehicles; most of
them being unsuccessful at the same. The standards and the timeline for implementation
are set by the Central Pollution Control Board under the Ministry of Environment &
Forests. Bharat stage emission standards are emission standards instituted by the
Government of India to regulate the output of air Pollutants from internal combustion
engine equipment, including motor vehicles. The first emission norms were introduced
in India in 1991 for petrol and 1992 for diesel vehicles. These were followed by making
Chapter-2 Literature survey

the Catalytic converter mandatory for petrol vehicles and the introduction of unleaded
petrol in the market. On April 29, 1999 the Supreme Court of India ruled that all
vehicles in India have to meet Euro I or India 2000 norms by June 1, 1999 and Euro II
will be mandatory in the NCR by April 2000. Car makers were not prepared for this
transition and in a subsequent judgment the implementation date for Euro II was not
enforced. The standards, based on European regulations were first introduced in 2000.
Progressively stringent norms have been rolled out since then. All new vehicles
manufactured after the implementation of the norms have to be compliant with the
regulations. Since October 2010, Bharat stage III norms have been enforced across the
country. In 13 major cities, Bharat stage IV emission norms are in place since April
2010. In this paper, the semiconductor sensors have been used to detect the pollutant
level of the vehicles. This Paper concentrates mainly on three blocks; smoke detector,
microcontroller and fuel injector. The smoke detector detects the pollutants (CO, NOx,
etc.) continuously. The microcontroller compares the level of pollutants with the
stipulated level allowed by the government. When the pollutant level exceeds the
standardized limit, it sends a signal to the fuel injector. On receiving a signal from the
controller, the fuel injector stops the fuel supply to the engine after a particular period
of time.
Chapter-3 Line Diagram

CHAPTER-3
LINE DIAGRAM
In this diagram represents about the description of the each block with the help of line
diagram.

sms

Gas sensor

L293D
MOTOR

Arduino

Co sensor
Chapter-3 Line Diagram

3.1 REQUIRED MODULES:

• Power Supply
• Temperature sensor
• Co sensor
• MQ2 sensor
• Arduino Uno
• LCD display
3.2 INPUT MODULES:
• Power supply
• Temperature sensor
• Mq2 sensor

3.3 OUTPUT MODULES:


• LCD display
• ESP8266

3.4 POWER SUPPLY:


3.4.1 Input Voltage Limits

• Recommended: 7~12V
• Absolute: 6~20V
• Input/output (I/O) pins: -0.5V to +5.5V (the actual max is “Vcc + 0.5V,” which
for a 5V Arduino, is +5.5V)

3.4.2 Output Current Limits


• When powered by USB: total of 500mA
• With external battery or power supply: total of 500mA~1A
• 5V pin: same as above: 500mA or 500mA~1A
• Each input/output pin: 40mA
• Sum of all input/output pins combined (but NOT including the “5V”
pin): 200mA
Chapter-3 Line Diagram

3.5 Temperature Sensor

A temperature sensor is an electronic device that measures the temperature of its environment
and converts the input data into electronic data to record, monitor, or signal temperature
changes. There are many different types of temperature sensors. Some temperature sensors
require direct contact with the physical object that is being monitored (contact temperature
sensors), while others indirectly measure the temperature of an object (non-contact temperature
sensors).

3.6 MQ2 SENSOR:

The Grove - Gas Sensor (MQ2) module is useful for gas leakage detection
(home and industry). It is suitable for detecting H2, LPG, CH4, CO, Alcohol, Smoke
or Propane. Due to its high sensitivity and fast response time, measurement can be taken
as soon as possible. The sensitivity of the sensor can be adjusted by potentiometer.

3.7 ARDUINO UNO:

Arduino is an open-source hardware and software company, project and user


community that designs and manufactures in the single-board microcontrollers
and microcontroller kits for building digital devices and interactive objects that can
sense and control both physically and digitally.

3.8 LCD DISPLAY:

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 colour or monochrome. 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 seven-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
Chapter-3 Line Diagram

The Design &Implementation of line diagram will be discussed in next chapter with the
help of circuit diagram and other components.

3.9 CO SENSOR

MQ-7 Semiconductor Sensor for Combustible Gas

Sensitive material of MQ-7 gas sensor is SnO2, which with lower conductivity in clean
air. It make detection by method of cycle high and low temperature, and detect CO
when low temperature (heated by 1.5V). The sensors conductivity is more higher along
with the gas concentration rising. When high temperature (heated by 5.0V), it cleans
the other gases adsorbed under low temperature. Please use simple electrocircuit,
Convert change of conductivity to correspond output signal of gas concentration.
Chapter-4 Circuit Diagram

CHAPTER-4
CIRCUIT DIAGRAM

4.1 Co Sensor

MQ-7 gas sensor has high sensitity to Carbon Monoxide. The sensor could be used to
detect different gases contains CO, it is with low cost and suitable for different he
carbon monoxide sensor we will use is the MQ-7 sensor. This is a sensor that is sensitive
to effects of CO.

Carbon monoxide (CO) is a very dangerous gas which is odorless, colorless, and
tasteless, so it cannot be smelt, seen, or tasted. A person really would have no idea that
they are breathing in CO besides the fact that they would start to feel horrible. The most
common symptoms of CO poisoning is headache, nausea, vomiting, dizziness, fatigue,
and a feeling of weakness. Neurological signs include confusion, disorientation, visual
disturbance, syncope, and seizures.

Carbon monoxide is produced from the partial oxidation of carbon-containing


compounds; it forms when there is not enough oxygen to produce carbon dioxide
(CO<sub2< sub="">), such as when operating a stove or an internal combustion engine
in an enclosed space. In the presecne of oxygen, including atmospheric concentrations,
carbon monoxide burns with a blue flame, producing carbon dioxide. So it is really in
enclosed spaces with partial oxidation of carbon products that creates the danger of
carbon monoxide production in homes or in businesses. </sub2<>

Carbon monoxide poisoning is the most common type of fatal air poisoning in many
countries. Being colorless, odorless, and tasteless, it is very hard to detect but highly
toxic. Carbon monoxide is absorbed through breathing and enters the bloodstream
through gas exchange in the lungs. CO combines with hemoglobin to produce
carboxyhemoglobin, which usurps the space in hemoglobin that normally carries
oxygen, but is ineffective for delivering oxygen to bodily tissues. This leads to oxygen
deprivation, which can be deadly.

CO is measured in parts per million (ppm). To give you some perspective, the natural
atmosphere is composed of 0.1ppm. Ther average level in homes is 0.5-5ppm. The level
near properly adjusted gas stoves in homes and from modern vehicle exhaust emissions
is 5-15ppm. The exhaust from automobilies in Mexico City central area is 100-200ppm.
The amount of CO that can be created from the exhaust from a home wood fire is
5000ppm. Concentrations as low as 667ppm may cause up to 50% of the body's
hemoglobin to convert to carboxyhemoglobin. A level of 50% carboxyhemoglobin may
result in seizure, coma, and fatality.

In the United States, OSHA limits long-term workplace exposure levels above 50ppm.

According to the Florida Department of Health, every year more than 500 people in the
United States die every year from accidental exposure to carbon monoxide and
thousands more across the US require emergency medical care for non-fatal CO
Chapter-4 Circuit Diagram

poisoning. These products include malfunctioning fuel-burning appliances such as


furances, ranges, water heaters, gas and kerosene room heaters, fireplaces, and charcoal
that is burned in homes and other enclosed areas. Still others die from CO produced by
non-home products, such as cars left running in a garage. The Centers for Disease
Control and Prevention estimates that several thousand people go to hospital emergency
rooms every year to be treated for carbon monoxide poisoning.

Carbon monoxide can be measured through laboratory testing requiring a blood sample
(arterial or venous) and can also be analyzed on a CO-oximeter.

Having this overview of carbon monoxide gives some background to how it is created
and the real severe dangers it can pose. It creates context to just how important it is to
be able to detect and measure the amount of CO that may be present in the environment
during any given time.

application.

Character

• High sensitivity to Combustible gas in wide range


• High sensitivity to Natural gas
• Fast response
• Wide detection range
• Stable performance, long life, low cost
• Simple drive circuit.

Technical Data
Chapter-4 Circuit Diagram

Introduction to MQ-7 Carbon Monoxide Sensor

According to its datasheet, the MQ-7 carbon monoxide sensor detects 20 to 2000 ppm
of CO in air. Here is its sensitivity characteristic curve:

This is a graph of Rs/R0 vs. gas concentration in ppm. Rs is the resistance of the sensor
in target gas while R0 is the resistance in clean air. We will use this graph later when
we create our code.

This breakout board is more convenient as it converts resistance variations to voltage


variations. Here is its schematic diagram:
Chapter-4 Circuit Diagram

There are two ways to read the output from the MQ-7. One is through the DOUT pin
which gives a high when the concentration threshold is reached and low otherwise. The
threshold can be varied by adjusting the trimmer on the breakout board which is Rp in
the schematic.

Meanwhile, the AOUT pin gives varying voltage representing the CO concentration.
We can convert the voltage reading to ppm if we look at the characteristic curve above.
The relationship between concentration in ppm and RS/R0 is:

4.2 MQ2 SENSOR:


Sensitive material of MQ-2 gas sensor is SnO2, which with lower conductivity
in clean air. When the target combustible gas exist, the sensor’s conductivity is higher
along with the gas concentration rising. Please use simple electro circuit, Convert
change of conductivity to correspond output signal of gas concentration. MQ-4 gas
sensor has high sensitity to Methane, also to Propane and Butane. The sensor could be
used to detect different combustible gas, especially Methane, it is with low cost and
suitable for different application.

4.2.1 Character:

* Good sensitivity to Combustible gas in wide range

* High sensitivity to Natural gas

* Long life and low cost

* Simple drive circuit

4.2.2 Application:

* Domestic gas leakage detector

* Industrial Combustible gas detector

* Portable gas detect


Chapter-4 Circuit Diagram

4.2.3 Configuration:

Fig. 4.5 MQ2 Configuration

4.2.4 Basic test loop:

Fig. 4.6 MQ2 Basic test loop

The above is basic test circuit of the sensor. The sensor need to be put 2 voltage,
heater voltage (VH) and test voltage(VC). VH used to supply certified working
temperature to the sensor, while VC used to detect voltage (VRL) on load resistance
(RL)whom is in series with sensor. The sensor has light polarity, Vc need DC power.
Chapter-4 Circuit Diagram

VC and VH could use same power circuit with precondition to assure performance of
sensor. In order to make the sensor with better performance, suitable RL value is
needed: Power of Sensitivity body (Ps):

Ps=Vc2 ×Rs/(Rs+RL)2 .............(4.2)

Resistance of sensor (Rs): Rs= (Vc/VRL-1) ×RL ............. (4.3)

4.3 ARDUINO UNO:


The Arduino UNO is an open-source microcontroller board based on the
Microchip ATmega3285 microcontroller and developed by arduino. The board is
equipped with sets of digital and analog input/output (I/O) pins that may be interfaced
to various expansion boards (shields) and other circuits. The board has 14 Digital pins,
6 Analog pins, and programmable with the Arduino IDE (Integrated Development
Environment) via a type B USB cable. It can be powered by a USB cable or by an
external 9 volt battery, though it accepts voltages between 7 and 20 volts. It is also
similar to the Arduino Nano and Leonardo. The hardware reference design is
distributed under a Creative commons Attribution Share-Alike 2.5 license and is
available on the Arduino website. Layout and production files for some versions of the
hardware are also available. The detailed description of ARDUINO UNO are
discussed in chapter-5.
4.4 LCD DISPLAY:
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 colour or monochrome. 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 seven-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
Chapter-4 Circuit Diagram

4.4.1 Pin Diagram:

Fig. 4.8 LCD pin diagram

4.4.2 Pin Description:

Table 4.1 Pin Description


Chapter-4 Circuit Diagram

4.5 Temperature Sensor


Chapter-4 Circuit Diagram

LM35 Temperature Sensor

LM35 Temperature Sensor Pinout

CLICK ON IMAGE TO ENLARGE

Pin Configuration:
Pin Pin Name Description
Number
1 Vcc Input voltage is +5V for typical applications
2 Analog There will be increase in 10mV for raise of every 1°C. Can range from -1V(-
Out 6V(150°C)
3 Ground Connected to ground of circuit

LM35 Regulator Features:


• Minimum and Maximum Input Voltage is 35V and -2V respectively. Typically 5V.
• Can measure temperature ranging from -55°C to 150°C
• Output voltage is directly proportional (Linear) to temperature (i.e.) there will be a rise
of 10mV (0.01V) for every 1°C rise in temperature.
• ±0.5°C Accuracy
• Drain current is less than 60uA
• Low cost temperature sensor
• Small and hence suitable for remote applications
• Available in TO-92, TO-220, TO-CAN and SOIC package
Chapter-4 Circuit Diagram

Note: Complete Technical Details can be found at the datasheet give at the end of
this page.

LM35 Temperature Sensor Equivalent:


LM34, DS18B20, DS1620, LM94022
How to use LM35 Temperature Sensor:
LM35 is a precession Integrated circuit Temperature sensor, whose output voltage
varies, based on the temperature around it. It is a small and cheap IC which can be used
to measure temperature anywhere between -55°C to 150°C. It can easily be interfaced
with any Microcontroller that has ADC function or any development platform like
Arduino.
Power the IC by applying a regulated voltage like +5V (VS) to the input pin and
connected the ground pin to the ground of the circuit. Now, you can measure the
temperate in form of voltage as shown below.

If the temperature is 0°C, then the output voltage will also be 0V. There will be rise of
0.01V (10mV) for every degree Celsius rise in temperature. The voltage can converted
into temperature using the below formulae.

LM35 Temperature Sensor Applications:


• Measuring temperature of a particular environment
• Providing thermal shutdown for a circuit/component
• Monitoring Battery Temperature
• Measuring Temperatures for HVAC applications.
Chapter-4 Circuit Diagram

2D model of the component (TO-92):

LM35 temperature sensor circuit configuration

LM35 can be used in two circuit configurations. Both yield different results.
In the first configuration, you can only measure the positive temperature from
2 degrees Celsius to 150 degrees Celsius. In this first configuration, we simply
power lm35 and connect the output directly to analog to digital converters. In
the second configuration, we can utilize all the sensor resources and can
measure the full range temperature from -55 degree centigrade to 150-degree
centigrade. This configuration is a little complex but yields high results. We
have to connect an external resistor, in this case, to switch the level of negative
voltage upwards. The external resistor value can be calculated from the
formula given below the configuration circuit. The second configuration
circuit can be made in various ways.To see about the second configuration
Chapter-4 Circuit Diagram

circuits visit the LM35 datasheet by Texas Instruments. Texas


Instruments data sheet enlists the circuit with clear component values.

Although the first configuration did not need a resistor at the output side, I recommend
connecting an 80 k to 100 k resistor between vout and gnd pin. When I performed
several experiments I noticed that the readings some time fluctuate and the vout pin
floats. So a resistor between vout and gnd tights the vout pin low and prevents the pin
from floating.

LM35
accuracy level
The accuracy parameters for both configurations are different. The average
accuracy level is +- 1 degree Celsius for both configurations. But the accuracy
level decreases for temperature between 2 degrees to 25-degree centigrade.
Now that we have discussed the LM35 temperature sensor pinout, structure,
linear scale factor and accuracy level its time to list down the steps on how to
measure temperature using LM35 temperature sensor.

Steps to calculate temperature using LM35 temperature sensor


Formula to convert
• Build circuit. voltage to temperature
• Power LM35 vcc to +5-
20 volts and gnd to The formula to convert the
ground. voltage to centigrade
• Connect Vout to analog temperature for LM35 is
to digital converter Centigrade Temperature =
input. Voltage Read by ADC / 10
• Sample the ADC mV(mills Volt)
reading, vout output
voltage.
I divided by 10 mV because
• Convert the voltage to Linear scale factor is for LM35 is
temperature. 10mV.

Following the above steps and tutorial, you can easily interface LM35
temperature sensor with any microcontroller that has a built-in analog to
Chapter-4 Circuit Diagram

digital converter pins. Almost all the microcontrollers today have built-in
ADC.
Chapter 5 Arduino and ESP modules

CHAPTER 5
ARDUINO UNO AND ESP8266 MODULES
5.1 ARDUINO:

5.1.1 Introduction:

The Arduino UNO is an open-source microcontroller board based on the


Microchip ATmega328P microcontroller and developed by arduino. The board is
equipped with sets of digital and analog input/output (I/O) pins that may be interfaced
to various expansion boards (shields) and other circuits. The board has 14 Digital pins,
6 Analog pins, and programmable with the Arduino IDE (Integrated Development
Environment) via a type B USB cable. It can be powered by a USB cable or by an
external 9 volt battery, though it accepts voltages between 7 and 20 volts. It is also
similar to the Arduino Nano and Leonardo. The hardware reference design is distributed
under a Creative Commons Attribution Share-Alike 2.5 license and is available on the
Arduino website. Layout and production files for some versions of the hardware are
also available.

"Uno" means one in Italian and was chosen to mark the release of Arduino
Software (IDE). The Uno board and version 1.0 of Arduino Software (IDE) were the
reference versions of Arduino, now evolved to newer releases. The Uno board is the
first in a series of USB Arduino boards, and the reference model for the Arduino
platform. The ATmega328 on the Arduino Uno comes preprogrammed with a boot
loader that llows uploading new code to it without the use of an external hardware
programmer. It communicates using the original STK500 protocol. The Uno also
differs from all preceding boards in that it does not use the FTDI USB-to-serial driver
chip. Instead, it uses the Atmega16U2 (Atmega8U2 up to version R2) programmed as
a USB-to-serial converter.

5.1.2 History of arduino:

The Arduino project started at the Interaction Design Institute Ivrea (IDII) in
Ivrea, Italy. At that time, the students used a BASIC Stamp microcontroller at a cost of
$100, a considerable expense for many students. In 2003 Hernando Barragán created
the development platform wiring as a Master's thesis project at IDII, under the
supervision of Massimo Banzi and Casey Reas, who are known for work on the
Chapter 5 Arduino and ESP modules

Processing language. The project goal was to create simple, low-cost tools for creating
digital projects by nonengineers. The Wiring platform consisted of a printed circuit
board (PCB) with an ATmega168 microcontroller, an IDE based on Processing and
library functions to easily program the microcontroller. In 2003, Massimo Banzi, with
David Mellis, another IDII student, and David Cuartielles, added support for the
cheaper ATmega8 microcontroller to Wiring. But instead of continuing the work on
Wiring, they forked the project and renamed it Arduino. Early arduino boards used the
FTDI USB-to-serial driver chip and an ATmega168. The Uno differed from all
preceding boards by featuring the ATmega328P microcontroller and an ATmega16U2
(Atmega8U2 up to version R2) programmed as a USB-to-serial converter.

5.1.3 Technical Specifications:

• Microcontroller: Microchip ATmega328P


• Operating Voltage: 5 Volts
• Input Voltage: 7 to 20 Volts
• Digital I/O Pins: 14 (of which 6 provide PWM output)
• Analog Input Pins: 6
• DC Current per I/O Pin: 20 mA
• DC Current for 3.3V Pin: 50 mA
• Flash Memory: 32 KB of which 0.5 KB used by bootloader
• SRAM: 2 KB
• EEPROM: 1 KB
• Clock Speed: 16 MHz
• Length: 68.6 mm
• Width: 53.4 mm
• Weight: 25g
Chapter 5 Arduino and ESP modules

5.1.4 Pin Description:

Fig. 5.1 Pin diagram for ATMEGA328P


5.1.5 General Pin description:

LED: There is a built-in LED driven by digital pin 13. When the pin is HIGH value,
the LED is on, when the pin is LOW, it's off.

Vin: The input voltage to the Arduino/Genuino board when it's using an external power
source (as opposed to 5 volts from the USB connection or other regulated power
source). You can supply voltage through this pin, or, if supplying voltage via the power
jack, access it through this pin.

5V: This pin outputs a regulated 5V from the regulator on the board. The board can be
supplied with power either from the DC power jack (7 - 20V), the USB connector (5V),
or the VIN pin of the board (7-20V). Supplying voltage via the 5V or 3.3V pins
bypasses the regulator, and can damage the board.

3.3V: A 3. 3 volt supply generated by the on-board regulator. Maximum current draw
is 50 mA.

GND: Ground pins.

IOREF: This pin on the Arduino/Genuino board provides the voltage reference with
which the microcontroller operates. A properly configured shield can read the IOREF
pin voltage and select the appropriate power source or enable voltage translators on the
outputs to work with the 5V or 3.3V.
Chapter 5 Arduino and ESP modules

Reset: Typically used to add a reset button to shields which block the one on the board.

5.1.6 Special Pin Functions:

Each of the 14 digital pins and 6 Analog pins on the Uno can be used as an input
or output, using pin Mode (), digital Write (), and digital Read () functions. They operate
at 5 volts. Each pin can provide or receive 20 mA as recommended operating condition
and has an internal pull-up resistor (disconnected by default) of 20-50k ohm. A
maximum of 40mA is the value that must not be exceeded on any I/O pin to avoid
permanent damage to the microcontroller. The Uno has 6 analog inputs, labeled A0
through A5, each of which provide 10 bits of resolution (i.e. 1024 different values). By
default they measure from ground to 5 volts, though is it possible to change the upper
end of their range using the AREF pin and the Analog Reference () function.

In addition, some pins have specialized functions:

• Serial / UART: pins 0 (RX) and 1 (TX). Used to receive (RX) and transmit
(TX) TTL serial data. These pins are connected to the corresponding pins of the
ATmega8U2 USB to-TTL Serial chip.
• External Interrupts: pins 2 and 3. These pins can be configured to trigger an
interrupt on a low value, a rising or falling edge, or a change in value.
• PWM (Pulse Width Modulation): 3, 5, 6, 9, 10, and 11 Can provide 8-bit PWM
output with the analog Write () function.
• SPI (Serial Peripheral Interface): 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK).
These pins support SPI communication using the SPI library.
• TWI (Two Wire Interface) / I²C: A4 or SDA pin and A5 or SCL pin. Support
TWI communication using the Wire library.
• AREF (Analog Reference): Reference voltage for the analog inputs.
Chapter 5 Arduino and ESP modules

Fig. 5.2 Arduino UNO


Pin 1: Power USB

Arduino board can be powered by using the USB cable from your computer. All you
need to do is connect the USB cable to the USB connection.

Pin 2: Power (Barrel Jack)

Arduino boards can be powered directly from the AC mains power supply by
connecting it to the Barrel Jack.

Pin 3: Voltage Regulator

The function of the voltage regulator is to control the voltage given to the Arduino
board and stabilize the DC voltages used by the processor and other elements.

Pin 4: Crystal Oscillator


Chapter 5 Arduino and ESP modules

The crystal oscillator helps Arduino in dealing with time issues. How does Arduino
calculate time? The answer is, by using the crystal oscillator. The number printed on
top of the Arduino crystal is 16.000H9H. It tells us that the frequency is 16,000,000
Hertz or 16 MHz

Pins 5, 17: Arduino Reset you can reset your Arduino board, i.e., start your program
from the beginning. You can reset the UNO board in two ways. First, by using the reset
button (17) on the board. Second, you can connect an external reset button to the
Arduino pin labelled RESET (5).

Pins 6, 7, 8, 9: Pins (3.3, 5, GND, Vin)

• 3.3V (6) − Supply 3.3 output volt


• 5V (7) − Supply 5 output volt
• Most of the components used with Arduino board works fine with 3.3 volt and
5 volt.
• GND (8) (Ground) − There are several GND pins on the Arduino, any of which
can be used to ground your circuit.
• Vin (9) − This pin also can be used to power the Arduino board from an external
power source, like AC mains power supply.

Pin 10: Analog pins

The Arduino UNO board has six analog input pins A0 through A5. These pins
can read the signal from an analog sensor like the humidity sensor or temperature sensor
and convert it into a digital value that can be read by the microprocessor.

Pin 11: Main microcontroller

Each Arduino board has its own microcontroller (11). You can assume it as the
brain of your board. The main IC (integrated circuit) on the Arduino is slightly different
from board to board. The microcontrollers are usually of the ATMEL Company. You
must know what IC your board has before loading up a new program from the Arduino
IDE. This information is available on the top of the IC. For more details about the IC
construction and functions, you can refer to the data sheet.
Chapter 5 Arduino and ESP modules

Pin 12: ICSP pin

Mostly, ICSP (12) is an AVR, a tiny programming header for the Arduino
consisting of MOSI, MISO, SCK, RESET, VCC, and GND. It is often referred to as an
SPI (Serial Peripheral Interface), which could be considered as an "expansion" of the
output. Actually, you are slaving the output device to the master of the SPI bus.

Pin 13: Power LED indicator

This LED should light up when you plug your Arduino into a power source to
indicate that your board is powered up correctly. If this light does not turn on, then there
is something wrong with the connection.

Pin 14: TX and RX LEDs

On your board, you will find two labels: TX (transmit) and RX (receive). They
appear in two places on the Arduino UNO board. First, at the digital pins 0 and 1, to
indicate the pins responsible for serial communication. Second, the TX and RX led
(13). The TX led flashes with different speed while sending the serial data. The speed
of flashing depends on the baud rate used by the board. RX flashes during the receiving
process.

Pin 15: Digital I/O

The Arduino UNO board has 14 digital I/O pins (15) (of which 6 provide PWM
(Pulse Width Modulation) output. These pins can be configured to work as input digital
pins to read logic values (0 or 1) or as digital output pins to drive different modules like
LEDs, relays, etc. The pins labeled “~” can be used to generate PWM.

Pin 16: AREF

AREF stands for Analog Reference. It is sometimes, used to set an external


reference voltage (between 0 and 5 Volts) as the upper limit for the analog input pins.
Chapter 5 Arduino and ESP modules

5.2 ESP8266 MODULE:

5.2.1 Introduction:

The ESP8266 arduino compatible module is a low-cost Wi-Fi chip with full
TCP/IP capability, and the amazing thing is that this little board has a MCU (Micro
Controller Unit) integrated which gives the possibility to control I/O digital pins via
simple and almost pseudo-code like programming language. This device is produced
by Shanghai-based Chinese manufacturer, Espressif Systems.

This chip was first time seen in August 2014, in ESP-01 version module, made
by AI-Thinker, a third-party manufacturer. This little module allows the MCU to
connect to WiFi network and create simple TCP/IP connections.

5.2.2 Technical Specifications:

• 32-bit RISC CPU: Tensilica Xtensa LX106 running at 80 MHz **


• 64 KiB of instruction RAM, 96 KiB of data RAM
• External QSPI flash – 512 KiB to 4 MiB* (up to 16 MiB is supported)
• IEEE 802.11 b/g/n Wi-Fi
• Integrated TR switch, balun, LNA, power amplifier and matching network
• WEP or WPA/WPA2 authentication, or open networks
• 16 GPIO pins **
• SPI, I²C,
• I²S interfaces with DMA (sharing pins with GPIO)
• UART on dedicated pins, plus a transmit-only UART can be enabled on GPIO2
• 1 10-bit ADC

ESP8266 Arduino module comes with PCB trace antenna which seems to have
a very good coverage. Other version can have on-board ceramic antenna or an external
connector which allows you to attach external Wi-Fi antennas modules. ESP-01 has
only 6 active pins, although the MCU can support up to 16 I/O. Board dimensions are
14.3 x 24.8 mm.
Chapter 5 Arduino and ESP modules

Fig. 5.3 ESP8266 Module

Over the internet it found that ESP8266 arduino module, version 01, is sold in
two or more versions, which at first glance seem quite the same. After buying both of
them I saw that there is a difference in size of the flash memory. You may encounter
issues while flashing if you don’t make the proper settings according to board
specifications. Although the board default has 2 available GPIOs, you can do some
workarounds and use other MCU available pins if you have the proper soldering tools.
I managed to use GPIO 16 in order to wake up the device after DEEP SLEEP mode.

5.2.3 Pin Description:

Fig. 5.4 pin diagram of esp8266


Chapter 5 Arduino and ESP modules

Pins are arranged in two rows, having 4 on each row. Some models have pin
description on the PCB, which make it simple. On the top row you can find following
pins from the left to the right:

1. GND (Ground from power supply)

2. GPIO2 (Digital I/O programmable)

3. GPIO0 (Digital I/O programmable, also used for BOOT modes)

4. RX – UART Receiving channel

On the bottom (second row) you can find:

1. TX – UART Transmitting channel

2. CH_PD (enable/power down, must be pulled to 3.3v directly or via resistor)

3. REST – reset, must be pulled to 3.3v)

4. VCC - 3. 3v power supply

5.2.4 Power Supply and Current Consumption:

All esp8266 arduino compatible modules must be powered with DC current from any
kind of source that can deliver stable 3.3V and at least 250mA. Also logic signal is rated
at 3.3v and the RX channel should be protected by a 3.3v divisor step-down. You should
be careful when using this module with Arduino or other boards which supplies 5v,
because this module usually do not come with overpower protection and can be easily
destroyed.
Chapter-6 Software used

CHAPTER 6
SOFTWARE USED
6.1 ARDUINO IDE SOFTWARE:

Arduino IDE is an open-source software program that allows users to write


and upload code within a real-time work environment. As this code will thereafter be
stored within the cloud, it is often utilized by those who have been searching for an
extra level of redundancy. The system is fully compatible with any Arduino software
board.

The Arduino Integrated Development Environment - or Arduino Software


(IDE) - contains a text editor for writing code, a message area, a text console, a toolbar
with buttons for common functions and a series of menus. It connects to the Arduino
and Genuino hardware to upload programs and communicate with them.
6.1.1 Writing Sketches:
Programs written using Arduino Software (IDE) are called sketches. These
sketches are written in the text editor and are saved with the file extension .ino. The
editor has features for cutting/pasting and for searching/replacing text. The message
area gives feedback while saving and exporting and also displays errors. The console
displays text output by the Arduino Software (IDE), including complete error
messages and other information. The bottom righthand corner of the window displays
the configured board and serial port.
The toolbar buttons allow you to verify and upload programs, create, open, and
save sketches, and open the serial monitor.
6.1.2 Sketchbook:
The Arduino Software (IDE) uses the concept of a sketchbook: a standard
place to store your programs (or sketches). The sketches in your sketchbook can be
opened from the File > Sketchbook menu or from the Open button on the toolbar. The
first time you run the Arduino software, it will automatically create a directory for
your sketchbook. You can view or change the location of the sketchbook location from
with the Preferences dialog.
6.1.3 Uploading:
Before uploading your sketch, you need to select the correct items from the
Tools > Board and Tools > Port menus. The boards are described below. On the Mac,
Chapter-6 Software used

the serial port is probably something like /dev/tty.usbmodem241 (for a Uno or


Mega2560 or Leonardo) or /dev/tty.usbserial-1B1 or /dev/tty.USA19QW1b1P1.1. On
Windows, it's probably COM1 or COM2 (for a serial board) or COM4,
COM5, COM7, or higher (for a USB board) - to find out, you look for USB serial
device in the ports section of the Windows Device Manager. On Linux, it should be
/dev/ttyACMx, /dev/ttyUSBx or similar. Once you've selected the correct serial port
and board, press the upload button in the toolbar or select the Upload item from the
Sketch menu. Current Arduino boards will reset automatically and begin the upload.
With older boards (pre-Diecimila) that lack auto-reset, you'll need to press the reset
button on the board just before starting the upload. On most boards, you'll see the RX
and TX LEDs blink as the sketch is uploaded. The Arduino Software (IDE) will
display a message when the upload is complete, or show an error.
When you upload a sketch, you're using the Arduino boot loader, a small
program that has been loaded on to the microcontroller on your board. It allows you
to upload code without using any additional hardware. The boot loader is active for a
few seconds when the board resets; then it starts whichever sketch was most recently
uploaded to the microcontroller. The boot loader will blink the on-board (pin 13) LED
when it starts (i.e. when the board resets).
6.1.4 Libraries:
Libraries provide extra functionality for use in sketches, e.g. working with
hardware or manipulating data. To use a library in a sketch, select it from the Sketch
to Import Library menu. This will insert one or more #include statements at the top of
the sketch and compile the library with your sketch. Because libraries are uploaded to
the board with your sketch, they increase the amount of space it takes up. If a sketch
no longer needs a library, simply delete its #include statements from the top of your
code.
6.1.5 Compilation steps:
• Install the Arduino Programmer, aka the integrated development
environment (IDE).
• Connect your Arduino to the USB port of your computer. This may require
a specific USB cable. Every Arduino has a different virtual serial-port
address, so you will need to reconfigure the port if you're using different
Arduinos.
Chapter-6 Software used

• Set the board type and the serial port in the Arduino Programmer.

• Test the microcontroller by using one of the preloaded programs, called


sketches, in the Arduino Programmer. Open one of the example sketches,
and press the upload button to load it. The Arduino should begin
responding to the program: If you've set it to blink an LED light, for
example, the light should start blinking.
• To upload new code to the Arduino, either you'll need to have access to
code you can paste into the programmer, or you'll have to write it yourself,
using the Arduino programming language to create your own sketch. An
Arduino sketch usually has five parts: a header describing the sketch and
its author; a section defining variables; a setup routine that sets the initial
conditions of variables and runs preliminary code; a loop routine, which is
where you add the main code that will execute repeatedly until you stop
running the sketch; and a section where you can list other functions that
activate during the setup and loop routines. All sketches must include the
setup and loop routines.
• Once you've uploaded the new sketch to your Arduino, disconnect it from
your computer and integrate it into your project as directed

You might also like