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.

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:

http://share.weiyun.com/dfd9763e10370ec584b635e1f0... Download the fire Arduino_ESP8266_IDE_1.0 ?????.rar extract.

Complex way:

Download Arduino 1.6.5, and install http://share.weiyun.com/dfd9763e10370ec584b635e1f0... Start Arduino and open Preferences window. Enter http://share.weiyun.com/dfd9763e10370ec584b635e1f0... 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 www.inovafitness.com 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 www.inovafitness.com // packet format: AA C0 PM25_Low PM25_High PM10_Low PM10_High 0 0 CRC AB mData = Serial.read(); delay(2); if(mData == 0xAA)//head1 ok { delay(400);//wait until packet is received mPkt[0] = mData; mData = Serial.read(); if(mData == 0xc0)//head2 ok { mPkt[1] = mData; mCheck = 0; for(i=0;i < 6;i++)//data recv and crc calc { mPkt[i+2] = Serial.read(); delay(2); mCheck += mPkt[i+2]; } mPkt[8] = Serial.read(); delay(1); mPkt[9] = Serial.read(); 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 www.inovafitness.com 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

<p>Hi,</p><p>I have a quetion how to measure PM10?<br>Could you please help?</p><p>Thanks,<br>Piotr</p>
In the sds sensor, their is a serial port data protocol.<br>the first byte is AA and the last byte is AB;<br>the third byte and fourth byte is the PM2.5 data byte;<br>the fifth byte and sixth byte is the PM10 data byte;<br><br>if you want to get the PM10 data, <br>PM10(unit: ug/m3) = fifth byte data + (sixth byte data * 256);<br>hope this will help
<p>Can you please send the codes? My email is gkbhat@taru.org</p>
<p>hi</p><p>http://share.weiyun.com/dfd9763e10370ec584b635e1f06e3bbf is broken can u replace the link plz plz :)</p>
<p>Step 3: Software development environment</p><p>if the link is no more avaliable, check here:<br>https://github.com/esp8266/Arduino</p>
I'm sorry that the &quot;instructables.com&quot; web could not attach the code with some error.<br>I could send you the code if you may leave a email;<br>
filippo_tacchini@hotmail.com <br>ty sir
<p>Hi, I have a question.</p><p>I am trying to use Arduino Uno R3 to build the air monitor and display on computer (no wifi). And I found using the serial.read() 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!</p>

About This Instructable



More by jiangshan00000:Using Pm2.5 Sensor With Raspberry Pi make an arduino wifi air monitor 8051 C development using FREE compiler SDCC  
Add instructable to: