Make an Arduino Wifi Air Monitor

A laser pm2.5 air monitor Base on ESP8266 arduino with wifi.

ESP8266 is a wifi chip which is cheap and arduino development enabled;

SDS011/SDS018/SDS021 is laser pm2.5 sensor which is said accuracy and quick response to detect pm2.5 air pollution.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Component

ESP8266-01 wifi module

SDS011/SDS018/SDS021 inovafitness compatible laser pm2.5 sensor

USB to TTL module

Conductor wire A switch for optional

Step 2: Wire Connect

Between USB2TTL and ESP8266 module

ESP8266-01 USB2TTL Comment

VCC 3.3V


CH_PD 3.3V Add 20-100 resistor for secure(optional)

GPIO0 GND Add switch here. GPIO0 connected to GND means ready to update the firmware; GPIO0 floating means ready to run; RX TX TX RX

Between ESP8266 and SDS011/SDS018/SDS021

ESP8266 SDS011/SDS018/SDS021 Comment

RXD TXD Add 20-100 resistor for secure(optional) GND GND

Between USB2TTL and SDS011/SDS018/SDS021
ESP8266 USB2TTL Comment

5V 5V


Step 3: Software Development Environment


Simple way: Download the fire Arduino_ESP8266_IDE_1.0 ?????.rar extract.

Complex way:

Download Arduino 1.6.5, and install Start Arduino and open Preferences window. Enter into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas. Open Boards Manager from Tools > Board menu and install esp8266 platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation).


For esp8266-01 module, the board ‘NodeMCU 0.9’ should be selected, as below: And set CPU Frequency to 80MHz,Upload Speed to115200,select the correct port which the usb2ttl module is connected (eg COM12).

Step 4: Code

///download the file AirMonitorServer.ino or just copy the code below, it should be the same(download the file is suggested)

/* Create a WiFi access point and provide a web server for pm2.5 on it. */

#include #include #include /* Set these to your desired credentials. */ const char *ssid = "AirMonitor"; const char *password = "inovafitness"; ESP8266WebServer server(80); // this is a demo for Arduino PM2.5 sensor test // PM2.5 sensor is from SDS011 unsigned int Pm25 = 0;//used for result pm2.5 unsigned int Pm10 = 0;//used for result pm10 unsigned char Pm25IsNew = 0;//show if pm25 is refreshed void ProcessSerialData() { uint8_t mData = 0; uint8_t i = 0; uint8_t mPkt[10] = {0}; uint8_t mCheck = 0; while (Serial.available() > 0) { // from // packet format: AA C0 PM25_Low PM25_High PM10_Low PM10_High 0 0 CRC AB mData =; delay(2); if(mData == 0xAA)//head1 ok { delay(400);//wait until packet is received mPkt[0] = mData; mData =; if(mData == 0xc0)//head2 ok { mPkt[1] = mData; mCheck = 0; for(i=0;i < 6;i++)//data recv and crc calc { mPkt[i+2] =; delay(2); mCheck += mPkt[i+2]; } mPkt[8] =; delay(1); mPkt[9] =; if(mCheck == mPkt[8])//crc ok { Serial.flush(); //Serial.write(mPkt,10); Pm25 = (uint16_t)mPkt[2] | (uint16_t)(mPkt[3]<<8); Pm10 = (uint16_t)mPkt[4] | (uint16_t)(mPkt[5]<<8); if(Pm25 > 9999) Pm25 = 9999; if(Pm10 > 9999) Pm10 = 9999; //get one good packet Pm25IsNew = 1; return; } } } } } /* Just a little test message. Go to in a web browser * connected to this access point to see it. */ void handleRoot() { char pm25_str[100]; char *pm25_format_red = "


"; char *pm25_format_green = "


"; char *pm25_format_blue = "


"; if (Pm25<150)//15.0 sprintf(pm25_str,pm25_format_green, Pm25/10,Pm25%10); else if (Pm25<500)//pm2.5<50.0 sprintf(pm25_str,pm25_format_blue, Pm25/10,Pm25%10); else sprintf(pm25_str,pm25_format_red, Pm25/10,Pm25%10); server.send(200, "text/html", pm25_str); } void setup() { delay(1000); Serial.begin(9600); Serial.println(); Serial.print("Configuring access point..."); /* You can remove the password parameter if you want the AP to be open. */ WiFi.softAP(ssid, password); delay(500); delay(500); //while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("done"); IPAddress myIP = WiFi.softAPIP(); Serial.print("AP IP address: "); Serial.println(myIP); server.on("/", handleRoot); server.begin(); Serial.println("HTTP server started"); } void loop() { server.handleClient(); ProcessSerialData(); }

Step 5: Firmware Upload

Step 6: Device View

Step 7: Run

find a cell phone with wifi enabled.

Connect WIFI AP with name: ’AirMonitor’,

Password: ’inovafitness’

After connect to the ap, access

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    8 Discussions


    3 years ago


    I have a quetion how to measure PM10?
    Could you please help?


    2 replies

    Reply 3 years ago

    In the sds sensor, their is a serial port data protocol.
    the first byte is AA and the last byte is AB;
    the third byte and fourth byte is the PM2.5 data byte;
    the fifth byte and sixth byte is the PM10 data byte;

    if you want to get the PM10 data,
    PM10(unit: ug/m3) = fifth byte data + (sixth byte data * 256);
    hope this will help


    3 years ago

    hi is broken can u replace the link plz plz :)

    3 replies

    Reply 3 years ago

    Step 3: Software development environment

    if the link is no more avaliable, check here:


    Reply 3 years ago

    I'm sorry that the "" web could not attach the code with some error.
    I could send you the code if you may leave a email;


    3 years ago

    Hi, I have a question.

    I am trying to use Arduino Uno R3 to build the air monitor and display on computer (no wifi). And I found using the and serial.print does not work. Possibly due to computer is using those two ports. Then I switched to 2 digital ports 10 and 11, hoping to using them as RX and TX. Somehow I still get no reading. Do I need the USB to TTL converter? I tried both, connection RX, TX, GND, 5V from SDS021 or the USB to TTL converter, neither worked. Could you please shine light on this? Thanks a lot!