INTRODUCTION
In this project, we are making an Iot-based gas level Indicator using Node MCU ESP8266-12e wi-fi board and MQ2 gas Sensor by interfacing with Thingspeak. We will show the measured data on the Thingspeak interface in a graph or a chart.
HARDWARE REQUIRED
- Node MCU (esp82 66-12e v1.0) Wi-Fi Board -1pc
- NodeMcu USB cable - 1pc
- MQ-2 Gas Sensor -1pc
- Jumper Wires (male to male) – 20 pcs
- 830 pt. Breadboard - 1pc
SOFTWARE REQUIRED
Arduino IDE 1.8.10 (programmable platform for Arduino)
Click here to download the software

SPECIFICATIONS
NodeMCU ESP8266 CP2102 Module:
The development board equips the ESP-12E module containing the ESP8266 chip, having a Tensilica Xtensa® 32-bit LX106 RISC microprocessor which operates at 80 to 160 MHz adjustable clock frequency and supports RTOS.
- Operating Voltage: 2.5v to 3.6v
- On-board 3.3V 600mA regulator
- 80ma Operating Current
- 20 µA during Sleep Mode

WARNING
The ESP8266 requires a 3.3v power supply and 3.3v logic levels for communication. The GPIO pins are not 5v-tolerant! You must do some level shifting if you want to interface the board with 5v (or higher) components.
MQ-2 Gas Sensor Module:
- Operating Voltage is +5v
- Can be used to measure or detect LPG, Alcohol, Propane, Hydrogen, CO and even methane
- Analogue output voltage: 0v to 5v
- Digital Output Voltage: 0V or 5V (TTL Logic)
- Preheat duration: 20 seconds
- Can be used as a digital or analogue sensor
- The Sensitivity of the digital pin can be varied using the potentiometer

Pin No: |
Pin Name: |
Description |
1 |
Vcc |
This pin powers the module, Typically, the operating voltage is +5v |
2 |
Ground |
Used to connect the module to the system ground |
3 |
Digital Out |
You can also use this sensor to get a digital output from this pin by setting a threshold value using the potentiometer |
4 |
Analog Out |
This pin outputs 0-5V analogue voltage based on the intensity of the gas |
LIBRARY REQUIRED
ThingSpeak - Click to open

CIRCUIT CONNECTION
- Connect the VCC pin of the MQ-2 Gas Sensor module to the Vin pin of NodeMCU ESP8266-12E Board.
- Connect the GND pin of the MQ-2 Gas Sensor module to the GND pin of the NodeMCU pin of the ESP8266-12E Board.
- Connect the D0 pin of the MQ-2 Gas Sensor module to the A0 pin of the NodeMCU ESP8266-12E board.

CODE
WORKING AND OUTPUT
Welcome to the IoT-based Gas Detector indicator circuit.
- Go to https://thingspeak.com/
- Sign up for the account.
- After signing up/signing in, go to my channel and create a new channel

- Now go to the API keys. Copy your API key and paste it into your Code.

After uploading the code, you will be able to see the readings after measuring the gas level in ppm on the Gas level monitoring system using the Thingspeak IOT platform, in which after several raised values, it will indicate as a graphical point where the Gas Level increases above the set value.
