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 | |
$1.21 | |
$1.22 |
MQ-7 Carbon Monoxide CO Gas Sensor Detection Module | |
$1.41 | |
$1.20 |
MQ-3 Alcohol Ethanol Sensor Breath Gas Detector Ethanol Detection | |
$1.78 | |
$1.59 |
MQ-4 Natural Gas Methane Detection Sensor | |
$1.45 | |
$1.29 |
MQ-5 Methane Gas Sensor mosule | |
$1.41 | |
$1.10 |
MQ-6 Liquefied Petroleum Gas Sensor | |
$0.99 | |
$1.19 |
MQ-135 Air Quality Sensor Hazardous Gas Detection Module | |
$1.41 | |
$1.96 |
-ESP8266 module
ESP8266 ESP-01 Serial WIFI Wireless Transceiver Module | |
$2.11 | |
$17.00 |
ESP8266 ESP-03 Serial WIFI Wireless Transceiver Module | |
$2.07 | |
$2.15 |
ESP8266 ESP-12 Serial WIFI Wireless Transceiver Module | |
$2.06 | |
$1.75 |
ESP8266 ESP-05 Serial WIFI Wireless Transceiver Module | |
$1.88 |
ESP8266 ESP-07 Serial WIFI Wireless Transceiver Module | |
$2.18 | |
$1.88 |
ESP8266 Lua Nodemcu WIFI Network Development Board | |
$7.43 | |
$2.65 |
-2N2222 NPN transistor
100Pcs 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 ohm | |
$1.88 | |
$5.50 |
-10uF electrolytic capacitor
210Pcs 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.
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.
For power supply we recommend AMS1117 regulator or AMS1117 regulator module. See power supply in store.
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.
See more tutorials at http://iot-playground.com/build
Buying guide
To support this site and EasyIoT framework development please buy in our store.
Comments
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...
Here is Icon1 for ON status...
RSS feed for comments to this post