Tuesday, February 11, 2020

CO2 air quality monitor with Telegram notification

Introduction


CO2 Air Quality Monitoring System with Telegram notification


Purpose


The aim of this project is to receive Telegram notification when CO2 air quality is higher than certain level from Wemos. It uses MH-Z19B sensor to measure CO2 air quality and visualizes the result with Google Chart API. CO2 measurement data is presented in gauge type. We can check current status via web browser using WiFi connection.

Features


This project is based on our previous projects,

IoT Laboratory: CO2 air quality monitor with Line notification V2
IoT Laboratory: CO2 air quality monitor with Line notification

It replaces Line notification with Telegram notification.  A user will be notified by Telegram when the level of CO2 hits a certain level which is specified by the user in the source code. The entire process for sending Telegram notification is like below. Wemos sends HTTP GET request to Telegram server, then, the message will be delivered to our Telegram messenger.


For web server, we use ESPAsyncWebServer library and it is available at github. Additionally, we need to install EPS8266 Sketch Data Upload to upload web server related files to Wemos. For example, in this project, we use HTML, Javacript, and CSS files under data directory. In other words, we need to upload sketch and web related files separately.

Prerequisites


- Arduino IDE
ESP8266 package for Arduino IDE
EPS8266 Sketch Data Upload
ESPAsyncTCP Library
ESPAsyncWebServer Library
- Telegram Bot token and chat id

Requirements


Hardware
-Wemos D1 mini : US$1.77 on Aliexpress
-MH-Z19B CO2 sensor : US$17.90 on Aliexpress

Instructions


Step 1. Setup hardware

MH-Z19B sensor has many pins, but, we only use TX, RX, VCC, and GND pins. Connect TX of MH-Z19B to D5 of Wemos, RX to D6, VCC to 5V, and GND to G. Finally, connect micro usb to Wemos for uploading firmware, and check serial monitor and serial plotter in Android IDE to make sure the sensor works correctly.



Step 2. Create Telegram account and bot

To be able to receive Telegram notification, we need two things; bot token and chat id. Bot token is generated automatically when we create a new bot. Then, send a request on web browser to Telegram. After that, Telegram sends a response with chat id in it. This process looks a little bit complicated at first, but, I found an easy and useful tutorial on Youtube. It would be extremely helpful if you are not familiar with Telegram.

Step 3. Upload sketch to Wemos D1 mini

This step is to upload sketch to Wemos as usual. In the following sketch, following values need to be modified with your own.

WIFI_SSID  : Name of WiFi router
WIFI_PASS  Password of WiFi router
- TG_TOKEN   : Token of Telegram bot
TG_CHAT_ID Chat id that the bot will be sending message to

In this example sketch, it send Line notification only when CO2 density hit 1000 or higher. And before sending again it waits 10 minutes. These values can be changed by user.

notifyLevel    : CO2 threshold for Line notification
- notifyInterval : Waiting time (specify in milliseconds)


Step 4. Upload data to Wemos D1 mini

This step is to upload web server related files (HTML, Javascript, CSS) to Wemos. These files are located in directory named data. Click "ESP8266 Sketch Data Upload" under Tools menu in Arduino IDE to upload these files to Wemos. Once it shows the measurement data, it will refresh every 3 seconds automatically.

HTML file

On web interface, the size of gauge is defined in width, height of options variable. Just change these values to customize chart size. And if you want to modify refresh rate, change the value of 30000 in setInterval function to other value.

CSS file


Javascript file

Results


After uploading firmware, Wemos restarts itself automatically. Once Wemos D1 mini has restarted, serial monitor shows a welcome message, CO2 threshold, and waiting period. When CO2 is higher than threshold it will send Telegram notification to the user as below.


In this project, Wemos sends two types of message. The first type is for informing IP address of itself.  And the second type is for notification with measured CO2 density.


We can use web browser to connect to the device, then it will show current time and visualized information, which is based on Google Chart API. It will refresh itself every 3 seconds automatically.


Cautious!


In this project, Wemos uses softwareserial library to communicate with MH-Z19B sensor. However,  this library will be interfered by other library which uses timer or interrupt internally. Originally, I plant to use Adafruit Neopixel library in this project to lit some of LED strip, but, it interfered the communication of softwareserial library. So, I decided not to use LED strip for this project. One possible work around would be to ESP32 board which has more than one hardware serial.

References


