Air pollution has become a common phenomenon everywhere. Specially in the urban areas, air pollution is a real-life problem. In the urban areas, the increased number of petrol and diesel vehicles and the presence of industrial areas at the outskirts of the major cities are the main causes of air pollution. The problem is seriously intensified in the metropolitan cities. The governments all around the world are taking every measure in their capacity. Many European countries have aimed to replace petrol and diesel vehicles with the electric vehicles by 2030. Even India has aimed to do so by 2025.
The main aim of this project is to develop a device which can monitor PPM in air in real time, tell the quality of air and log data to a remote server(ThingSpeak).
The air monitoring device developed in this project is based on Arduino Uno. The Arduino board connects with ThingSpeak platform using ESP8266 Wi-Fi module. The sensor used for monitoring the air pollution is MQ-135 gas sensor. The sensor data is also displayed on a character LCD.
- Arduino Uno $18
- 16x2 LCD $6
- MQ135 gas sensor $2
- ESP8266 module $4-5
- Breadboard $3
- Connecting wires
The total cost of the material is around $40.
Arduino Uno is one of the most popular prototyping boards. It is small in size and packed with rich features. The board comes with built-in Arduino boot loader. It is an Atmega 328 based controller board which has 14 GPIO pins, 6 PWM pins, 6 Analog inputs and on board UART, SPI and TWI interfaces. In this IOT device, 9 pins of the board are utilized. There are six pins used to interface the character LCD. There are two pins utilized to interface the ESP8266 Wi-Fi Module and an analog input pin is used to connect the MQ-135 sensor.
2. 16X2 Character LCD
The 16X2 LCD display is used to monitor the sensor values read by the Arduino board from MQ-135. It is interfaced with the Arduino Uno by connecting its data pins D4 to D7 with pins 6 down to 3 of the controller respectively. The RS and E pins of the LCD are connected to pins 13 and 12 of the controller respectively. The RW pin of the LCD module is connected to the ground.
3. ESP8266 Wi-Fi Module
The ESP8266 WiFi Module is a self contained SOC with integrated TCP/IP protocol stack that can give any microcontroller access to your WiFi network. The ESP8266 is capable of either hosting an application networking functions from another application Each ESP8266 module comes pre-programmed with an AT command.
The ESP8266 supports APSD for VoIP applications and Bluetooth co-existence interfaces, it contains a self-calibrated RF allowing it to work under all operating conditions, and requires no external RF parts.
- 802.11 b/g/n
- Wi-Fi Direct (P2P), soft-AP
- Integrated TCP/IP protocol stack
- Integrated TR switch, balun, LNA, power amplifier and matching network
- Integrated PLLs, regulators, DCXO and power management units
- +19.5dBm output power in 802.11b mode
- Power down leakage current of <10uA
- 1MB Flash Memory
- Integrated low power 32-bit CPU could be used as application processor
- SDIO 1.1 / 2.0, SPI, UART
- STBC, 1×1 MIMO, 2×1 MIMO
- A-MPDU & A-MSDU aggregation & 0.4ms guard interval
- Wake up and transmit packets in < 2ms
- Standby power consumption of < 1.0mW (DTIM3)
For connecting ESP8266 Module with Arduino Uno, you need 3.3 voltage regulator because Arduino is not capable of providing 3.3 v to ESP8266.
4. MQ-135 Gas sensor
The MQ-135 gas sensor senses the gases like ammonia nitrogen, oxygen, alcohols, aromatic compounds, sulfide and smoke. The operating voltage of this gas sensor is from 2.5V to 5.0V. MQ-135 gas sensor can be implementation to detect the smoke, benzene, steam and other harmful gases.
Working Principle And Circuit Diagram
The MQ-135 alcohol sensor consists of a tin dioxide (SnO2), a perspective layer inside Aluminium Oxide micro tubes (measuring electrodes) and a heating element inside a tubular casing. The end face of the sensor is enclosed by a stainless steel net and the back side holds the connection terminals. Ethyl alcohol present in the breath is oxidized into acetic acid passing through the heat element. With the ethyl alcohol cascade on the tin dioxide sensing layer, the resistance decreases. By using the external load resistance the resistance variation is converted into a suitable voltage variation.
It has lower conductivity compare to clean air and due to air pollution the conductivity is increases. The air quality sensor detects ammonia, nitrogen oxide, smoke, CO2 and other harmful gases. The air quality sensor has a small potentiometer that permits the adjustment of the load resistance of the sensor circuit.
The air quality 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. The resistance of the sensor decreases as the concentration of the target gas is increased in PPM while for clean air its resistance remains constant.
The VCC and Ground terminals of the sensor are connected to the common VCC and Ground. The Analog Output pin of the sensor is connected to the A0 pin of the Arduino. The analog output voltage from the sensor can be assumed directly proportional to the concentration of CO2 gas in PPM under standard conditions. The analog voltage is sensed from the sensor and converted to a digital value in range from 0 to 1023 by the inbuilt ADC channel of the controller. The digitized value is hence equal to the gas concentration in PPM.
- Firstly, go to ThingSpeak website, link is given below
Signup or login there, After that go to my channels.
- Then create new channel.
- Next, name it whatever you want to give and after that give field name. Here we are using only one field.
- After saving you will see page like this.
For viewing API keys go to API section.
2. Arduino IDE
To Program Arduino Uno we need IDE. Arduino IDE contains a text editor for writing code, a message area, a text console, a toolbar with buttons for common functions and a series of menus. It connects to the Arduino and Genuino hardware to upload programs and communicate with them.
For this project we need two libraries.
SoftwareSerial and LiquidCrystal.
As the device is powered, the Arduino board loads the required libraries, flashes some initial messages on the LCD screen and start sensing data from the MQ-135 sensor. The sensor can be calibrated so that its analog output voltage is proportional to the concentration of polluting gases in PPM. The analog voltage sensed at the pin A0 of the Arduino is converted to a digital value by using the in-built ADC channel of the Arduino. The Arduino board has 10-bit ADC channels, so the digitized value ranges from 0 to 1023. The digitized value can be assumed proportional to the concentration of gases in PPM. The read value is first displayed on LCD screen and passed to the ESP8266 module wrapped in proper string through virtual serial function. The Wi-Fi module is configured to connect with the ThingSpeak IOT platform. ThingSpeak is an IOT analytics platform service that allows to aggregate, visualize and analyze live data streams in the cloud. ThingSpeak provides instant visualizations of data posted by the IOT devices to ThingSpeak server.
- The Wi-Fi module can be connected with the ThingSpeak server by sending AT commands from the module. The module first test the AT startup by sending the AT command. Then, command is passed by the controller to the Wi-Fi module using software serial function. In response to the command 'AT', the platform must respond with 'OK' if the cloud service is running.
- Then, the AT command to view the version information is passed.
AT + GMR
In response to this command, the IOT platform must respond by sending back the version information, SDK version and the time bin is compiled.
1. ESP-01 output : it will be 00160901.
2. ESP-12 output : it will be 00180000902-AI03.
- Next, the AT command to set the connection to Wi-Fi mode is send.
AT + CWMODE = 3
By setting the parameter in CWMODE to 3, the Wi-Fi connection is configured to SoftAP as well as station mode. This AT command can take three parameters
1 - set Wi-Fi connection to station mode
2 - set Wi-Fi connection to SoftAP mode
3 - set Wi-Fi connection to SoftAP + station mode
In response to this command, the IOT platform must send back the string indication the Wi-Fi connection mode set.
- Next, the AT command to reset the module is send.
AT + RST
In response to this command, the Wi-Fi module must restart and send back a response of 'OK'. After resetting the module.
- Next, command to setup multiple connections is AT+ CIPMUX.
AT + CIPMUX=1
This AT command can take two parameters - 0 for setting single connection and 1 for setting multiple connections.
- Next, the command to connect with the Access Point (AP) is passed which takes two parameters where first parameter is the SSID and the other parameter is the password.
- Next, the AT command to get local IP address is passed.
AT + CIFSR
In response to this command, the local IP address of the Wi-Fi connection is sent back by the module. Now, the module is ready to establish TCP IP connection with the ThingSpeak server. The controller reads the sensor data and store it in a string variable.
- The TCP IP connection is established by sending the following AT command
AT + CIPSTART = 4, "TCP", "126.96.36.199", 80
The AT + CIPSTART command can be used to establish a TCP connection, register an UDP port or establish an SSL connection. Above command is used to establish a TCP IP connection. For establishing a TCP-IP connection, the command takes four parameters where first parameter is link ID which can be a number between 0 to 4, second parameter is connection type which can be TCP or UDP, third parameter is remote IP address or IP address of the cloud service to connect with and last parameter is detection time interval for checking if the connection is live. If the last parameter is set to 0, the TCP keep-alive feature is disabled otherwise a time interval in seconds range from 1 to 7200 can be passed as parameter. In response to this command, the server must respond with 'OK' if connection is successfully established otherwise it should respond with message 'ERROR'.
- When the connection with the server is successfully established and the controller has read the sensor value, it can send the data to the cloud using
AT + CIPSEND = 4
This command takes four parameters, where first parameter is the link ID which can be a number between 0 to 4, second parameter is data length which can be maximum 2048 bytes long, third parameter is remote IP in case of an UDP connection and remote port number in case of UDP connection. The third and fourth parameter are optional and used only in case of UDP connection with the server. Since, the TCP IP connection is established, these parameters are not used. The command is followed by a string containing the URL having the field names and values passed through the HTTP GET method.
In this project, a string containing the URL having API Key and the sensor value as the field and value is passed. The passed field and its value are logged on the cloud server. It is important to pass the API key in this URL as one of the field value in order to connect with the registered cloud service. The Air quality measured by sensor can now be monitored and recorded through the ThingSpeak IOT platform.
- Measuring Units
The three basic units of measure used in reporting air pollution data are micrograms per cubic meter (JLg/m3), parts per million (PPM), and the micron (JL). Micro grams per cubic meter and parts per million are measures of concentration. Both microgram per meter cube and ppm are used to indicate the concentration of a gaseous pollutant. There is an advantage to the unit ppm that frequently makes it the unit of choice.PPM is a volume-to-volume ratio.
Note:- PPM in Air, is a volume-to-volume ratio.
PPM in water and wastewater, is a mass-to-mass ratio.
Changes in temperature and pressure do not change the ratio of the volume of pollutant gas to the volume of air that contains it.
1.What is PPM
Parts per million (PPM) is a unit of measurement used for expressing a very dilute concentration level of pollutants in the air, water and other fluids or one item in a million of anything of the same size.
- Converting air pollutant concentration
1. Converting Micro grams per cubic meter to PPM
ppmv = mg/m^3 x (0.08205 x T) / M
2. Converting PPM to Micro grams per cubic meter
mg/m^3 = ppmv x M /(0.08205 x T)
- mg/m^3 = microgram of pollutant per cubic meter of air
- ppmv = air pollutant concentration, in parts per million by volume
- T = ambient temperature in kelvin
- 0.08205 = Universal gas constant
- M = Molecular weight of air pollutant
2. What is PM level
Particulate matter (PM) in the atmospheric air or in any other gas cannot be expressed in terms of ppmv, volume percent or mole percent. PM is most expressed as mg/m^3 of air or other gas at a specified temperature and pressure.
Note:- One volume percent = 10, 000 ppmv (parts per million by volume) with a million being defined as 10^6.
Care must be taken with the concentrations expressed as parts per billion by volume (ppbv) to differentiate between the British billion which is 10^12 and the USA billion which is 10^9.
Particulate matter is the sum of all solid and liquid particles suspended in air many of which are hazardous. This complex mixture includes both organic and inorganic particles
Based on size, particulate matter is often divided into two groups.
1. Coarse particles (PM 10-2.5) such as those found near roadways and dusty industries range in diameter from 2.5 to 10 micrometers (or microns). The existing coarse particle standard (known as PM 10) includes all particles less than 10 microns in size.
2. "Fine particles" (or PM 2.5) are those found in smoke and haze have diameters less than 2.5 microns. PM 2.5 is referred to as "primary" if it is directly emitted into the air as solid or liquid particles, and is called "secondary" if it is formed by chemical reactions of gases in the atmosphere.
Arduino ==> LCD
- GND ==> GND
- 5 V ==> Vcc
- D13 ==> RS
- GND ==> R/W
- D12 ==> Enable
- D6 ==> DB4
- D5 ==> DB5
- D4 ==> DB6
- D3 ==> DB7
- 5V ==> LED+
- GND ==> LED-
Arduino ==> Gas sensor
- GND ==> GND
- 3.3 V ==> Vcc
- Analog0 ==> A0
Arduino ==> ESP8266
- D10 ==> Tx
- D11 ==> Rx