In this tutorial we will show how to build ESP8266 gas sensor with EasyIoT server. We will show how to add new sensor types even if not supported in EasyIoT server.

Materials

-gas sensor module

 MQ-2 Gas Sensor Module Smoke Methane Butane MQ-2 Gas Sensor Module Smoke Methane Butane
$1.21
$1.22
MQ-7 Carbon Monoxide CO Gas Sensor Detection ModuleMQ-7 Carbon Monoxide CO Gas Sensor Detection Module
$1.41
$1.20
MQ-3 Alcohol Ethanol Sensor Breath Gas Detector Ethanol Detection MQ-3 Alcohol Ethanol Sensor Breath Gas Detector Ethanol Detection
$1.78
$1.59
MQ-4 Natural Gas Methane Detection SensorMQ-4 Natural Gas Methane Detection Sensor
$1.45
$1.29
MQ-5 Methane Gas Sensor mosuleMQ-5 Methane Gas Sensor mosule
$1.41
$1.10
MQ-6 Liquefied Petroleum Gas SensorMQ-6 Liquefied Petroleum Gas Sensor
$0.99
$1.19
MQ-135 Air Quality Sensor Hazardous Gas Detection ModuleMQ-135 Air Quality Sensor Hazardous Gas Detection Module
$1.41
$1.96

 

-ESP8266 module

ESP8266 ESP-01 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-01 Serial WIFI Wireless Transceiver Module
$2.11
$17.00
ESP8266 ESP-03 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-03 Serial WIFI Wireless Transceiver Module
$2.07
$2.15
ESP8266 ESP-12 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-12 Serial WIFI Wireless Transceiver Module
$2.06
$1.75
ESP8266 ESP-05 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-05 Serial WIFI Wireless Transceiver Module
$1.88
ESP8266 ESP-07 Serial WIFI Wireless Transceiver ModuleESP8266 ESP-07 Serial WIFI Wireless Transceiver Module
$2.18
$1.88
ESP8266 Lua Nodemcu WIFI Network Development BoardESP8266 Lua Nodemcu WIFI Network Development Board
$7.43
$2.65

 

-2N2222 NPN transistor

100Pcs NPN Transistor TO-92 2N2222100Pcs NPN Transistor TO-92 2N2222
$1.01
$0.90

 

-1K resistor

-68K resistor

400X 0.25w 1/4w Metal Film Resistor Pack Kit 1% 20 Value Each 20 Pcs 10 ~ 1M ohm400X 0.25w 1/4w Metal Film Resistor Pack Kit 1% 20 Value Each 20 Pcs 10 ~ 1M ohm
$1.88
$5.50

 

-10uF electrolytic capacitor

210Pcs 25 Value 0.1uF-220uF Electrolytic Capacitors Assortment Kit Set210Pcs 25 Value 0.1uF-220uF Electrolytic Capacitors Assortment Kit Set
$3.36
$6.52

 

There are different gas sensor modules on the market. Dependent on model it can be used to detect different gases. See buying guide for details.

ESP8266 gas sensor

EasyIoT sever

Add Virtual node in EasyIoT server interface. Currently there is no support for gas sensor so we will select Digital input (DI) type of sensor. Remember Virtual node address because we will need it later in program.

 

We want picture to represent gas sensor in EasyIoT user interface. We will add custom icon to EasyIoT server.

 

Add custom property "SettingsIcon" and set value to gas.png. Also save gas.png picture in custom icon folder.

Connections

Connections are very simple. Use gas sensor digital output and connect it to ESP8266 GPIO2 pin. Because ESP8266 operates on 3.3V and gas sensor operates on 5V we will add additional NPN transistor, two resistors and capacitor for voltage level sifter. Don't forget to add capacitor - it helps to set GPIO2 pin high during power on, to boot ESP8266 in correct state. 

gas sensor digital output

For power supply we recommend AMS1117 regulator or AMS1117 regulator module. See power supply in store.

ESP8266 gas sensor connection

Program

Program can be found on GitHub. Correct following lines in program (AP username password, server IP address, node address, EasyIoT server username and password):

//AP definitions

#define AP_SSID "your AP SSID"

#define AP_PASSWORD "your AP password"

// EasyIoT server definitions

#define EIOT_USERNAME    "admin"

#define EIOT_PASSWORD    "test"

#define EIOT_IP_ADDRESS  "192.168.1.5"

#define EIOT_PORT        80

#define EIOT_NODE        "N8S0"

 

Compile and load program with ESP8266 Arduino IDE. Read tutorial for direct ESP8266 programming in Arduino IDE.

ESP8266 gas sensor

 See more tutorials at ​http://iot-playground.com/build​

Buying guide

To support this site and EasyIoT framework development please buy in our store.

MQ-2 Gas Sensor Module Smoke Methane Butane

Detects the gas, natural gas, city gas, smoke

MQ-3 Alcohol Ethanol Sensor Breath Gas Detector Ethanol Detection

Alcohol sensor

MQ-4 Natural Gas Methane Detection Sensor

Natural Gas Methane sensor

MQ-5 Methane Gas Sensor mosule

Methane Gas Sensor

MQ-6 Liquefied Petroleum Gas Sensor

MQ-6 Liquefied Petroleum Gas Sensor

MQ-7 Carbon Monoxide CO Gas Sensor Detection Module

Carbon Monoxide CO Gas Sensor

MQ-135 Air Quality Sensor Hazardous Gas Detection Module

Air Quality Sensor

210Pcs 25 Value 0.1uF-220uF Electrolytic Capacitors Assortment Kit Set

400X 0.25w 1/4w Metal Film Resistor Pack Kit 1% 20 Value Each 20 Pcs 10 ~ 1M ohm

100Pcs NPN Transistor TO-92 2N2222

All purpose NPN transistor.

5pcs 3.3V regulator module 800mA

Basic regulator module based on AMS1117.

ESP8266 ESP-01 Serial WIFI Wireless Transceiver Module

ESP8266 Serial WIFI Wireless Transceiver Module

ESP8266 ESP-03 Serial WIFI Wireless Transceiver Module

ESP8266 serial WIFI model ESP-03

ESP8266 ESP-12 Serial WIFI Wireless Transceiver Module

ESP8266 serial Port WIFI wireless module ESP-12

ESP8266 ESP-05 Serial WIFI Wireless Transceiver Module

ESP8266 ESP-05 Serial WIFI Wireless Transceiver Module

ESP8266 ESP-07 Serial WIFI Wireless Transceiver Module

ESP8266 with external antenna

ESP8266 serial WIFI wireless transceiver module 3DBI gain antenna

ESP8266 serial WIFI wireless transceiver module 3DBI gain antenna.

 

 

 


Comments   

#4 Lakshmi Sai kumar Jampani 2017-03-02 14:15
Can you please explain the process and project of same gas sensor with NodeMCU
+1 #3 DarioCdj 2015-06-19 15:42
Quoting DarioCdj:
Pheraps it seems to be the same problem of reed ? if gas sensor start in OFF mode esp-01 doesn't start in correct mode because it is connected to gpio2 ?


YES, with GPIO12 on ESP-12 it works.

How to make Icon1 works on ON status? I've named Sensor.Icon1 as Mr.EasyIoT describe...
+1 #2 DarioCdj 2015-06-18 23:32
Pheraps it seems to be the same problem of reed ? if gas sensor start in OFF mode esp-01 doesn't start in correct mode because it is connected to gpio2 ?
#1 DarioCdj 2015-06-18 23:27


Here is Icon1 for ON status...

You have no rights to post comments

Forum latest

  • No posts to display.