- MH-Z19B Manual PDF: mh-z19b-co2-ver1_0.pdf
MHZ19 - RevSpace
Source codes at github

Monday, February 10, 2020

CO2 air quality monitor with Line notification V2

Introduction


This is an updated version of previous project IoT Laboratory: CO2 air quality monitor with Line notification.


Why?


After cold start, it takes about 65 seconds for MH_Z19B to preheat itself. During this period, the reading will be somewhere between 410 and 430, but, it should not be considered as an actual measurement. Once preheating period has finished, it starts showing actual CO2 density. Therefore, it is recommended to read sensor after 65 seconds at least. For your reference, according to the manual, preheating time is 3 minutes.


What's changed


- Display current status: Preheating, Measuring
- Add line chart on web interface

Source code


References


- MH-Z19B Manual PDF: mh-z19b-co2-ver1_0.pdf
Source codes at github

Saturday, February 8, 2020

CO2 air quality monitor with Line notification

Introduction


CO2 Air Quality Monitoring System with Line notification


Purpose


The aim of this project is to receive Line notification when CO2 air quality is higher than certain level from Wemos. It uses MH-Z19B sensor to measure CO2 air quality and visualizes the result with Google Chart API. CO2 measurement data is presented in gauge type. We can check current status via web browser using WiFi connection.

Features


This project is based on our previous project named "IoT Laboratory: Send Line notification from ESP8266 when PM2.5 is too high" It replaces air quality sensor with CO2 sensor.  A user will be notified by Line when the level of CO2 hits a certain level which is specified by the user in the source code. The entire process for sending Line notification is like below. Wemos sends HTTP POST request to Line Notify website, then, the message will be delivered to our Line messenger.


For web server, we use ESPAsyncWebServer library and it is available at github. Additionally, we need to install EPS8266 Sketch Data Upload to upload web server related files to Wemos. For example, in this project, we use HTML, CSS files under data directory. In other words, we need to upload sketch and web related files separately.

Prerequisites


- Arduino IDE
ESP8266 package for Arduino IDE
EPS8266 Sketch Data Upload
ESPAsyncTCP Library
ESPAsyncWebServer Library
- Line account and Token

Requirements


Hardware
-Wemos D1 mini : US$1.77 on Aliexpress
-MH-Z19B CO2 sensor : US$17.90 on Aliexpress

Instructions


Step 1. Setup hardware

MH-Z19B sensor has many pins, but, we only use TX, RX, VCC, and GND pins. Connect TX of MH-Z19B to D5 of Wemos, RX to D6, VCC to 5V, and GND to G. Finally, connect micro usb to Wemos for uploading firmware, and check serial monitor and serial plotter in Android IDE to make sure the sensor works correctly.



Step 2. Create Line account and Token for notification

To be able to receive Line notification, we need to get a token from Line Notify website and put it in our source sketch. Useful tutorial on how to create a token is available at https://engineering.linecorp.com/en/blog/using-line-notify-to-send-messages-to-line-from-the-command-line/. Take a good look at it to understand basic procedure to create a token.

First, login to the LINE Notify website


Click "My page"


Click "Generate token"


Important! Then, type any name for the token and choose who will receive Line notification. We can choose a single recipient or group. For testing purpose, let's choose myself here, then it will send notification only to me.

Step 3. Upload sketch to Wemos D1 mini

This step is to upload sketch to Wemos as usual. In the following sketch, following values need to be modified with your own.

WIFI_SSID  : Name of WiFi router
WIFI_PASS  Password of WiFi router
LINE_TOKEN : Token string from Line Notify website

In this example sketch, it send Line notification only when CO2 density hit 1000 or higher. And before sending again it waits 10 minutes. These values can be changed by user.

notifyLevel    : CO2 threshold for Line notification
- notifyInterval : Waiting time (specify in milliseconds)


Step 4. Upload data to Wemos D1 mini

This step is to upload web server related files (HTML, CSS) to Wemos. These files are located in directory named data. Click "ESP8266 Sketch Data Upload" under Tools menu in Arduino IDE to upload these files to Wemos. Once it shows the measurement data, it will refresh every 3 seconds automatically.

HTML file

On web interface, the size of gauge is defined in width, height of options variable. Just change these values to customize chart size. And if you want to modify refresh rate, change the value of 30000 in setInterval function to other value.

CSS file


Results


After uploading firmware, Wemos restarts itself automatically. Once Wemos D1 mini has restarted, serial monitor shows a welcome message, CO2 threshold, and waiting period. When CO2 is higher than threshold it will send Line notification to the user as below.




