Troubleshooting and repairing Switch Mode Power Supplies

ESP32-based air quality monitoring system | Full Electronics Project

This is an ESP32 NodeMCU-based Air Quality monitoring system to check particulate matter (PM), humidity, temperature, altitude and pressure levels. Various environmental conditions of the place are tested and displayed on the TFT display as well as on ThingSpeak IoT (Internet of Things) platform. The author’s prototype is shown in Fig. 1.

Particulate matter

High concentrations of dust or PM is a serious health concern. PM2.5 is less than 2.5 microns in diameter, and PM10 is less than 10 microns in diameter. This means, a PM10 report includes PM2.5 as well. Both these particles are much smaller than a human hair, which is about 70 microns in width.

Operations such as stone crushing, coal grinding, rotary kilning in cement industry and dust on road stirred by moving vehicles can increase PM10 levels. PM10 limit for 24-hour average is 150µg/m3.


This is a result of fine particles produced from all types of combustion, including motor vehicles, thermal power plants, residential wood burning, forest fires, agricultural burning and other industrial processes. PM2.5 limit for 24-hour average is 35µg/m3.

Circuit and working

The circuit diagram of the IoT-based air quality monitoring system is shown in Fig. 2. It consists of ESP32 NodeMCU, SDS011, BME280, ILI9163 TFT display, a resistor and transistor 2N2219. ESP32 NodeMCU is the heart of the circuit. Connection details of various modules to ESP32 board are given in tables I, II and III.


It is a low-power microcontroller (MCU) with integrated Wi-Fi and dual-mode Bluetooth—it is a successor of ESP8266 MCU. ESP32 is shown in Fig. 3. Arduino IDE is used to upload the sketch to ESP32 NodeMCU. (ESP-Wroom-32 version 1.1 was used at EFY Lab for testing purpose.)

TFT display

A 3.65cm (1.44-inch) coloured TFT screen display with SPI serial bus was used during testing. It is compatible with Nokia 5110, and is available on
SDS011. Nova dust sensor SDS011 is one of the best particulate sensors in terms of size, accuracy and price (available for US$ 20 on It has a UART interface and measurement resolution of 0.3µg/m3. Operating voltage is 5V. SDS011 used in this project is shown in Fig. 4.

For reading temperature, pressure and relative humidity, an inexpensive BME280 module is used. BME280 used in this project is shown in Fig. 5.

Transistor 2N2219 (T1) is used as a switch for SDS011. Its collector is connected to GND pin of SDS011, and its emitter to circuit ground. When pin 15 of ESP32 is logic high, T1 conducts and SDS011 gets ground connection through T1, otherwise SDS011 is off.

ThingSpeak IoT platform

The project is based on ThingSpeak cloud computing. ThingSpeak is an open source IoT application and API to store and retrieve data from things using HTTP protocol over the Internet via LAN. It enables the creation of sensor-logging applications, location-tracking applications and a social network of things with status updates. This means, if you send data from the sensors to ThingSpeak at regular intervals, it will create, store and display data in a trend automatically. It has Maths modelling inbuilt in the form of MATLAB documentation, which is free to use.

Account and channel set up. Open an account and a channel on For this, you need to have a valid email account. The site will send a confirmation email. Click on the link sent in the email to validate your account and create a channel.

From here on, you can create as many channels as you want. The moment you create a channel, you get three ThingSpeak identities: channel ID, write API key and read API key. Note these down, as you will require these in the source program later. Feed up to eight sensor data per channel, such as PM2.5, PM10, temperature, relative humidity, altitude and pressure.

Eight data per channel. Each channel can take eight data signals from different devices. This means, using ThingSpeak API, you can upload eight data per channel, which are eventually gathered, logged and put into trend data by ThingSpeak, like the following:

The software (environment_thingspeak.ino) for the project is written in Arduino programming language. PM2.5 and PM10 have a relation with relative humidity (RH).

Therefore an RH correction is included in the program code (or sketch) to fine tune the readings.

SDS011 on ESP32. ESP32 works on Arduino IDE. Since Arduino is an advanced technology, there is a library available for almost all sensors. So, for SDS011 there is a ready-made library available that uses SoftwareSerial library and works out-of-the-box for Arduino Uno.

ESP32 does not work with SoftwareSerial. It has three UART ports and uses HardwareSerial for connecting UART devices. Existing library and command are used with hardwareserial to get PM data from the sensors. These commands are placed in processdata.h file, which must be kept in the same folder as Arduino sketch and compiled together with the main sketch.

Sleep mode of SDS011. As per specifications, SDS011 has a sleep current of 2mA. The sensor works on sleep mode infrequently. Sleep commands are also placed in processdata.h file for you to try. However, GPIO13 (pin 15) is used to switch on the npn transistor (2N2219) to keep SDS011 on during active stage, before it goes into power-off mode.

Uploading the code to ESP32. Now everything is set and done by you. Assemble the devices on the PCB or general-purpose Veroboard. Connect the USB power supply cord to ESP32.

Run Arduino IDE and add the library for ESP32 and other relevant libraries. Open Arduino code (environment_thingspeak.ino).

Change/provide Wi-Fi ID and password towards the beginning of the sketch. Replace ThingSpeak channel number with your channel number, and API key with your API key.

Select ESP32 Dev Module from the pull-down menu under ToolsBoard option. Next, select the correct USB COM port from the pull-down menu under ToolsPort option. Press Upload.

If you have done everything right, the program will start communicating with ESP32 board and then upload the code into ESP32 MCU.

After a few seconds, you will see PM2.5, PM10 and other data on the TFT display screen. The same data will also show up on the serial monitor of Arduino.

Open ThingSpeak channel on any Internet browser—your smartphone browser will work, too. You will find that data is stacking up perfectly, as shown in Fig. 6.

You may refer to the following websites for details on instructions on how to integrate ESP32 on Arduino IDE:

Construction and testing

An actual-size PCB layout for the air quality monitoring system is shown in Fig. 7 and its components layout in Fig. 8. Mount various modules on the PCB. Switch on the power supply to ESP32.

Download PCB and Component Layout PDFs: Click Here

If everything is correct, you will see the readings on the TFT display ofair quality monitoring system. The same values will appear on, as shown in Fig. 6.

SDS011 runs on 5V. But, you can also use two 3.7V lithium-ion batteries along with a small linear regulator like 7805 to step-down to 5V. Alternately, you can use a tiny converter (available on that can boost voltage from 1.5V to 5V. You can use one lithium-polymer battery along with a converter making it a truly portable device.

Somnath Bera is an avid user of open source software. Professionally, he is a thermal power expert and works as an additional general manager at NTPC Ltd.

This content was originally published here.

Troubleshooting and repairing Switch Mode Power Supplies
LCD Monitor Repair Secrets
Electronic Repair Information

Check Also

Electronics Projects: Configurable RS232 To TTL To I2C Adaptor

RS232 signals cover a much longer distance than standard TTL and I2C signals. Also, RS232 …

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Download Free PDF :

The Easy Way To Understand Switch Mode Power Supply

Discover The 11 Functions Of SMPS Power Supply