IoT Thingspeak App Gas Level Monitor on Internet Using ESP8266 & Gas Sensor

To understand the working of Thingspeak IoT cloud with any sensor we can follow the steps which are explained here in for Gas sensor with ESP8266. For Gas Level Monitor On Internet Using search ESP8266 & Gas Sensor Module, i.e search 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. MQ-135 gas sensor can be implemented to detect the smoke, benzene, steam, and other harmful gases. It has the potential to detect different harmful gases. It is with low cost and is particularly suitable for Air quality monitoring applications.
The MQ135 sensor has two outputs: analog output and TTL output. The TTL output is a low signal light that can be accessed through the IO ports on the Microcontroller. The analog output is a concentration, i.e. increasing voltage is directly proportional to increasing concentration. This sensor has a long life and reliable stability as well. And this is connected to Analog port of ESP8266 Node MCU.

Features

Circuit Diagram & Connections Make a connection as per the circuit diagram below. Connect the VCC pin of search MQ135 to Vin of NodeMCU and GND to GND. Connect analog pin A0 of search MQ135 to Analog pin A0 of NodeMCU.
Setting Thingspeak & Getting API Key: Go to https://thingspeak.com/ and create an account if you do not have one. Login to your account.
Create a new channel by clicking on the button. Enter the basic details of the channel. Then Scroll down and save the channel. You can follow the video guide below.
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 Monitor On Internet Using search ESP8266 & Gas Sensor search MQ135. Copy this code and upload it to Nodemcu.
Change the wifi SSID, password, and thingspeak API key.
#include String apiKey = “SKP9YQY2CFVNK919”; // Enter your Write API key from ThingSpeak const char *ssid = “Alexahome”; // replace with your wifi ssid and wpa2 key const char *pass = “hngzhowxiantan”; const char* server = “api.thingspeak.com”; WiFiClient client;
If wifi is connected then you can see the gas level displayed in percentage and data will be sent to thingspeak.
Open the thingspeak channel and select pubic/private view. Here you can see the data uploaded after the interval of 15 seconds.