One Wemos sends notification, Line messenger will show you the content of it as below. Notice that "Air quality" in the message is actually the token name we typed when the token was created.


We can use web browser to connect to the device, then it will show current time and visualized information, which is based on Google Chart API. It will refresh itself every 3 seconds automatically.


Cautious!


In this project, Wemos uses softwareserial library to communicate with MH-Z19B sensor. However,  this library will be interfered by other library which uses timer or interrupt internally. Originally, I plant to use Adafruit Neopixel library in this project to lit some of LED strip, but, it interfered the communication of softwareserial library. So, I decided not to use LED strip for this project. One possible work around would be to ESP32 board which has more than one hardware serial.

References


- MH-Z19B Manual PDF: mh-z19b-co2-ver1_0.pdf
Source codes at github

Thursday, February 6, 2020

Control ESP8266 with Google Assistant. OK GOOGLE TURN ON THE LIGHT!

Introduction


Voice control ESP8266 with Google Assistant


Purpose


The aim of this project is to voice control ESP8266 with Google Assistant. We talk to Google Assistant app. Once Google Assistant hear our voice command, it will communicate with IFTTT. Then, IFTTT forwards command to Adafruit MQTT broker. Finally, ESP8266 receives the command through MQTT subscribe function and executes it.

Features


This project requires multiple services to complete the mission. First, it requires Google Assistant app on your phone. Then, we need to create IFTTT account and Adafruit MQTT broker account. In IFTTT, create an applet to link Google Assistant and MQTT broker, so, IFTTT can forward our command from Google Assistant to MQTT broker. Wemos receives a messge from MQTT broker using subscribe function. The whole communication flow looks like this,


Prerequisites


- Arduino IDE
ESP8266 package for Arduino IDE
EPS8266 Sketch Data Upload
IFTTT
- Adafruit MQTT broker
Adafruit_NeoPixel Library for controlling single-wire LED pixels (NeoPixel, WS2812, etc.)

Requirements


Hardware
- Wemos D1 mini : US$1.77 on Aliexpress
- NeoPixel compatible LED stick: https://www.adafruit.com/product/1426

Instructions


Step 1. Setup hardware

Normally, LED stick has VCC, GND, DATA pin. Wiring is very simple, just connect DATA of LED stick to D1 of Wemos.


Step 2. Create IFTTT account and Adafruit MQTT account

After creating Adafruit MQTT account, create a "feed" and dashboard for it just like this. We are going to use this dashboard to test communication between Wemos and MQTT broker later.


Useful tutorial about how to create a "feed" on MQTT broker is available here https://learn.adafruit.com/adafruit-io-basics-digital-output?view=all

Then, create two applets on IFTTT, one is for "turning off the light" and the other is for "turning on the light". Useful tutorial is here https://www.electronicwings.com/nodemcu/control-home-appliances-using-google-assistant

Step 3. Upload sketch to Wemos D1 mini

This step is to upload sketch to Wemos as usual. In the following sketch, following values need to be modified with your own.

WIFI_SSID    : Name of WiFi router
WIFI_PASS    Password of WiFi router
- AIO_USERNAME : Value of 'IO_USERNAME' of MQTT broker
- AIO_KEY      : Value of 'IO_KEY' of the MQTT broker


Results


After uploading firmware, Wemos restarts itself automatically. Once Wemos D1 has restarted, serial monitor shows a welcome message and IP address of Wemos. It displays detail about the command whenever it receives new one. In this example, there are two different commands; on and off.


Right after upload sketch, it is recommended to test whether Wemos is working with MQTT broker without problem by clicking onoff switch on MQTT broker dashboard. It would be good news if console message shows the correct command whenever you click the switch on dashboard.


After confirming above step, now it is time to test the system altogether.


References


Source codes at github

Wednesday, February 5, 2020

homebridge [rpi camera] ffmpeg exited with code 1

Homebridge, Raspberry Pi camera, HomeKit


Installing homebridge on Raspberry Pi seems to be easy if we follow tutorials like nfarina/homebridge: HomeKit support for the impatient and Running Homebridge on a Raspberry Pi · nfarina/homebridge Wiki.

But, once we finish all the processes and setup systemd configuration, then hit this command to run homebridge in background.

$ sudo systemctl start homebridge.service

Then, some of you may encounter error like this,

And we use following command to check the status of service.

