Home > Microcontroller >Microcontroller Production > How to use ESP32 to implement the design of air quality monitoring system

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

Source: InternetPublisher:司马缸砸光 Keywords: MCU air quality monitoring ESP32 Updated: 2023/12/26

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

particulates

Dust and PM can pose health risks to humans. The diameter of PM2.5 can be less than 2.5 microns, and the width of PM10 can also be less than 10 microns. This means PM10 reports will also include PM2.5. Both particles are shorter than a human hair, which is about 70 microns in diameter.

PM10

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

PM2.5

It is the result of fine particles produced by any type of combustion, such as motor vehicle thermal power plants, wood burning in residential buildings, forest-related agricultural burning fires, and various other industrial processes. The PM2.5 limit for the 24-hour average is 35ug/m3.

circuit

It consists of ESP32NodeMCUSDS011, BME280ILI9163TFT display, resistor and transistor 2N2219. The ESP32NodeMCU is at the center of this circuit.

The schematic diagram of the air quality system based on the Internet of Things is shown in the figure:

IoT air quality system

ESP32NodeMCU:

ESP32NodeMCU

It is a low-power consumption (MCU) microcontroller with integrated Wi-Fi and dual-mode Bluetooth. It is an upgraded version of the earlier ESP8266 microcontroller. ESP32 is shown in the picture. Code can be sent to the ESP32NodeMCU using the ArduinoIDE. (EFY Labs uses ESP-Wroom-32 version 1.1 to test sketches.)

TFT display

A 3.65 cm (1.44 in) touch screen with a color display supporting SPI serial bus technology was used during the tests.

SDS011. Nova’s dust detector SDS011 is arguably one of the most effective particle sensors in terms of size, accuracy and cost. It has a UART interface and a measurement accuracy of 0.3ug/m3. Working voltage is 5V.

Nova dust detector SDS011

BME280

To read temperature and pressure as well as relative humidity, the affordable BME280 module is used.

BME280 module

2N2219

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

ThingSpeak, an IoT-based platform

The project is built on ThingSpeak cloud computing. 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 recording software, location tracking applications, and social networks that provide status updates. If you regularly stream data from your sensors to ThingSpeak, it will generate the data, store it and display trends in real time. It also has built-in mathematical modeling as freely available MATLAB documentation.

Account and channel settings. Set up an account and channel at www.thingspeak.com. To do this, you need to have a valid email account. The website will send you a confirmation email. Follow the link in the email to confirm your account and create an account.

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

Eight data per channel. Each channel is capable of receiving eight data signals from various devices. This means that using ThingSpeakAPI you will be able to upload 8 data per channel. Then use ThingSpeak to collect, record and convert the data into trend data, for example: https://thingspeak.com/channels/279012

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).

It is therefore necessary to add a RH correction in the software (or sketch) to adjust the readings.

SDS011 on ESP32. ESP32 runs on Arduino IDE. Since Arduino is a cutting-edge technology, there is an application library for almost every sensor. For the SDS011, there is a ready-to-use library that uses the SoftwareSerial library that works directly with the ArduinoUno.

ESP32 is not compatible with SoftwareSerial. It comes with three UART ports and utilizes HardwareSerial to connect UART devices. Existing commands and libraries can be used in conjunction with hardware serial 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.

SDS011 sleeps in SDS011 mode. According to the specifications, the SDS011 can have a sleep current of 2mA. Sensors are rarely in sleep mode. Additionally, sleep-related commands have been 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 remains running during the active phase and then switches it to power-down mode.

I'm uploading a program to an ESP32. Then everything is ready for you to execute. Connect the device to a PCB or Veroboard for general purposes. Connect to the ESP32's USB power supply.

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

Change or provide Wi-Fi ID and password when starting a sketch. Replace ThingSpeak channel number with your channel number and API key and API key.

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

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

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

Start the ThingSpeak channel in any Internet browser. Your smartphone browser will also work. The data stacks perfectly as shown:

ThingSpeakChannel

test

The actual size PCB layout of the air quality monitoring system is shown in the figure:

Air Quality Monitoring System Actual Size PCB Layout

If everything is fine, you will be able to observe the correct value on the TFT display of the air quality monitor.

Possible expansion

In the project, SDS011 is powered by 5V. However, you can use 2 3.7V Li-ion batteries with a very small linear regulator (such as a 7805) to step down to 5V.

You can also use a tiny converter to step up the voltage to 1.5V to 5V. You can use a lithium polymer battery and converter to make it portable.

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号