Najmniejszy system weryfikacji smogu

ESP8266 and SMOG: Quick and snappy SMOG sensor with WiFi interface – first, basic version

Recently, we built a smog sensor which measures PM2.5 and PM10 ppm particles common in SMOG. This time let’s focus on something easy to do, without deliberations on extending life of the sensor. The Nova Fitness SDS011 (also versions 018 or 015) has proven to be quite accurate, with a good life expectancy, even with nearly theoretical unsupported air humidity above 70%. Today I will try to show you the mobile version of the sensor, using the cheapest elements, and then expand it with a temperature and humidity sensor, display – up to the cloud version. To start with – let’s build the basic version.

NOTICE: The ESPEasy MEGA 2.0 software that we use here – has been updated in January 2018 with much better SDS011 support. When finished with this version check out the updated one (fourth version)

Najmniejszy system weryfikacji smogu
Smallest SMOG measurment system

This is a very easy project that can be completed withinin 10 minutes.
Flash the software,  connect 3 cables and read the result via WWW. Something that can be shown at school (or as a school project) or at the local community – as an effective SMOG meter.

What will you need?


  • ESP8226 – best to use either NodeMCU v2 or Wemos D1 mini boards. We’ll use Wemos here. The ESP8266 comes with a convenient USB interface for 5V power supply and “flashing”. At the same time, such boards have additional features – the RESET and/or FLASH buttons, correctly puts them into the “Deep Sleep” mode, and have the most recent versions – ESP-12S, with better antenna. It is important that we need the ESP8266 version with 4MB FLASH (32Mbit) – the  NodeMCU, or Wemos D1 – have exactly this ammount of FLASH memory.
    The device itself should cost around $ 4- $ 5 with shipping, or a little more expensive in stores on-site in your country.
  • Smog sensor – Nova Fitness SDS011. As before, we will use a well-known sensor, which is quite accurate for the price of about $ 22 in China – it can indicate the level of SMOG for 2.5 and 10 ppm particles. You can also get it at Nettigo – if you don’t want to wait a month for delivery – with the DIY_SMOG_15 coupon code, that’s 15% off the regular price.
  • 3 jumper cables.
  • Charger – any smartphone charger with USB port and USB to microUSB cable. At least 750mA, but it could be more – 1A, 2,1A etc, the ESP8266 board will use only what it needs – in this scenario, together with SDS011 – about 650mA

Software and Tools

  • ESPEasy 2.0-dev – ti’s the developing version of the ESPEasy software to be the final 2.0 version, by many programmers. It is the successor of the 1.x. version – at the time of writing, the last version that we can use is dev12, which supports the SDS011 sensor, thanks to its inclusion by Jochen Krapf – who also develops very interesting  Nova SDS011 caseings. This version is suitable for daily usage, even if it’s “just” development version.
  • Linux – any version that runns the  software used to flash ESPEasy into ESP8266. It’s also possible to flash using Microsoft Windows or Mac OS X, but it involves installing the USB-to-serial driver which could be sketchy. Linux has the correct driver in kernel – works without any hassle. The best is a PC with WiFi card and free USB slot, i.e. old cheap netbook (I’m using here very old Acer Aspire One ZG5 with Mint Cinnamon Linux distribution)

Lets do it!

Start your PC with Linux (PC or Raspberry Pi) preferably with Debian based Linux distribution. Insall, the software used to flash the ESP8266 with the ESP Easy 2.0 software.

If the last command gives you errors, you can try:

Correct output looks similar to this:

Next step – connect your ESP8266 board using the USB to microUSB cable to PC. Please mind if you have any other USB-to-serial adapters, in that case port will be different!
Use dmesg command to verify your board being recognized:

The chosen  ESP8266 based board is now available as ttyUSB0 – /dev/ttyUSB0, given that it’s the only type of that device in your Linux system.

For convenience let’s switch to administrator (root) mode, and create working directory:

Download from the latest binary version (it’s a ZIP archive) – i.e.: today it’s the dev12 version. Then, uncompress:

Now all that is lef is to flash onto ESP8266 the correct version, 4MB – dev, (that is the file for 4MB size of flash) – ESPEasy_v2.0.0-dev12_dev_4096.bin:

Correct output:

It’s time for hardware part. Get the SDS011 and disconnect the USB-to-serial that came with it. (thisUSB-to-serial is a popular device, right?). Since ESP8266 has serial port onboard, using the 0 and 3,3V – we don’t need additional adapter. Now hook up 3 jumper cables, please mind the orientation of the plug:

Podłączenie SDS011 do ESP8266
Connecting SDS011 to ESP8266

As you can see – we’ve connected (+5V, GND) and TX from the SDS’s serial port. Turn to ESP8266:

Pin z czujnika SMOGu TX->RX na ESP8266
Connecting the TX->RX onto Wemos D1 Mini

Connect the yellow data TX cable to PIN described as D6. Power goes to +5V and GND:

Podłączenie zasilania SDS011 przez Wemos D1 mini
Connecting the power to SDS011 via Wemos D1 mini

For the whole project, waiting to add power via USB:

Najmniejszy system weryfikacji smogu
Smallest SMOG Senor

After connecting the power the WWW interface of ESPEasy is available via WiFi access point that is started by ESPEasy – with the name (SSID) of ESP_XXXX – and, WPA2 protected setup with default “configesp” password. The “XXXX” is the MAC address of ESP8266, which allows you to tell the many ESP8266 you have!. Connect to the ESP via WiFi, a 192.168.4.x class address should be obtained and use your favourite browser to type in the default address:

The next step would be to add it to our home WiFi network – the one we usually connect to as it is shown in the Main tab:

Wersja ESPEasy
ESPEasy version and our home IP address

Next – chose the Devices tab and Edit in the first line. Choose from drop down “Device:”  menu the SDS011 smog sensor, and fill in the data – using GPIO-12 (D6) to receive data from SDS011 – we won’t be sending anything to it:

Konfiguracja SDS011 w ESPEasy dev12
SDS011 configuration ESPEasy dev12

Press “Submit” and after around 30 seconds – check the results in Devices tab (refresh the page with F5):

Pomiar i wynik z ESPEasy
Pomiar i wynik z ESPEasy

Looks like we have 22,86 μg/m3  of the PM2,5 μm particles and 32,92 μg/m 3  PM10μm.

Caution – do mind that the dust types are named to be properly shown on the ESP8266’s web page. This means that currently we have PM2.5 which is correct, but if you going to build next version of the sensor this variable will be changed to PM25 – without the dot!

That is it, now you can take it with you, just configure the WiFi Hotspot in your smartphone to the same setup as your home WiFi network. Ready for adding OLED screen and another sensor ? Check out the second part.