$ sudo systemctl status home-assistant@homeassistant.service

We may see error like this,

[rpi camera] ffmpeg exited with code 1


How to fix this error is really simple. If we have followed tutorials mentioned above, then we already created a user homebridge. 

Run the following command to add user homebridge to the video group.

$ sudo usermod -a -G video homebridge

 then, restart homebridge.

If homebridge failss even earlier, take a look at the location of homebridge binary. In /etc/systemd/system/homebridge.service in tutorial, it says /usr/local/bin/homebridge, but, somehow, it is located in /usr/bin/homebridge in my case. So, I modified it in /etc/systemd/system/homebridge.service

[Unit]
Description=Node.js HomeKit Server
After=syslog.target network-online.target

[Service]
Type=simple
User=homebridge
EnvironmentFile=/etc/default/homebridge
# Adapt this to your specific setup (could be /usr/bin/homebridge)
# See comments below for more information
#ExecStart=/usr/local/bin/homebridge $HOMEBRIDGE_OPTS
ExecStart=/usr/bin/homebridge $HOMEBRIDGE_OPTS
Restart=on-failure
RestartSec=10
KillMode=process

[Install]
WantedBy=multi-user.target

References






Tuesday, February 4, 2020

Send Line notification from ESP8266 when PM2.5 is too high

Introduction


Low-cost (US$19) Air Quality Monitoring System with Line notification


Purpose


The aim of this project is to receive Line notification when air quality is higher than certain level from Wemos. It uses PMS7003 sensor to measure air quality and visualizes the result with Google Chart API. Air quality measurement data is presented in gauge type. We can check current status via web browser using WiFi connection.

Features


This project is based on our previous project named "IoT Laboratory: ESP8266-based WiFi air quality monitoring system using PMS7003 sensor with Google Chart visualization." It adds Line notification functionality to notify user when the level of air quality hits a certain level which is specified by the user in the source code. The entire process for sending Line notification is like below. Wemos sends HTTP POST request to Line Notify website, then, the message will be delivered to our Line messenger.


For web server, we use ESPAsyncWebServer library and it is available at github. Additionally, we need to install EPS8266 Sketch Data Upload to upload web server related files to Wemos. For example, in this project, we use HTML, CSS files under data directory. In other words, we need to upload sketch and web related files separately.

Prerequisites


- Arduino IDE
ESP8266 package for Arduino IDE
EPS8266 Sketch Data Upload
ESPAsyncTCP Library
ESPAsyncWebServer Library
- Line account and Token

Requirements


Hardware
-Wemos D1 mini : US$1.77 on Aliexpress
-PMS7003 air quality sensor : US$16.80 on Aliexpress

Instructions


Step 1. Setup hardware

PMS7003 sensor comes with a small breakout board, which has TX, RX, VCC, GND pins. Connect TX of PMS7003 to D5 of Wemos, RX to D6, VCC to 5V, and GND to G. Finally, connect micro usb to Wemos for uploading firmware, and check serial monitor and serial plotter in Android IDE to make sure the sensor works correctly.



Step 2. Create Line account and Token for notification

To be able to receive Line notification, we need to get a token from Line Notify website and put it in our source sketch. Useful tutorial on how to create a token is available at https://engineering.linecorp.com/en/blog/using-line-notify-to-send-messages-to-line-from-the-command-line/. Take a good look at it to understand basic procedure to create a token.

First, login to the LINE Notify website


Click "My page"


Click "Generate token"


Important! Then, type any name for the token and choose who will receive Line notification. We can choose a single recipient or group. For testing purpose, let's choose myself here, then it will send notification only to me.

Step 3. Upload sketch to Wemos D1 mini

This step is to upload sketch to Wemos as usual. In the following sketch, following values need to be modified with your own.

WIFI_SSID  : Name of WiFi router
WIFI_PASS  Password of WiFi router
LINE_TOKEN : Token string from Line Notify website

In this example sketch, it send Line notification only when PM2.5 hit 20 or higher. And before sending again it waits 10 minutes. These values can be changed by user.

notifyLevel : PM2.5 threshold for Line notification
interval    : Waiting time (specify in milliseconds)



Step 4. Upload data to Wemos D1 mini

This step is to upload web server related files (HTML, CSS) to Wemos. These files are located in directory named data. Click "ESP8266 Sketch Data Upload" under Tools menu in Arduino IDE to upload these files to Wemos. Once it shows the measurement data, it will refresh every 3 seconds automatically.

HTML file

On web interface, the size of gauge is defined in width, height of options variable. Just change these values to customize chart size. And if you want to modify refresh rate, change the value of 30000 in setInterval function to other value.

CSS file


Results


After uploading firmware, Wemos restarts itself automatically. Once Wemos D1 mini has restarted, serial monitor shows a welcome message, PM2.5 threshold, and waiting period. When PM2.5 is higher than threshold it will send Line notification to the user as below.


One Wemos sends notification, Line messenger will show you the content of it as below. Notice that "Air quality" in the message is actually the token name we typed when the token was created.


Use web browser to connect to the device, then it will show current time and visualized information, which is based on Google Chart API. It will refresh itself every 3 seconds automatically.


References

Source codes at github

ESP8266-based WiFi air quality monitoring system using PMS7003 sensor with Google Chart visualization

Introduction


Low-cost (US$19) WiFi Air Quality Monitoring System with Google Chart visualization



Purpose


The aim of this project is to use PMS7003 sensor to measure air quality and visualize the result with Google Chart API. Air quality measurement data is presented in gauge type. We can check current status via web browser using WiFi connection.

Features


This project is based on our previous project named "ESP8266-based air quality monitoring system using PMS7003 sensor". It adds web server functionality to offer web-based user interface, which is based on Google Chart API to visualize measured air quality data. For web server, we use ESPAsyncWebServer library and it is available at github. Additionally, we need to install EPS8266 Sketch Data Upload to upload web server related files to Wemos. For example, in this project, we use HTML, CSS files under data directory. In other words, we need to upload sketch and web related files separately.

Prerequisites


- Arduino IDE
ESP8266 package for Arduino IDE
EPS8266 Sketch Data Upload
ESPAsyncTCP Library
ESPAsyncWebServer Library

Requirements


Hardware
-Wemos D1 mini : US$1.77 on Aliexpress
-PMS7003 air quality sensor : US$16.80 on Aliexpress

Instructions


Step 1. Setup hardware

PMS7003 sensor comes with a small breakout board, which has TX, RX, VCC, GND pins. Connect TX of PMS7003 to D5 of Wemos, RX to D6, VCC to 5V, and GND to G. Finally, connect micro usb to Wemos for uploading firmware, and check serial monitor and serial plotter in Android IDE to make sure the sensor works correctly.



Step 2. Upload sketch to Wemos D1 mini

This step is to upload sketch to Wemos as usual. In the following sketch, two values need to be modified with your own.

WIFI_SSID : Name of WiFi router
WIFI_PASS Password of WiFi router

Step 3. Upload data to Wemos D1 mini

This step is to upload web server related files (HTML, CSS) to Wemos. These files are located in directory named data. Click "ESP8266 Sketch Data Upload" under Tools menu in Arduino IDE to upload these files to Wemos. Once it shows the measurement data, it will refresh every 3 seconds automatically.

HTML file

The size of gauge is defined in width, height of options variable. Just change these values to customize chart size. And if you want to modify refresh rate, change the value of 30000 in setInterval function to other value.

CSS file


Results


After uploading firmware, Wemos restarts itself automatically. Once Wemos D1 mini has restarted, serial monitor shows welcome message as below. Remember IP address of Wemos to connect it via web browser.



Use web browser to connect to the device, then it will show current time and visualized information, which is based on Google Chart API. It will refresh itself every 3 seconds automatically.




References

Source codes at github

Monday, February 3, 2020

ESP8266-based WiFi MQTT air quality monitoring system using PMS7003 sensor

Introduction


Low-cost (US$19) MQTT Air Quality Monitoring System





Purpose


The aim of this project is to use PMS7003 sensor to measure air quality and publish data to MQTT broker.

Features


This project is based on our previous project named "ESP8266-based air quality monitoring system using PMS7003 sensor". It adds MQTT functionality to publish measured data to the MQTT broker. Especially, io.adafruit.com offers a free account, which is good enough for prototyping IoT device easily.

Prerequisites


- Arduino IDE
- Adafruit MQTT Library(We can install this from Library Manager in Arduino IDE)
ESP8266 package for Arduino IDE
- io.adafruit.com free account

Requirements


Hardware
-Wemos D1 mini : US$1.77 on Aliexpress
-PMS7003 air quality sensor : US$16.80 on Aliexpress

Instructions


Step 1. Setup hardware

PMS7003 sensor comes with a small breakout board, which has TX, RX, VCC, GND pins. Connect TX of PMS7003 to D5 of Wemos, RX to D6, VCC to 5V, and GND to G. Finally, connect micro usb to Wemos for uploading firmware, and check serial monitor and serial plotter in Android IDE to make sure the sensor works correctly.



Step 2. Create io.adafruit.com free account and feeds. Additionally, create a dashboard to show the value of feeds.

In this project, we will create  3 feeds. Each feed stores value for PM1.0, PM2.5, and PM10.0, respectively. We will use the 'Key' of each feed in our sketch to publish new value to MQTT broker.



After creating feeds, click 'AIO Key' menu to find out IO_USERNAME and IO_KEY value, which we will use in our sketch.

Step 3. Upload sketch to Wemos D1 mini

In the following sketch, four values need to be modified with your own.

- WIFI_SSID    : Name of WiFi router
- WIFI_PASS    : Password of WiFi router
- AIO_USERNAME : Value of 'IO_USERNAME' of MQTT broker
AIO_KEY      : Value of 'IO_KEY' of the MQTT broker

For WiFi feature, three functions are added to the sketch of our previous project.

- connectWifi() : Connect to WiFi router
- connectMQTT() : Connect to MQTT broker
publishMQTT() : Publish to MQTT broker


Results


After uploading firmware, Wemos restarts itself automatically. Once Wemos D1 mini has restarted, serial monitor shows air quality data from PMS7003 every 5 minutes. In the following serial console output, it shows MQTT server is connected and published 3 feeds successfully.




On MQTT broker website, we can check the data which is sent from device. In the menu, go 'Feeds', then, click the name of feed to see the line graph of published value.



Additionally, we can create a dashboard to display all related feeds in a single screen such as following screenshot. In the dashboard, it shows value of PM1.0, PM2.5 and PM10.0 altogether.



References


Source codes at github

ESP8266-based WiFi air quality monitoring system using PMS7003 sensor

Introduction


Low-cost (US$19) WiFi Air Quality Monitoring System



Purpose


The aim of this project is to use PMS7003 sensor to measure air quality and transmit data to ThingSpeak IoT cloud platform via WiFi.

Features


This project is based on our previous project named "ESP8266-based air quality monitoring system using PMS7003 sensor". It adds WiFi functionality to send measured data to the IoT cloud. Especially, ThingSpeak offers a free account, which is good enough for prototyping IoT device easily.

Prerequisites


- Arduino IDE
ESP8266 package for Arduino IDE
- ThingSpeak free account

Requirements


Hardware
-Wemos D1 mini : US$1.77 on Aliexpress
-PMS7003 air quality sensor : US$16.80 on Aliexpress

Instructions


Step 1. Setup hardware

PMS7003 sensor comes with a small breakout board, which has TX, RX, VCC, GND pins. Connect TX of PMS7003 to D5 of Wemos, RX to D6, VCC to 5V, and GND to G. Finally, connect micro usb to Wemos for uploading firmware, and check serial monitor and serial plotter in Android IDE to make sure the sensor works correctly.



Step 2. Create ThingSpeak free account and channel

In this project, we will create a channel with 3 fields. Each field stores value for PM1.0, PM2.5, and PM10.0, respectively.



After creating a channel, click 'API Keys' menu to find out 'Write API Key' value, which we will use in our sketch.



Step 3. Upload sketch to Wemos D1 mini

In the following sketch, three values need to be modified with your own.

- WIFI_SSID : Name of WiFi router
- WIFI_PASS : Password of WiFi router
- TS_KEY    : Value of 'Write API Key' of the channel

For WiFi feature, two functions are added to the sketch of our previous project.

- connectWifi() : Connect to WiFi router
- uploadCloud() : Upload measured data to ThingSpeak cloud using HTTP GET request




Results


After uploading firmware, Wemos restarts itself automatically. Once Wemos D1 mini has restarted, serial monitor shows air quality data from PMS7003 every 5 minutes. In the following serial console output, it shows a HTTP GET request and response from ThingSpeak.


On ThingSpeak website, we can check the data which is sent from device. In the menu, go 'Channels/My channels', then, click 'Private' submenu of the channel. By default, it will show you line graph of each individual field. By clicking 'Add Widgets' menu, you can create a gauge widget as well. For example, in the following screenshot, the bottom right gauge is added manually to make it easier to read for users.




References



Source codes at github