title tutorial

This sensor connects to your home or office WiFi, and automatically uploads a measurement every five minutes. You will need to plug it into a power socket. The node is based on the Wemos microcontroller and costs around Euro 30.

A printable version of this tutorial is available.

We also have a tutorial for the hackAIR home v1 sensor (based on Arduino).

VIDEO TUTORIAL

What you need

Materials

Tools

  • Soldering iron + soldering tin (from ca. 20 EUR)
  • Poster putty
  • Computer

For general soldering instructions, check out this tutorial: Introduction to soldering.

wemos (2)

Assemble the sensor

Step 1: Solder headers to your microcontroller

Solder the short headers to the Wemos microcontroller.

In order to keep the header stable during soldering use some poster putty (see red arrow)

putty under Wemos to make soldering easier

Your finished board should look like this:

wemos (4)
Step 2: Solder headers to the humidity sensors

Solder the long headers to the humidity sensor shield

Use poster putty again, it really helps!

fig4

Your finished humidity sensor shield should look like this:

Sensor with headers
Step 3: Stack the shields

Stack the shield over the Wemos and check alignment. The white dots on both the Wemos board and the humidity sensor need to be on the same side.

Check that all pins line up and everything is aligned. If everything is OK then plug it in (push it down as white arrow indicates).

wemos (7)

Your finished Wemos shield pair should look like this:

fig7

In order to check that you put the shield in the correct orientation there is an easy way: White dots. At the Wemos board as well as at the humidity sensor shield you are going to find a white dot in one of the corners. The white dots from Wemos board and sensor shield must be in the same side (just like the picture on the right)

fig8
Step 4: Connect the cables

Connect the sensor with four M/F jumper wires as follows. The picture shows the connections of the female side to the SDS011 sensor.

wemos (10)
Sensor Wemos
5V 5V
GND GND
RXD D6
TXD D7
fig11
fig10

Install the software

Step 1: Preparations and downloads

Download the Arduino IDE software and install it on your computer.

image12

Register on the hackAIR platform (if you have not done that already).

Go to your user profile on the platform Tab “Sensors” click on “add a new sensor”.

image18

Fill in the information for your new sensor, including location details.

image16

Save the information that you have provided. Now you go back to your profile, go to the tab “My sensors”. Click on the arrow in the bottom right corner. This takes you to your sensor profile. Here you see the access key. Copy the access key into a document on your computer. You need it later.

access key 2
Step 2: Arduino set up

Now open the Arduino software to set it up to work with your sensor.


Arduino 1

1. Add a board manager. Go to Arduino Preferences

Arduino preferences

Add the following link to Additional Boards Manager URLs:

http://arduino.esp8266.com/stable/package_esp8266com_index.json
Additional Boards Manager (1)

Go to Tools Board Boards Manager…

image19

Search for ESP8266, click on it and install esp8266 by ESP8266 Community.

image5

2. Install libraries

Click on Sketch Include Library Manage Libraries…

We need to install the following four additional libraries:

  • WiFiManager by tzapu
  • DHT sensor library by Adafruit
  • Adafruit unified sensor library by Adafruit
  • ESP8266WiFi by I.Grokhotkov
  • hackAIR by Thanasis Georgiou
image25

Search for WiFiManager.

Choose WiFIManager by tzapu and install it.

image24

Search for DHT sensor library. Choose DHT sensor library by Adafruit and install it.

image28

Search for Unified sensor abstraction layer. Choose Adafruit Unified Sensor and install it.

image22

Search for esp8266wifi built-in. Choose ESP8266WiFi by I. Grokhotkov and install it.

esp wifi

Search for hackAIR. Choose hackAIR by Thanasis Georgiou and install it.

Capture

3. Connect Wemos

Connect the Wemos sensor to your computer with the USB cable.

Select the correct board type by going to Tools Board Arduino Wemos D1 R2 & mini

image14

Select the correct port by going to Tools Port [name of the port]

On Windows: If more than one port is shown, you can find the correct one in your computer’s Device Manager.

On Mac: you’ll first need to download USB2Serial drivers. You can find drivers in this article. Once that is done, choose something like “wchusbserial”.

image8

4. Upload software to Wemos

Go to File Examples hackAIR Wemos

image2

This is the window that opens – it contains the software that needs to be uploaded to your Wemos sensor

image13

Scroll down to Line 27: #define AUTHORIZATION “AUTHORIZATION TOKEN”

Replace the words “AUTHORIZATION TOKEN” in the quotation marks with your sensor access key, but keep the quotation marks.

image7

Now you are ready to upload the software. To do so, just click on the upload button (the arrow that points to the right).

image17

5. Connect the sensor to the network

Now you are ready to use your sensor. Disconnect the Wemos from the computer, and reconnect it with the sensor. When you power it up, it will create a temporary WiFi network.

With your laptop or phone, connect to the WiFi network ESP-wemos. Go to 192.168.4.1 and configure the WiFi by entering the details of your home WiFi (SSID and password). Once set up correctly, the temporary network will disappear and the sensor starts measuring.

Screen Shot 2018-05-01 at 15.21.21

Measure air quality

Once your sensor is up and running, you can read its measurements on the platform:

  • Browse to the https://platform.hackair.eu and login with your account
  • Visit your profile and select your sensor area
  • By selecting each sensor you will be able to see your measurements.

CHECK YOUR SENSOR IS WORKING

If your sensor does not show up on the platform, you can check if the sensor is working with the Arduino software:

1. Connect your sensor to your computer

2. Select the right port

3. Open Tools > Serial Monitor

4. You should see:

  • a row of numbers appearing
  • the message “connected”
  • a line with: {“reading”:{“PM2.5_AirPollutantValue”:”X”,”PM10_AirPollutantValue”:”Y”},”battery”:”Z”,”tamper”:”0″,”error”:”0″}

5. Check your internet connection, and the SSID and password, if “connected” does not appear

6. Check your soldering and connections, if the line “{“reading”:{etc.” doesn’t appear