Today I would like to share with you some small IoT project that I did a few weeks ago. It was a homebrew weather station. Here are in details instruction how I did it.
- ESP8266 - I have used dev board with NodeMCU https://www.seeedstudio.com/NodeMCU-v2-Lua-based-ESP8266-development-kit.html
- PMSx003 - PMS7003 PM2.5 and PM10 Air Quality sensor and adapter (Adapter IDC 10pin 1,27mm - 2,54mm - G7-5V TTL) https://www.adafruit.com/product/3686 http://www.aqmd.gov/docs/default-source/aq-spec/resources-page/plantower-pms5003-manual_v2-3.pdf
- DHT11 sensor on KY-015 board- Temperature & Humidity Sensor https://www.mouser.com/ds/2/758/DHT11-Technical-Data-Sheet-Translated-Version-1143054.pdf
- Breadboard power supply useful because PMS7003 require 5V power instead of 3.3V) - https://opencircuit.shop/ProductInfo/1000154/Breadboard-Power-Supply.pdf
- ESP Easy - use Testing binary (due to PMSx003 sensor support) ready to use, configurable firmware with web interface https://www.letscontrolit.com/wiki/index.php/ESPEasy
- USB to UART drivers (Win) https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers
- NodeMCU flasher - https://github.com/nodemcu/nodemcu-flasher (optional)
- ESPlorer - https://esp8266.ru/esplorer/ (optional)
Upload firmware on ESP8266 using ESP Easy Flasher (Win) or via flash scripts (https://www.letscontrolit.com/wiki/index.php?title=Flash_script_linux)
- Start ESP Easy Flasher
- Select correct COM port - in my case COM4
- Select firmware for your hardware - in my case, I had NodeMCU dev board - it have 4M of flash memory, I had chosen test branch of ESP Easy - so in my case it is ESP_Easy_mega-20190202_test_ESP8266_4096.bin
- Check settings and hit Flash ESP Easy FW
After ~104s you should have firmware on ESP8622.
On connection, your ESP8266 Node MCU should blink once. On connection issues try to:
- Install USB to UART Drivers if needed (if f.e. you don't see any COM ports on ESP Easy Flasher)
- Use a different USB cable
- Use a different USB port
Now is time to start and configure Easy ESP via the web interface. We need to reset the ESP8266 Node MCU (RST button).
You can verify the status of firmware update by Opening serial monitor after flash from ESP Easy Flasher. It should look more or less like this.
Setup WiFi on ESP8622
Log from above states that we should be able to connect to new a WiFi network called ESP_Easy_0 with password configesp.
Then navigate to IP address http://www.msftconnecttest.com/setup to select WiFi network and input password.
As a result, you are routed to new IP inside desired WiFi network.
Now is time to configure some sensors.
Configure DHT11 sensor
First thing would be to navigate to Devices page and select sensor from drop down. We would start with DHT-11 so after choosing it we need to specify GPIO pin with DATA connected to our board. In this case, it would be D7.
We can use the board to provide power for sensor f.e. using V3.3 and GND pins located near D7.
After a successful setup and connection, we will get some readings.
Configure PMS7003 sensor
Now it would be time to connect the air quality sensor. The overall configuration looks similar, but there is a trick.
PMS7003 uses 5V as a power supply and 3.3V as a data line. NodeMCU board can provide the only 3.3V - so this needs to be solved. In my case, it was an external breadboard supply.
I have used software serial port with TX on D5, RX on D6 and RST(Reset) on D0.
After successful configuration, restarting and re-connecting we should get readings similar to mine.
Summary of connections
- KY-015 may have different variants of connections. Please follow your variant description - (f.e VCC, DATA, GND).
- The breadboard power supply I have used because PMS7003 require 5V.
- In case of G7-5V TTL adapter / PMS7003, please follow your connection variant described on your chip.
- The nominal lifetime of PMS7003 sensor is ~8000h (1 year), and it may be extended by introducing sleep scripts. That is the main reason behind the additional blue line on G7-5V TTL pin RST (Reset). https://www.letscontrolit.com/wiki/index.php/PMSx003
I have used thingspeak.com as a cloud platform for data visualization. After you create an account on this portal, you need to create a channel and get API keys.
The key is required to set up the controller to send data to thingspeak using 184.108.40.206 and provide with API key.
Next step would be to configure sensors to be used by this controller. Mapping is quite simplistic. We need to specify index of sensor data.
On the thingspeak level, I had defined as an array of 5 fields -
[Temperature, Humidity, pm1.0, pm2.5, pm10] and that is why on PMS7003 we are starting PM info from 2nd the index to match thingspeak definition.
Now after some time, we can see some data.