Gas Level Monitoring Over Internet Using ESP8266 & Gas Sensor

Gas Monitoring ESP8266 Gas Sensor (Last Updated On: May 25, 2019)

Gas Level Monitoring Over Internet Using ESP8266 & Gas Sensor

In this project we will learn about Gas Level Monitoring Over Internet Using ESP8266 & Gas Sensor Module, i.e MQ135. We will measure the quantity of gas in percentage and send it over the internet using the thingspeak server. With this system, the data can be monitored remotely staying at any part of the world. We just need gas/smoke/LPG sensor like MQ2/MQ3/MQ5/MQ7/MQ135 that is directly connected to Nodemcu ESP8266-12E Module.

ThingSpeak is an open source Internet of Things (IoT) application and API to store and retrieve data from things using the HTTP protocol over the Internet or via a Local Area Network.

You can check our earlier projects while are similar to the current project:
1. Alcohol Level Meter using Arduino & MQ-135 Alcohol/Gas Sensor
2. Arduino Smoke Level Detector using MQ-135 Sensor with Alert Alarm
3. Gas Leakage Detector with SMS Alert using GSM Module & Arduino

Components Required

Following are the components required for the project. All the components can be purchased from Amazon.

1. NodeMCU ESP8266 12E Board (Buy Online from Amazon)
2. MQ135 Gas Sensor (Buy Online from Amazon)
3. Breadboard
4. Connecting Wires

MQ135 Gas/Smoke Sensor


The MQ-135 gas sensor senses the gases like ammonia nitrogen, oxygen, alcohols, aromatic compounds, sulfide and smoke. The MQ-3 gas sensor has a lower conductivity to clean the air as a gas sensing material. In the atmosphere we can find polluting gases, but the conductivity of gas sensor increases as the concentration of polluting gas increases. MQ-135 gas sensor can be implementation to detect the smoke, benzene, steam and other harmful gases. It has potential to detect different harmful gases. It is with low cost and particularly suitable for Air quality monitoring application.

MQ135 Gas Smoke Sensor

The MQ135 sensor is a signal output indicator instruction. It has two outputs: analog output and TTL output. The TTL output is low signal light which can be accessed through the IO ports on the Microcontroller. The analog output is an concentration, i.e. increasing voltage is directly proportional to increasing concentration. This sensor has a long life and reliable stability as well.


• High Sensitivity
• High sensitivity to Ammonia, Sulfide and Benze
• Stable and Long Life
• Detection Range: 10 – 300 ppm NH3, 10 – 1000 ppm Benzene, 10 – 300 Alcohol
• Heater Voltage: 5.0V
• Dimensions: 18mm Diameter, 17mm High excluding pins, Pins – 6mm High
• Long life and low cost

Circuit Diagram & Connections

Make a connection as per circuit diagram below. Connect VCC pin of MQ135 to Vin of NodeMCU and GND to GND. Connect analog pin A0 of MQ135 to Analog pin A0 of NodeMCU.

Circuit Diagram Gas Level Monitoring ESP8266

Setting Thingspeak & Getting API Key:

1. Go to and create an account if you do not have one. Login to your account.

2. Create a new channel by clicking on the button. Enter basic details of the channel.Than Scroll down and save the channel. You can follow the video guide below.

Setting up Thingspeak

3. Then go to API keys copy and paste this key to a separate notepad file. You will need it later while programming.

Source Code

Here is a program for Gas Level Monitoring Over Internet Using ESP8266 & Gas Sensor MQ135. Copy this code and upload it to Nodemcu.

Change the wifi ssid, password and thingspeak API key.

Working of the Project

After the circuit is assembled on breadboard, code should be uploaded.
Gas Level Monitoring Over IOT

Once code uploading is done open serial monitor to see whether wifi is connected or not. Make sure the baud rate should be 115200. If wifi is connected then you can see the gas level displayed in percentage and data will be send to thingspeak.

You can now introduce gas or smoke or perfume at the MQ135 and see the changes in rise in percentage value of gas level.

Open thingspeak channel and select pubic/private view. Here you can see the data uploaded after the interval of 15 seconds.

Video Preview & Explanation

Recommended For You

Ask A Question .......