Specification of the MQ135 Gas sensor:-
- Power: 2.5V ~ 5.0V
- Dimension: 40.0mm * 21.0mm
- Mounting holes size: 2.0mm
- Jumper Wires
- MQ135 Gas Sensor
- Breadboard (optional)
MQ135 Gas Sensor:-
We need to install ESPAsyncTCP and ESPAsyncWebServer libraries for creating Asynchronous Web Server. These Libraries are not available in Arduino Library Manager. Download these library from the given two links and include these libraries in your Arduino ide from sketch/include Library/Add .Zip Folder.
In these Program We learn how to read Analog Gas Sensor Data from the MQ135 Gas Sensor, displaying the real time data on chart and displaying the quality of air through different color on asynchronous Web Server.
How the Code Works?
The Aim of the code is to show the Air Quality using MQ135 sensor on Asynchronous Web Server.
Here we design our Web page and see how to send request from Html Web page to ESP8266.
1) First, we need to include the highcharts library:
2) Create one div for containing graph div and span for Sensor Data.
The following spinet creates the Gas chart. Then We define the chart id, set the title, the axis labels. Etc.
4) The setInvertal() function adds points to the charts. Every 2 seconds it makes a request to the /sensorvalue URL to get the temperature readings from our ESP8266.
5) This Snippet of set Interval Function declare the x and y variable. Using getTime function we get the current time and y takes data received from http as Sensor Value
6) Further we declare another variable z which also takes sensor value and further it is used to decide the color of the bar based on quality on environment.
7) In the snippet after 2 seconds it makes a request to the /sensorvalue URL to get the temperature readings from our ESP8266.
In the Arduino sketch, we should handle what happens when we receive those requests: we should send the corresponding sensor readings.
1) Include all the Necessary Libraries for creating Asynchronous Webserver and activating Wi-Fi of Esp8266.
2) Giving the Network Credential to connect to Wi-Fi.
3) Creating the Asynchronous web Server object on port 80
4) Function to read analog Value from Gas Sensor
5) Starting the Serial Monitor
6) Connecting to Wi-Fi
7) Sending the Corresponding Data to Http Requests from the Asynchronous Web Server
8) Starting the Server