Sunteți pe pagina 1din 37

10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

Sign In (https://www.hackster.io/users/auth/arduino?
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsmoke-
detection-using-mq-2-gas-sensor-79c54a)
Arduino Project Hub
ARDUINO CREATE IS
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON
CHROME OS!

(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
DOWNLOAD THE APP

Device Manager
(https://create.arduino.cc/devices)

Digital
Store
(https://store.arduino.cc/digital/)

Arduino Web Editor


(https://create.arduino.cc/editor)

Smoke Detection using


Arduino MQ-2 Gas Sensor
IoT Cloud
(https://create.arduino.cc/iot)
© LGPL (http://opensource.org/licenses/lgpl-license)
(https://www.hackster.io/users/auth/arduino?
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
In this tutorial, we will learn how to detect
detection-using-mq-2-gas-sensor-79c54a)
Getting Smoke and inflammable gases
Started
using an MQ-2 sensor.
(https://create.arduino.cc/getting-started)
NOW CHROME
OS environmental
READY! sensing (/projecthub/projects/tags/environmental+sensing)
home automation (/projecthub/projects/tags/home+automation)

monitoring (/projecthub/projects/tags/monitoring)

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 1/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

293,372 VIEWS 49 COMMENTS 187 RESPECTS

ARDUINO CREATE IS
Arduino Project Hub
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON
CHROME OS!

COMPONENTS AND SUPPLIES


(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-

CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
DOWNLOAD THE APP
Arduino UNO & Genuino
UNO
× 1 
(/projecthub/products/buy/
( (/proj (/projecthub/product
41? Device Manager
/ ecthu s/buy/41?
s=BAhJIhIxOTc4MSxQcm9qZ
(https://create.arduino.cc/devices) p b/pro s=BAhJIhIxOTc4MSxQ
(/projecthub/pro WN0BjoGRUY%3D%0A)
r ducts cm9qZWN0BjoGRUY%
ducts/buy/41?
o /buy/ 3D%0A)
s=BAhJIhIxOTc4
j 41?
MSxQcm9qZWN
e s=BA
0BjoGRUY%3D%
c hJIhIx
0A)
t OTc4
h MSxQ
Digital u cm9q
Store
b ZWN
(https://store.arduino.cc/digital/) / 0Bjo
p GRUY
r %3D
Arduino Web Editor
o %0A)
(https://create.arduino.cc/editor) d
u
c
t
Arduino IoT Cloud
s
(https://create.arduino.cc/iot) /
b
(https://www.hackster.io/users/auth/arduino?
u
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Getting Startedy
detection-using-mq-2-gas-sensor-79c54a)
/
(https://create.arduino.cc/getting-started)
NOW CHROME 4
OS READY! 1
?
s
=
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 2/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

B
A
h
Arduino Project Hub
ARDUINO CREATE IS
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON JI
CHROME OS! h
I
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
x
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
O
DOWNLOAD THE APP
T
c
4
Device ManagerM
S
(https://create.arduino.cc/devices)
x
Q
c
m
9
q
Z
W
Digital
N
Store
0
(https://store.arduino.cc/digital/) B
j
o
Arduino Web Editor
G
(https://create.arduino.cc/editor) R
U
Y
%
Arduino IoT Cloud
3
(https://create.arduino.cc/iot) D
(https://www.hackster.io/users/auth/arduino?
%
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
0
detection-using-mq-2-gas-sensor-79c54a)
Getting StartedA
)
(https://create.arduino.cc/getting-started)
NOW CHROME
OS READY!
×
(
/
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 3/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub
/
Breadboard (generic) p
(/projecthub/products/buy/ r
A R D U I N O C R E A T E42749?
IS Arduino Project Hub
o 1 
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON j (/proj (/projecthub/product
CHROME OS! s=BAhJIhIxOTc4MSxQcm9qZ
WN0BjoGRUY%3D%0A) e ecthu s/buy/42749?
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
(/projecthub/pro c b/pro s=BAhJIhIxOTc4MSxQ
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
ducts/buy/42749 t ducts cm9qZWN0BjoGRUY%
DOWNLOAD THE APP
? h /buy/ 3D%0A)
s=BAhJIhIxOTc4 u 4274
MSxQcm9qZWN b 9?
0BjoGRUY%3D% / s=BA
Device Managerp hJIhIx
0A)
(https://create.arduino.cc/devices) r OTc4
o MSxQ
d cm9q
u ZWN
c 0Bjo
t GRUY
s %3D
/ %0A)
Digital b
Store u
(https://store.arduino.cc/digital/) y
/
4
2
Arduino Web Editor
7
(https://create.arduino.cc/editor)
4
9
?
s
Arduino IoT Cloud
=
(https://create.arduino.cc/iot)
B
(https://www.hackster.io/users/auth/arduino?
A
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
h
Getting Started
detection-using-mq-2-gas-sensor-79c54a)
JI
(https://create.arduino.cc/getting-started)
h
NOW CHROME
I
OS READY! x
O
T
c
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 4/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub
c
4
M
ARDUINO CREATE IS
Arduino Project Hub
S
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON
x
CHROME OS!
Q
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO- c
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE) m
DOWNLOAD THE APP 9
q
Z
W
Device ManagerN
(https://create.arduino.cc/devices) 0
B
j
o
G
R
U
Y
Digital %
Store 3
(https://store.arduino.cc/digital/) D
%
0
Arduino Web EditorA
(https://create.arduino.cc/editor) )

MQ-2 Smoke detection sensor × 1

Arduino IoT Cloud


Male/Female Jumper Wires
(https://create.arduino.cc/iot)
(/projecthub/products/buy/
(https://www.hackster.io/users/auth/arduino? × 
42773?
(
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm (/projecthub/product
s=BAhJIhIxOTc4MSxQcm9qZ
detection-using-mq-2-gas-sensor-79c54a)
WN0BjoGRUY%3D%0A) Getting Started/ s/buy/42773?
p s=BAhJIhIxOTc4MSxQ
(https://create.arduino.cc/getting-started)
NOW CHROME r cm9qZWN0BjoGRUY%
OS READY! o 3D%0A)
j
e
c
t
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 5/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub
t
h
u
ARDUINO CREATE IS
Arduino Project Hub 1
b
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON (/proj
CHROME OS! /
ecthu
p
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
(/projecthub/pro b/pro
r
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
ducts/buy/42773 ducts
o
D
? OWNLOAD THE APP /buy/
d
s=BAhJIhIxOTc4 42773
u
?
MSxQcm9qZWN c
s=BA
0BjoGRUY%3D% t
0A)
Device Manager hJIhIx
s
(https://create.arduino.cc/devices) OTc4
/
MSxQ
b
cm9q
u
ZWN
y
0Bjo
/
GRUY
4
%3D
2
%0A)
7
Digital 7
Store 3
(https://store.arduino.cc/digital/) ?
s
=
Arduino Web Editor
B
(https://create.arduino.cc/editor) A
h
JI
h
Arduino IoT CloudI
(https://create.arduino.cc/iot) x
O
(https://www.hackster.io/users/auth/arduino?
T
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Getting Startedc
detection-using-mq-2-gas-sensor-79c54a)
4
(https://create.arduino.cc/getting-started)
NOW CHROME M
OS READY! S
x
Q
c
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 6/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

m
9
q
Arduino Project Hub
ARDUINO CREATE IS
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON Z
CHROME OS! W
N
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
0
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
B
DOWNLOAD THE APP
j
o
G
Device Manager
R
U
(https://create.arduino.cc/devices)
Y
%
3
D
%
0
A
)
Digital
5 mm LED: Red Store
(/projecthub/products/buy/
(https://store.arduino.cc/digital/)
× 1 
56525?
( (/proj (/projecthub/product
s=BAhJIhIxOTc4MSxQcm9qZ
/ ecthu s/buy/56525?
WN0BjoGRUY%3D%0A)
Arduino Web Editor
p b/pro s=BAhJIhIxOTc4MSxQ
(/projecthub/pro
(https://create.arduino.cc/editor) r ducts cm9qZWN0BjoGRUY%
ducts/buy/56525
o /buy/ 3D%0A)
?
s=BAhJIhIxOTc4 j 5652
e 5?
MSxQcm9qZWN Arduino IoT Cloud
c s=BA
0BjoGRUY%3D%
(https://create.arduino.cc/iot) t hJIhIx
0A) (https://www.hackster.io/users/auth/arduino?
h OTc4
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
u MSxQ
Getting Started
detection-using-mq-2-gas-sensor-79c54a)
b cm9q
(https://create.arduino.cc/getting-started)
/ ZWN
NOW CHROME p 0Bjo
OS READY! r GRUY
o %3D
d %0A)
u
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 7/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub
u
c
t
ARDUINO CREATE IS
Arduino Project Hub
s
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON /
CHROME OS!
b
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO- u
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE) y
DOWNLOAD THE APP /
5
6
5
Device Manager2
(https://create.arduino.cc/devices) 5
?
s
=
B
A
h
JI
Digital h
Store I
x
(https://store.arduino.cc/digital/)
O
T
c
Arduino Web Editor
4
(https://create.arduino.cc/editor)
M
S
x
Q
Arduino IoT Cloud
c
(https://create.arduino.cc/iot)
m
(https://www.hackster.io/users/auth/arduino?
9
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
q
detection-using-mq-2-gas-sensor-79c54a)
Getting Started
Z
(https://create.arduino.cc/getting-started)
W
NOW CHROME N
OS READY! 0
B
j
o
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 8/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub
o
G
R
ARDUINO CREATE IS
Arduino Project Hub
U
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON Y
CHROME OS!
%
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO- 3
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE) D
DOWNLOAD THE APP %
0
A
)
Device Manager
5 mm LED: Green
(https://create.arduino.cc/devices)
(/projecthub/products/buy/
× 1 
56524?
( (/proj (/projecthub/product
s=BAhJIhIxOTc4MSxQcm9qZ
/ ecthu s/buy/56524?
WN0BjoGRUY%3D%0A)
(/projecthub/pro p b/pro s=BAhJIhIxOTc4MSxQ
ducts/buy/56524 r ducts cm9qZWN0BjoGRUY%
o /buy/ 3D%0A)
?
j 5652
s=BAhJIhIxOTc4 Digital
MSxQcm9qZWN e 4?
Store
0BjoGRUY%3D% c s=BA
(https://store.arduino.cc/digital/) t hJIhIx
0A)
h OTc4
u MSxQ
Arduino Web Editor
b cm9q
(https://create.arduino.cc/editor) / ZWN
p 0Bjo
r GRUY
o %3D
Arduino IoT Cloud
d %0A)
(https://create.arduino.cc/iot) u
c
(https://www.hackster.io/users/auth/arduino?
t
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Getting Starteds
detection-using-mq-2-gas-sensor-79c54a)
/
(https://create.arduino.cc/getting-started)
NOW CHROME b
OS READY! u
y
/
5
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 9/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

6
5
2
Arduino Project Hub
ARDUINO CREATE IS
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON 4
CHROME OS! ?
s
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
=
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
B
DOWNLOAD THE APP
A
h
JI
Device Managerh
I
(https://create.arduino.cc/devices)
x
O
T
c
4
M
S
x
Digital
Q
Store
c
(https://store.arduino.cc/digital/) m
9
q
Arduino Web Editor
Z
(https://create.arduino.cc/editor) W
N
0
B
Arduino IoT Cloud
j
(https://create.arduino.cc/iot) o
(https://www.hackster.io/users/auth/arduino?
G
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
R
detection-using-mq-2-gas-sensor-79c54a)
Getting StartedU
Y
(https://create.arduino.cc/getting-started)
NOW CHROME %
OS READY! 3
D
%
0
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 10/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

A
)
ARDUINO CREATE IS Arduino Project Hub
Buzzer
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON
CHROME OS! (/projecthub/products/buy/
× 1 
42750?
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-( (/proj (/projecthub/product
s=BAhJIhIxOTc4MSxQcm9qZ
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE) / ecthu s/buy/42750?
WN0BjoGRUY%3D%0A)
DOWNLOAD THE APP p b/pro s=BAhJIhIxOTc4MSxQ
(/projecthub/pro
r ducts cm9qZWN0BjoGRUY%
ducts/buy/42750
? o /buy/ 3D%0A)
s=BAhJIhIxOTc4 j 4275
Device Managere 0?
MSxQcm9qZWN
(https://create.arduino.cc/devices) c s=BA
0BjoGRUY%3D%
0A) t hJIhIx
h OTc4
u MSxQ
b cm9q
/ ZWN
p 0Bjo
r GRUY
Digital o %3D
Store d %0A)
(https://store.arduino.cc/digital/) u
c
t
s
Arduino Web Editor
/
(https://create.arduino.cc/editor)
b
u
y
/
Arduino IoT Cloud
4
(https://create.arduino.cc/iot)
2
(https://www.hackster.io/users/auth/arduino?
7
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
5
Getting Started
detection-using-mq-2-gas-sensor-79c54a)
0
(https://create.arduino.cc/getting-started)
?
NOW CHROME
s
OS READY!
=
B
A
h
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 11/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub
h
JI
h
ARDUINO CREATE IS Arduino Project Hub
I
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON
x
CHROME OS!
O
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO- T
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE) c
DOWNLOAD THE APP 4
M
S
x
Device ManagerQ
(https://create.arduino.cc/devices) c
m
9
q
Z
W
N
0
Digital B
Store j
(https://store.arduino.cc/digital/) o
G
R
Arduino Web EditorU
(https://create.arduino.cc/editor) Y
%
3
D
Arduino IoT Cloud%
(https://create.arduino.cc/iot) 0
A
(https://www.hackster.io/users/auth/arduino?
)
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Getting Started
detection-using-mq-2-gas-sensor-79c54a)
Resistor 221 ohm
(https://create.arduino.cc/getting-started)
(/projecthub/products/buy/
NOW CHROME 37914?
×
OS READY! s=BAhJIhIxOTc4MSxQcm9qZ (
/
WN0BjoGRUY%3D%0A)
p
r
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 12/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

o
j
e
Arduino Project Hub 3 
ARDUINO CREATE IS
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON c (/proj (/projecthub/product
CHROME OS! t ecthu s/buy/37914?
h b/pro s=BAhJIhIxOTc4MSxQ
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
(/projecthub/pro
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
u ducts cm9qZWN0BjoGRUY%
ducts/buy/37914 b /buy/ 3D%0A)
DOWNLOAD THE APP
? / 37914
s=BAhJIhIxOTc4 p ?
MSxQcm9qZWN r s=BA
0BjoGRUY%3D%
Device Managero hJIhIx
0A) d OTc4
(https://create.arduino.cc/devices)
u MSxQ
c cm9q
t ZWN
s 0Bjo
/ GRUY
b %3D
u %0A)
y
Digital
/
Store
3
(https://store.arduino.cc/digital/) 7
9
1
Arduino Web Editor
4
(https://create.arduino.cc/editor) ?
s
=
B
Arduino IoT Cloud
A
(https://create.arduino.cc/iot) h
(https://www.hackster.io/users/auth/arduino?
JI
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
h
Getting StartedI
detection-using-mq-2-gas-sensor-79c54a)
x
(https://create.arduino.cc/getting-started)
NOW CHROME O
OS READY! T
c
4
M
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 13/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

S
x
ARDUINO CREATE IS Q
Arduino Project Hub
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON c
CHROME OS! m
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO- 9
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE) q
DOWNLOAD THE APP Z
W
N
0
Device ManagerB
j
(https://create.arduino.cc/devices)
o
G
R
U
Y
%
3
Digital D
Store %
0
(https://store.arduino.cc/digital/)
A
)
Arduino Web Editor
(https://create.arduino.cc/editor)

APPS AND ONLINE SERVICES 

Arduino IoT Cloud


(https://create.arduino.cc/iot)
(https://www.hackster.io/users/auth/arduino?
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Getting Started
detection-using-mq-2-gas-sensor-79c54a)
Arduino IDE 
(https://create.arduino.cc/getting-started)
(https://www.arduino.cc/en/main (https://www.arduino.cc/en
NOW CHROME
(https://www.ar /software) /main/software)
OS READY!
duino.cc/en/mai
n/software)

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 14/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

AABOUT
R D U I N OTHIS
C R E APROJECT
TE IS Arduino Project Hub 

N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON
CHROME OS!
In this example, you will read the sensor analog output voltage and when the smoke
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
reaches a certain level, it will make sound a buzzer and a red LED will turn on.
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
When
D O W Nthe
L O Aoutput
D T H Evoltage
A P P is below  that level, a green LED will be on.

What is an MQ-2 Smoke Sensor?


Device Manager
The MQ-2 smoke sensor is sensitive to smoke and to the following flammable gases:
(https://create.arduino.cc/devices)
LPG
Butane
Propane
Methane
Alcohol
Hydrogen
Digital
The resistance of the sensor is different depending
Store on the type of the gas.
The smoke sensor has a built-in potentiometer that allows you to adjust the sensor
(https://store.arduino.cc/digital/)
sensitivity according to how accurate you want to detect gas.

Arduino Web Editor


(https://create.arduino.cc/editor)

Arduino IoT Cloud


(https://create.arduino.cc/iot)
(https://www.hackster.io/users/auth/arduino?
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Getting Started
detection-using-mq-2-gas-sensor-79c54a)
(https://create.arduino.cc/getting-started)
NOW CHROME
OS READY! MQ-2 sensor

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 15/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

ARDUINO CREATE IS
Arduino Project Hub
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON
CHROME OS!

(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
DOWNLOAD THE APP

Device Manager
(https://create.arduino.cc/devices)

Sensor Pin-out details

How does it Work?


Digital
The voltage that the sensor outputs changes accordingly to the smoke/gas level that
Store
exists in the atmosphere. The sensor outputs a voltage that is proportional to the
concentration of smoke/gas.
(https://store.arduino.cc/digital/)

In other words, the relationship between voltage and gas concentration is the
following:
Arduino Web Editor
The greaterthe gas concentration,the greaterthe output voltage
(https://create.arduino.cc/editor)
The lowerthe gas concentration,the lowerthe output voltage

Arduino IoT Cloud


(https://create.arduino.cc/iot)
(https://www.hackster.io/users/auth/arduino?
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Getting Started
detection-using-mq-2-gas-sensor-79c54a)
(https://create.arduino.cc/getting-started)
NOW CHROME
OS READY!

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 16/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

ARDUINO CREATE IS
Arduino Project Hub
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON
CHROME OS!

(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
DOWNLOAD THE APP
The output can be an analog signal (A0) that can be read with an analog input of the
Arduino or a digital output (D0) that can be read with a digital input of the Arduino.

Device Manager
Pin Wiring
(https://create.arduino.cc/devices)

The MQ-2 sensor has 4 pins.


Pin-------------------------------------Wiring to Arduino Uno
A0-------------------------------------Analog pins
D0-------------------------------------Digital pins
GND-----------------------------------GND
Digital
VCC------------------------------------5V
Store
So, before jumping into the coding part, let's check whether we've assembled all the
(https://store.arduino.cc/digital/)
necessary hardware components.

Arduino Web Editor


(https://create.arduino.cc/editor)

Arduino IoT Cloud


(https://create.arduino.cc/iot)
(https://www.hackster.io/users/auth/arduino?
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Getting Started
detection-using-mq-2-gas-sensor-79c54a)
(https://create.arduino.cc/getting-started)
NOW CHROME
OS READY!

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 17/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

ARDUINO CREATE IS Arduino Project Hub


N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON
CHROME OS!

(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
Kindly refer to the connection schematic attached below. After you've wired all the
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
components
D O W N L O A D properly,
T H E A P Pit's time to upload the necessary code.

Device Manager
CODE 

(https://create.arduino.cc/devices)

MQ-2 sensor code Arduino


  (/PROJECTHUB/CODE_FILES/60463/DOWNLOAD)

After setting up the hardware components properly, flash this code into your Arduino.
Feel free to adjust the variable " sensorThres " with a different threshold value.

Digital
Store
(https://store.arduino.cc/digital/)

Arduino Web Editor


(https://create.arduino.cc/editor)

Arduino IoT Cloud


(https://create.arduino.cc/iot)
(https://www.hackster.io/users/auth/arduino?
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Getting Started
detection-using-mq-2-gas-sensor-79c54a)
(https://create.arduino.cc/getting-started)
NOW CHROME
SCHEMATICS
OS READY!

C DOWNLOAD (HTTPS://HALCKEMY.S3.AMAZONAWS.COM/UPLOADS/IMAGE_FILE/FILE/149152/CIRCUIT-1.

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 18/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

o
n
n
ARDUINO CREATE IS Arduino Project Hub
e
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON
C
c H R O M E OS!
t
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
i
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
o
DOWNLOAD THE APP
n
s
c
h Device Manager
e
(https://create.arduino.cc/devices)
m
a
t
i
c
d
i
a Digital
g Store
r
(https://store.arduino.cc/digital/)
a
m
Arduino Web Editor
(https://create.arduino.cc/editor)

Arduino IoT Cloud


(https://create.arduino.cc/iot)
(https://www.hackster.io/users/auth/arduino?
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Getting Started
detection-using-mq-2-gas-sensor-79c54a)
(https://create.arduino.cc/getting-started)
NOW CHROME
OS READY!

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 19/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

ARDUINO CREATE IS Arduino Project Hub


N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON
CHROME OS!

(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
DOWNLOAD THE APP

Device Manager
(https://create.arduino.cc/devices)

Digital
Store
(https://store.arduino.cc/digital/)
COMMENTS 

Arduino Web Editor


Please log in (/projecthub/users/sign_in?
id=19781&m=project&reason=comment&redirect_to=%2Fprojecthub%2FAritro%2Fsm
(https://create.arduino.cc/editor)
oke-detection-using-mq-2-gas-sensor-79c54a%23comments) or sign up
(/projecthub/users/sign_up?
id=19781&m=project&reason=comment&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Arduino IoT Cloud
oke-detection-using-mq-2-gas-sensor-79c54a%23comments&source=popup) to
comment.(https://create.arduino.cc/iot)
(https://www.hackster.io/users/auth/arduino?
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Getting Started
detection-using-mq-2-gas-sensor-79c54a)
robysottini (/projecthub/robysottini)
(https://create.arduino.cc/getting-started)
NOW3 years
CHROME
ago
(/pr
OS
Hello!READY!
Very good job!!!
oject
hub/
I have a 3 pin MQ-2 gas sensor: GND, VCC and OUT. I connected the OUT pin to the a5
roby
analog Arduino pin. Is this correct?
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 20/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

sottiserial monitor shows:


The
Pin A0: 133
ni)
Pin A0: 134 Arduino Project Hub
ARDUINO CREATE IS
Pin
NOW A0:A V133
AILABLE ON
(https://create.arduino.cc/projecthub)
Pin
C H RA0:
O M134
E OS!
Pin A0: 135
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
Pin A0: 135
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
Pin A0: 136
DOWNLOAD THE APP
Pin A0: 135
Pin A0: 136
Pin A0: 136
Pin A0: 137
Pin A0: 137 Device Manager
Pin A0: (https://create.arduino.cc/devices)
137
Pin A0: 138
Pin A0: 138
Pin A0: 138
How can I know the 400 threshold is a healthy limit? Which unit use those number?
Thanks!
Roby
Digital
Store
(https://store.arduino.cc/digital/)
Ashu41 (/projecthub/Ashu41)
3 years ago
(/pr
Iam
ojectdoing this with mq135 sensor..can
Arduino Webit Editor
work? Or I have to chnge anything for
that
hub/ like code..connections? Can anyone pls help me???? Thnx in advanc
(https://create.arduino.cc/editor)
Ashu
1 thank
41)

Arduino IoT Cloud


(https://create.arduino.cc/iot)
AlexLPD (/projecthub/AlexLPD)
(https://www.hackster.io/users/auth/arduino?
2 years ago
(/pr
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Hi, I make some similar set up,
oject I noticeStarted
Getting
detection-using-mq-2-gas-sensor-79c54a) the sensors takes about 1 to two hrs to
warm
hub/ up to a level, I was reading the analog port and each time the reading get
(https://create.arduino.cc/getting-started)
NOWmore
Alex smaller, never the least once I have a steady reading I put my values (I
CHROME
think
LPD) 300 to 1024) And map the fuction, Something I noticed on this is once I
OS READY!
put to run on a smokers room, the values varies, But I think is for the
temperature of the AC.
Is this sensor affected by the AC air?
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 21/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

https://thingspeak.com/channels/423780
(https://thingspeak.com/channels/423780)
A R D U IThis
NO C isRthe
E A Tchannel
E IS Arduino Project Hub
by the way.
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON
CHROM Thanks
E O S ! and keep it up the good work.
-Alex.
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
DOWNLOAD THE APP

dezo (/projecthub/dezo)
3 years ago
(/pr Device Manager
Hello
oject i dont have 221 ohm resistor right now so can i use 220 ohm? and thanks for all
of your (https://create.arduino.cc/devices)
hub/ answers
dezo
)

Abhijit Nathwani (/projecthub/abhijit-nathwani)


3 years ago
(/pr
Yes
ojectyou can.
hub/ Digital
abhij Store
it-
(https://store.arduino.cc/digital/)
nath (/projecthub/dezo)
dezo
wani
3 years ago
(/pr )
hello
oject i dont have 221 ohm resistorArduino
so can i Web
use 220 ohm resistor?
Editor
hub/ (https://create.arduino.cc/editor)
dezo
)
Zein Mariku (/projecthub/zein-mariku)
3 years ago Arduino IoT Cloud
(/pr
Hi sir 😃(https://create.arduino.cc/iot)
can i use arduino mega to this project? I want to use this project but i will
oject
(https://www.hackster.io/users/auth/arduino?
hub/ arduino uno to mega 😃
replace
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
zein-
Getting Started
detection-using-mq-2-gas-sensor-79c54a)
mari
ku) (https://create.arduino.cc/getting-started)
NOW CHROME ThothLoki (/projecthub/ThothLoki)
OS READY!
3 years ago
(/pr
That
oject shouldn't be a problem. Just make sure your pinouts are correct
hub/
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 22/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

Thot
hLok
i) Ashu41 (/projecthub/Ashu41)
ARDUINO CREATE IS Arduino Project Hub
3 years ago
N O W A(/pr
V A I L A BLE ON
(https://create.arduino.cc/projecthub)
CHROM E
Iam O S !
ojectdoing this with mq135 sensor..can it work? Or I have to chnge anything for
hub/ that like code..connections? Can anyone pls help me???? Thnx in advanc
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
Ashu
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
D O W N41)
LOAD THE APP

Ashu41 (/projecthub/Ashu41)
3 years ago
(/pr
Iam Device Manager
ojectdoing this with mq135 sensor..can it work? Or I have to chnge anything for
that like code..connections? Can anyone pls help me???? Thnx in advanc
(https://create.arduino.cc/devices)
hub/
Ashu
1 thank
41)

Ashu41 (/projecthub/Ashu41)
3 years ago
(/pr
Hi everyone. Iam doing this with mq135 Digital
oject sensor..can it work? Or I have to chnge
anything
hub/ for that like code..connections?Store
Can anyone pls help me???? Thnx in advance
Ashu (https://store.arduino.cc/digital/)
41)

ThothLoki (/projecthub/ThothLoki)
Arduino Web Editor
3 years ago
(https://create.arduino.cc/editor)
(/pr
Ioject
do not see why not. Check this out
https://hackaday.io/project/3475-sniffing-trinket/log/12363-mq135-arduino-
hub/
library
Thot (https://hackaday.io/project/3475-sniffing-trinket/log/12363-mq135-
arduino-library) Arduino IoT Cloud
hLok
i)(https://create.arduino.cc/iot)
(https://www.hackster.io/users/auth/arduino?
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Getting Started
detection-using-mq-2-gas-sensor-79c54a)
Ashu41 (/projecthub/Ashu41)
3 years ago
(https://create.arduino.cc/getting-started)
NOW(/pr
CHROME
Pls send me the connections to arduino uno ...and relevant code.pls help us....
oject
OS READY!
hub/
Ashu
41)
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 23/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

ThothLoki (/projecthub/ThothLoki)
3 years ago
(/pr
A R D U IHonestly,
N O C R E A IThave Arduino
E I S never worked with Project Hub
these modules or this library. If you have a
oject
N O W AgasV A sensor
I L A B L Ethat
O N is on a board with the pins available, usually you will have 3
(https://create.arduino.cc/projecthub)
hub/
CHROME OS!
(Vcc,
Thot Gnd, Sig)
Just
hLokconnect your analog pin to Sig, 5v to Vcc and Gnd to Gnd
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
i)
DOWNLOAD THE APP

Abhijit Nathwani (/projecthub/abhijit-nathwani)


3 years ago
(/pr Device Manager
Hello!
oject
If(https://create.arduino.cc/devices)
you choose MQ135, the connections and code will remain the same. MQ135
hub/
works
abhij on the same principle. So it won't be a problem. If you need any further
help,
it- let me know.
nath
Abhijit.
wani
)

Aayush Jha (/projecthub/aayush-jha)


Digital
3 years ago Store
(/pr
How
oject can we convert the output of MQ-2/MQ-7 into PPM. Basically to understand if
(https://store.arduino.cc/digital/)
air
hub/quality is fit for humans or not.
aayu
sh- Arduino Web Editor
jha) (https://create.arduino.cc/editor)
Yash Bawankar (/projecthub/yash-bawankar)
3 years ago
(/pr
In the Circuit Schematics you have used Arduino Compatible MQ-2 Gas Sensor.
oject Arduino IoT Cloud
Ihub/
am doing Schematics of my Project in Fritzing. I am getting lot of trouble in Finding
that (https://create.arduino.cc/iot)
yash Arduino Compatible MQ-2 Gas Sensor..So can you please me?
- (https://www.hackster.io/users/auth/arduino?
baw current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Getting Started
anka detection-using-mq-2-gas-sensor-79c54a)
r) (https://create.arduino.cc/getting-started)
Yash Bawankar (/projecthub/yash-bawankar)
NOW3 years
CHROME
ago
OS READY!
(/pr
You
ojecthave used Arduino Compatible Gas Sensor in Schematics.How can i get that
Arduino
hub/ Compatible Gas Sensor in my Fritzing Library..
Please
yash Help..!!
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 24/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

-
baw
anka KoKo Yangonite (/projecthub/koko-yangonite)
Arduino Project Hub
A R D U I2Nyears
O C Rago
EATE IS
r)
N O W A (https://create.arduino.cc/projecthub)
(/pr VAILABLE ON
C
ItHhelpedE me
R O M O S !a lot ! Thank you v v much ! I made it with MQ-135. I set ( int sensorThres
oject
= 200; )for smoke. I made it for fire alarm with siren circuit.
hub/
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
koko
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
-D O W N L O A D T H E A P P
yang
onit divyangk23 (/projecthub/divyangk23)
e) 2 years ago
(/pr
If i am not wrong analog input don'tDevice
oject have aManager
pinMode function.
so
hub/why (https://create.arduino.cc/devices)
you add in line 19?
divy
angk
23)
Ardit1995 (/projecthub/Ardit1995)
2 years ago
(/pr
Is there any problem if instead I use 1k ohm ?
oject
hub/ Digital
Ardit Store
1995
(https://store.arduino.cc/digital/)
) bob1609 (/projecthub/bob1609)
2 years ago
(/pr
Hello!
oject Arduino Web Editor
hub/
I am new to Arduino and this Project blew my mind.
(https://create.arduino.cc/editor)
bob1
One thing I don't understand, what are the numbers displayed in the serial monitor?
609)
What do those numbers represent?
Thank you Arduino IoT Cloud
Bob (https://create.arduino.cc/iot)
(https://www.hackster.io/users/auth/arduino?
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Getting Started
detection-using-mq-2-gas-sensor-79c54a)
Emon49 (/projecthub/Emon49)
(https://create.arduino.cc/getting-started)
NOW
(/pr
CHROME
2 years ago
OS
How READY!
oject can i connect the battery in this project ?? please give the diagram. Will i have to
change
hub/ the code?? please response..

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 25/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

Emo
n49) Sakib_021 (/projecthub/Sakib_021)
A R D U I2Nyears
O C Rago
EATE IS Arduino Project Hub
(/pr
N O W A (https://create.arduino.cc/projecthub)
VAILABLE ON
Everything
C H R O M E Ois
oject S !ok , but my buzzer isn't making any sound! 😦 plz help !
hub/
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
Saki
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
b_0
DOWNLOAD THE APP
21) miss_anku (/projecthub/miss_anku)
2 years ago
(/pr
Hey
ojectthe video is not available . Can you please upload the video which has the working
of MQ 2 gas sensor with the arduinoDevice
hub/ ?? Manager
miss (https://create.arduino.cc/devices)
_an
ku)
Rax1 (/projecthub/Rax1)
2 years ago
(/pr
Please
oject why was the 400 set as threshold for the sensor? any particular reason? Any
formula
hub/ for arriving at that?
Rax1
) Digital
Store
(https://store.arduino.cc/digital/)
Eunate Mayor - SIGFOX Universities Program Manager
(/projecthub/eunatemayor)
(/pr a year ago
ojec Arduino Web Editor
Hi,
thuI'm organising a student challenge for projects in IoT that can help save the planet
on (https://create.arduino.cc/editor)
b/ethe occasion of Earth's Day, using SIGFOX technology.
Iunat
really like your project, do you want to participate?
ema
Eunate - SIGFOX Universities Program Manager
yor)
Arduino IoT Cloud
https://www.sigfox.com/en/news/sensing-earth-sigfoxs-2018-universities-challenge
(https://www.sigfox.com/en/news/sensing-earth-sigfoxs-2018-universities-
(https://create.arduino.cc/iot)
challenge)
(https://www.hackster.io/users/auth/arduino?
https://www.hackster.io/contests/sigfoxuniversities
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
(https://www.hackster.io/contests/sigfoxuniversities)
detection-using-mq-2-gas-sensor-79c54a)
Getting Started
(https://create.arduino.cc/getting-started)
NOW CHROME
OS READY!
jeevitha1 (/projecthub/jeevitha1)
a year ago
(/pr
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 26/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

oject will u share a video regarding connections of this project as i ve' tried alot bt
PLease
stil nt able to crack send me link its a humble request
hub/
jeevi Arduino Project Hub
ARDUINO CREATE IS
tha1)
NOW AVAILABLE ON
(https://create.arduino.cc/projecthub)
CHROME OS!
vaner (/projecthub/vaner)
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
a year ago
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
(/pr
D
CanOWNLOAD THE APP
ojectit work with the MQ-4?
hub/
vane
r)
Device Manager
shihabulparvez (/projecthub/shihabulparvez)
a (https://create.arduino.cc/devices)
year ago
(/pr
Nice
oject job!!!
How
hub/ can i add time for code see on serial monitor.like...
4.20
shih pm co value: 400
4.21
abul pm co value: 413
4.22
parv pm co value: 413
4.23
ez) pm co value: 417
Plse help me...for code Digital
Store
(https://store.arduino.cc/digital/)

Gunotham (/projecthub/gunotham)
a year ago Arduino Web Editor
(/pr
Can
ojecti use REES52 5 3.3-5V Passive Buzzer Alarm Module as buzzer?? or should i have
(https://create.arduino.cc/editor)
to buy a normal buzzer?
hub/
gun
otha
m) Arduino IoT Cloud
Marite (/projecthub/Marite)
(https://create.arduino.cc/iot)
a (https://www.hackster.io/users/auth/arduino?
year ago
(/pr current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
Tengo
oject esta progamación de la detección de gas en niveles ppm pero a mi me gustaría
Getting Started
detection-using-mq-2-gas-sensor-79c54a)
detectarlos
hub/ en niveles más sensibles en ppb, qué le tendría que modificar para que me
arroje (https://create.arduino.cc/getting-started)
Mari los resultados que busco.
NOW
Muchas
te)
CHROME
gracias,
OS READY!dejo la programación que use
A continuación

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 27/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

#define MQ1 (0) //define la entrada analogica para el sensor


#define RL_VALOR (5) //define el valor de la resistencia mde carga en kilo ohms
#define RAL (9.83) // resistencia Arduino
del sensor en el aire
Project Hublimpio / RO, que se deriva de la
ARDUINO CREATE IS
tabla
N O W de Vla
A I hoja
L A B Lde
E Odatos
A (https://create.arduino.cc/projecthub)
N
#define
C H R O M EGAS_LP
OS! (0)
String inputstring = ""; //Cadena recibida desde el PC
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
float LPCurve[3] = {2.3,0.21,-0.47};
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
float Ro = 10;
DOWNLOAD THE APP
void setup(){
Serial.begin(9600); //Inicializa Serial a 9600 baudios
Serial.println("Iniciando ...");
//configuracion del sensor
Serial.print("Calibrando...\n"); Device Manager
Ro = Calibracion(MQ1); //Calibrando el sensor. Por favor de asegurarse que el sensor
(https://create.arduino.cc/devices)
se encuentre en una zona de aire limpio mientras se calibra
Serial.print("Calibracion finalizada...\n");
Serial.print("Ro=");
Serial.print(Ro);
Serial.print("kohm");
Serial.print("\n");
}
void loop() Digital
{ Store
Serial.print("LP:");
(https://store.arduino.cc/digital/)
Serial.print(porcentaje_gas(lecturaMQ(MQ1)/Ro,GAS_LP) );
Serial.print( "ppm" );
Serial.print(" "); Arduino Web Editor
Serial.print("\n");
(https://create.arduino.cc/editor)
delay(200);
}
float calc_res(int raw_adc)
{ Arduino IoT Cloud
return ((https://create.arduino.cc/iot)
((float)RL_VALOR*(1023-raw_adc)/raw_adc));
} (https://www.hackster.io/users/auth/arduino?
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
float Calibracion(float mq_pin){
int i; detection-using-mq-2-gas-sensor-79c54a)
Getting Started
float val=0;
(https://create.arduino.cc/getting-started)
NOW CHROME
for (i=0;i<50;i++) { //tomar múltiples muestras
OS+=READY!
val calc_res(analogRead(mq_pin));
delay(500);
}
val = val/50; //calcular el valor medio
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 28/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

val = val/RAL;
return val;
} Arduino Project Hub
ARDUINO CREATE IS
N O W lecturaMQ(int
float A (https://create.arduino.cc/projecthub)
V A I L A B L E O mq_pin){
N
CHROME OS!
int i;
float rs=0;
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
for (i=0;i<5;i++) {
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
rsO+=
D WN calc_res(analogRead(mq_pin));
LOAD THE APP
delay(50);
}
rs = rs/5;
return rs; Device Manager
}
(https://create.arduino.cc/devices)
int porcentaje_gas(float rs_ro_ratio, int gas_id){
if ( gas_id == GAS_LP ) {
return porcentaje_gas(rs_ro_ratio,LPCurve);
}
return 0;
}
int porcentaje_gas(float rs_ro_ratio, float *pcurve){
return (pow(10, (((log(rs_ro_ratio)-pcurve[1])/pcurve[2])
Digital + pcurve[0])));
} Store
1 thank (https://store.arduino.cc/digital/)

Arduino Web Editor


(https://create.arduino.cc/editor)
AadiP (/projecthub/AadiP)
a year ago
(/pr
Can
ojectthe Arduino mega be used for this project?
hub/ Arduino IoT Cloud
Aadi
(https://create.arduino.cc/iot)
P)
(https://www.hackster.io/users/auth/arduino?
Yowyow (/projecthub/Yowyow)
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
a year ago
detection-using-mq-2-gas-sensor-79c54a) Getting Started
(/pr
The
ojectcodes didnt work for me . Many errors
(https://create.arduino.cc/getting-started)
NOW
hub/ CHROME
OS READY!
Yow
yow)
AadiP (/projecthub/AadiP)

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 29/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

(/pr a year ago


oject
I have used the MQ-6 sensor for this project and the serial monitor gives me values
hub/ Arduino Project Hub
starting
A R D U I N from
O C R E181A Tall
E Ithe
S way up to 302 after which it remains constant. Are these
Aadi
N O W Acorrect?
V A I L A B LAlso
E O Nis the green LED supposed to light up when not exposed to gas?
values (https://create.arduino.cc/projecthub)
P)H R O M E O S !
C
The red LED does not flash and the buzzer remains silent even after exposure to gas.
The serial monitor too shows no change in the values. What should I do?
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
DOWNLOAD THE APP

Chanatip17 (/projecthub/Chanatip17)
10 months ago
(/pr Device Manager
how
ojectmany voltage using for this?
(https://create.arduino.cc/devices)
hub/
Cha
nati
p17) nabeelshah (/projecthub/nabeelshah)
9 months ago
(/pr
5 volt for the sensor from the arduino.
oject
hub/
nabe Digital
elsh Store
ah)
Tatenda (/projecthub/Tatenda)
(https://store.arduino.cc/digital/)
10 months ago
(/pr
hie please help on how to connect the components
oject
Arduino Web Editor
hub/
Tate (https://create.arduino.cc/editor)
nda)
Rentaircat Com (/projecthub/rtrisk)
10 months ago
(/pr Arduino IoT Cloud
Great!
oject Is(https://create.arduino.cc/iot)
there a method to include GPS lat long inside the SMS when triggered? Like a
drone
hub/ hosted MQ2 sensor? This would be helpful to record any location that detects
(https://www.hackster.io/users/auth/arduino?
gas.
rtris Thank you and great job!
current_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
k) detection-using-mq-2-gas-sensor-79c54a)
Getting Started
(https://create.arduino.cc/getting-started)
NOW CHROME
Hificoolguy (/projecthub/Hificoolguy)
OS READY!
10 months ago
(/pr
oject

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 30/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

ihub/
made the circuit and i also programmed it with the code provided but for some
reason the buzzer keeps buzzing and the leds wont turn on however the power led on
Hific
the MQ-2 was on
oolg Arduino Project Hub
ARDUINO CREATE IS
uy)
NOW AVAILABLE ON
(https://create.arduino.cc/projecthub)
CHROME OS!

(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
nabeelshah (/projecthub/nabeelshah)
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
D O W N9Lmonths
O A D T Hago
E APP
(/pr
hi i want to build the gas sensor for my home, is it good for practical use, if yes than
oject
in that case i want the sensor to detect the domestic gas in case of leakage in my
hub/
house.
nabe The code above works and i have a reading, now can anyone help me what is
the Device Manager
elshreading in case of leakage and again can it be used for practical use other than on
aah)
college project.
(https://create.arduino.cc/devices)

aang (/projecthub/aang)
8 months ago
(/pr
Can
ojectsomebody help me, to share MQ-2 part.
Fritzing
hub/ doesnt have MQ-2.
Digital
aang
Store
)
(https://store.arduino.cc/digital/)
LIM254018 (/projecthub/LIM254018)
8 months ago
(/pr
Ioject
have successful made it although im first time touch with mq2, really thx for ur
tutoraial,
hub/ i give u 5 star.
LIM2
5401
8) Arduino IoT Cloud
nagesh_madakasira (/projecthub/nagesh_madakasira)
(https://create.arduino.cc/iot)
7 months ago
(/pr (https://www.hackster.io/users/auth/arduino?
Hi Guyscurrent_site=arduino&setup=true&redirect_to=%2Fprojecthub%2FAritro%2Fsm
oject
Where
hub/ can I buy this MQ -2 gas sensor.
detection-using-mq-2-gas-sensor-79c54a)
Regards
nage
NOW
Nagesh.
sh_ CHROME
mad READY!
OS
akasi
ra)
kepinalek (/projecthub/kepinalek)
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 31/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

5 months ago

Can
(/pr I don't use the resistors, and use jumper wires instead ? What'll happen if I do that
?oject
A RDUINO CREATE IS
NOW AVAILABLE ON
hub/
CHROME OS!
kepi
(HTTPS://CHROME.GOOGLE.COM/WEBSTORE/DETAIL/ARDUINO-
nale
CREATE/DCGICPIHGKMCCJIGALCCIPMJLNJOPDFE)
k) RoseC (/projecthub/RoseC)
D O W N5Lmonths
OAD TH E APP
ago
(/pr
Should
oject I use active buzzer or a passive buzzer?
hub/
Rose
C)
muhdshaqilaqim (/projecthub/muhdshaqilaqim)
4 months ago
(/pr
can
ojectthis mq2 gas sensor detect cat litter ?
hub/
muh
dsha
qilaq srmounika (/projecthub/srmounika)
im) 23 days ago
(/pr
sir,advantage
oject ,disadvantages&applications
are
hub/not there
srm
ouni
ka)
sivabalaji (/projecthub/sivabalaji)
23 days ago
(/pr
hello!i
oject want to insert LCD display with this so please send me the code for that
hub/
siva
balaj
i)
AUTHOR

(/projecthub/Aritro)
Aritro Mukherjee (/projecthub/Aritro)
6 PROJECTS 211 FOLLOWERS

FOLLOW (/PROJECTHUB/USERS/SIGN_UP?ID=15798&M=USER&REASON=FOLLOW&RE

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 32/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

PUBLISHED ON

May 6, 2016

 RESPECT PROJECT (/PROJECTHUB/USERS/SIGN_UP?ID=19781&M=ARTICLE&REASON=RESPECT...

 WRITE A COMMENT

 Share

MEMBERS WHO RESPECT THIS PROJECT

(/projecthub/raviprasad1234456789) (/projecthub/rajibghoshkolkata123456)

(/projecthub/abhishekkundu123456789) (/projecthub/sayanpatra123456)

(/projecthub/oeyhaga) (/projecthub/electromagus) (/projecthub/Automatek)

(/projecthub/user530780225)
and 179 others

SEE SIMILAR PROJECTS


YOU MIGHT LIKE

SIMILAR PROJECTS YOU MIGHT LIKE

(/projecthub/Aritro/security-access-using-rfid-reader-f7c746?
ref=similar&ref_id=19781&offset=0)

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 33/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

Security Access Using RFID Reader (/projecthub/Aritro/security-


access-using-rfid-reader-f7c746?
by Aritro Mukherjee (/projecthub/Aritro)
260,262 VIEWS 42 COMMENTS 281 RESPECTS

(/projecthub/jissanto/smoke-sensor-97e48b?ref=similar&ref_id=19781&offset=1)

Smoke Sensor (/projecthub/jissanto/smoke-sensor-97e48b?


ref=similar&ref_id=19781&offset=1)
https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 34/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

Project showcase by Jiss Anto (/projecthub/jissanto)


5,175 VIEWS 0 COMMENTS 8 RESPECTS

(/projecthub/aaronkow/iot-home-security-model-71e48e?
ref=similar&ref_id=19781&offset=2)

IoT Home Security Model (/projecthub/aaronkow/iot-home-


security-model-71e48e?ref=similar&ref_id=19781&offset=2)
Project showcase by Aaron Kow (/projecthub/aaronkow)
53,004 VIEWS 41 COMMENTS 155 RESPECTS

(/projecthub/nekhbet/using-the-yl-39-yl-69-soil-humidity-sensor-with-arduino-
968268?ref=similar&ref_id=19781&offset=3)

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 35/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

Using the YL-39 + YL-69 Soil Humidity Sensor with Arduino


(/projecthub/nekhbet/using-the-yl-39-yl-69-soil-humidity-
Project tutorial by Sorin Trimbitas (/projecthub/nekhbet)
28,112 VIEWS 6 COMMENTS 17 RESPECTS

(/projecthub/Isaac100/getting-started-with-the-hc-sr04-ultrasonic-sensor-036380?
ref=similar&ref_id=19781&offset=4)

Getting Started with the HC-SR04 Ultrasonic sensor


(/projecthub/Isaac100/getting-started-with-the-hc-sr04-
by Isaac100 (/projecthub/Isaac100)
22,758 VIEWS 1 COMMENT 23 RESPECTS

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 36/37
10/17/2019 Smoke Detection using MQ-2 Gas Sensor - Arduino Project Hub

(/projecthub/MichDragstar/ultrasonic-sensor-with-alarm-lcd-and-temperature-
a5dbab?ref=similar&ref_id=19781&offset=5)

Ultrasonic Sensor with Alarm, LCD and Temperature


(/projecthub/MichDragstar/ultrasonic-sensor-with-alarm-lcd-
Project tutorial by MichDragstar (/projecthub/MichDragstar)
5,212 VIEWS 7 COMMENTS 19 RESPECTS

(https://www.arduino.cc)
Powered by
(https://www.hackster.io)

https://create.arduino.cc/projecthub/Aritro/smoke-detection-using-mq-2-gas-sensor-79c54a 37/37

S-ar putea să vă placă și