Hello! Welcome to Embedic!
This website uses cookies. By using this site, you consent to the use of cookies. For more information, please take a look at our Privacy Policy.
Home > Embedded Events > How to use ESP32 to implement the design of an air quality monitoring system

How to use ESP32 to implement the design of an air quality monitoring system

Date: 06-06-2022 ClickCount: 260

The system is an ESP32NodeMCU-based air quality monitoring system for checking PM, particulate matter (PM), humidity, temperature, altitude, and pressure. Various aspects of the location environment are tested and then displayed on a TFT screen using the ThingSpeakIoT (Internet of Things) platform.

Particulate Matter

Dust and PM can pose a health risk to humans. PM2.5 can be less than 2.5 microns in diameter, and PM10 can be less than 10 microns in width. This means that PM10 reporting will also include PM2.5. Both particles are shorter than human hair, about 70 microns in diameter.

PM10

Operations such as rock crushing, coal grinding, rotary kilns within the cement industry, and dust on roads stirred up by moving vehicles can increase PM10 levels. The 24-hour PM10 limit is 150ug/m3.

PM2.5

It results from fine particles produced by any combustion, such as motor vehicle cogeneration plants, wood-burning in dwellings, forest-related agricultural combustion fires, and various other industrial processes. The 24-hour average PM2.5 limit is 35ug/m3.

Circuit

It consists of ESP32NodeMCUSDS011, BME280ILI9163 TFT display, resistor, and transistor 2N2219. ESP32NodeMCU is located in the central part of this circuit.

ESP32NodeMCU

It is a low-power (MCU) microcontroller with integrated Wi-Fi and dual-mode Bluetooth. It is an upgraded version of the earlier ESP8266 microcontroller. Code can be sent to the ESP32NodeMCU using ArduinoIDE.

TFT display

A 3.65 cm (1.44 inch) touch screen with a color display that supports SPI serial bus technology was used during testing.

SDS011. Nova's dust detector SDS011 is arguably one of the most efficient particle sensors in size, accuracy, and cost. It comes with a UART interface and a measurement accuracy of 0.3ug/m3. Operating voltage 5V.

BME280

For reading temperature, pressure, and relative humidity, the economic BME280 module is used.

2N2219

The transistor 2N2219 (T1) can be used as a switch in the SDS011. Its collector is connected to the GND pin of the SDS011, and the emitter is connected to the ground of the circuit. If pin 15 of ESP32 is high, logic T1 is on, and the SDS011 is grounded through T1. Otherwise, the SDS011 cannot be grounded.

ThingSpeak, an IoT-based platform

This project is built on top of the ThingSpeak cloud. ThingSpeak is an open-source IoT application and API that allows you to store and retrieve data from devices over the Internet using the HTTP protocol over a LAN. It allows the development of sensor logging software, location tracking applications, and social networks that provide status updates. If you periodically transfer data from your sensors to ThingSpeak, it will generate the data, then store it and display trends in real-time. It also has built-in mathematical modeling as freely available MATLAB documentation.

Account and Channel Settings. For this, you need to have a valid email account. The site will send you a confirmation email. Follow the link in the email to confirm your account and set up an account.

You can make as many channels as you want from this point on. If you create a channel, you will receive three ThingSpeak identities: a channel ID, an API key for writing, and an API key for reading. Please note these in case you need them in the future to use the program source. Up to eight sensor messages per channel, such as PM2.5 and PM10 temperature and altitude, relative humidity, and pressure.

Eight data per channel. Each channel can receive eight data signals from a variety of devices. This means using the ThingSpeak API. You will be able to upload eight data for each channel. The data is then collected, logged, and converted to trend data using ThingSpeak.

Software

The software for this project (environment_thingspeak.in) is written in the Arduino programming language. Both PM2.5 and PM10 are related to relative humidity (RH).

Therefore, adding an RH correction to the software (or sketch) is necessary to adjust the readings.

SDS011 on ESP32. ESP32 runs on ArduinoIDE. Since Arduino is cutting-edge technology, there is an application library for almost all sensors. For SDS011, there is an available off-the-shelf library that uses the SoftwareSerial library that works directly with Arduino Uno.

The ESP32 is not compatible with SoftwareSerial. It comes with three UART ports and uses HardwareSerial to connect to UART devices. Available commands and libraries can be used with HardwareSerial to obtain PM information from sensors. These commands are stored in the data.h file. It should be saved in the same location as the Arduino sketch and then usually compiled with the sketch.

The SDS011 is dormant in SDS011 mode. According to the specifications, the SDS011 can have a 2mA sleep current. The sensor is rarely in sleep mode. In addition, commands related to sleep are included in the data.h file for your testing purposes. However, GPIO13 (pin 15) is used to turn on the NPN transistor (2N2219) to ensure that the SDS011 stays running during the active phase and then switches it to power-down mode.

I am uploading the program to ESP32. Then everything is ready to be executed by you. Connect the device to the PCB or Veroboard for general purpose. Connect the USB power to the ESP32.

Start ArduinoIDE and add the ESP32 library and any other related libraries. Open the Arduino code (environment_thingspeak.info).

Change or provide the Wi-FiID and password when starting the sketch. Replace the ThingSpeak channel number with your channel number and the API key and API key.

Select ESP32DebModule by selecting the drop-down menu below the Tools(r) Board option. Then, select the correct USB port in the drop-down menu below the Tools(r) Port option. Press Upload.

If everything is OK, your program will start communicating through the ESP32 board and uploading code to the ESP32MCU.

After a few minutes, you will see PM2.5 or PM10 and other information displayed on the TFT display. Similar data will be displayed on the Arduino's serial monitor.

Launch the ThingSpeak channel in any Internet browser. Your smartphone browser will also work. Data stacks perfectly.

Possible extensions

The SDS011 in the project is powered by 5V. However, you can use two 3.7V Li-ion batteries with a very small linear regulator (e.g., 7805) to step down to 5V.

You can also use a small converter to increase the voltage from 1.5V to 5V. You can use a LiPo battery and a converter to make it portable.

  • TWS Bluetooth Headset Charging Compartment Design Solution
  • Package and PCB Issues Caused by SOC

Hot Products

  • PIC18LF46K40-E/P

    Manufacturer: Microchip

    IC MCU 8BIT 64KB FLASH 40DIP

    Product Categories: 8bit MCU

    Lifecycle:

    RoHS:

  • TMS320C6748BZWT3

    Manufacturer: Texas Instruments

    IC DSP FIX/FLOAT POINT 361NFBGA

    Product Categories: DSP

    Lifecycle:

    RoHS:

  • DM355SDZCE216

    Manufacturer: Texas Instruments

    IC DIGITAL MEDIA SOC 337-NFBGA

    Product Categories: SOC

    Lifecycle:

    RoHS:

Customer Comments

  • Looking forward to your comment

  • Comment

    Verification Code * 

Compare products

Compare Empty