by Floris Wouterlood – August 16, 2020
In a previous project I described a weather station* while another project dealt with an outdoor fine dust particle sensor**. Both devices use a NodeMCU ESP8266 microcontroller board and both report data to a server on the internet. The fine dust particle sensor was together with a power supply packed in a waterproof box placed provisionally outside the home. In contrast the weather station’s box with the microcontroller was mounted inside the home and wired via a twisted pair cable with sensors outside. Both devices had been running uninterrupted and very successfully for more than one year and both needed maintenance and cleaning. For instance, one of the two weather stations’ DHT11 sensors had stopped working and the fine dust particle sensor box badly needed improved protection from the weather. A new design was created, including a single weatherproof casing mounted outside the home that accommodates both environmental sensor devices. The weather station is from now on equipped with a single, accurate sensor that measures temperature, relative humidity and atmospheric pressure: a GY-21P.
Figure 1. Components of the combined weather station and fine particle sensor. Sensors are indicated in orange.
Typically a weather station keeps track of temperature, atmospheric pressure, relative humidity, precipitation and wind direction/speed. The basic outdoor parameters that I am interested in are temperature, barometer and relative humidity. The sensors that measure these parameters must for that matter be positioned either outside the protecting case that contains the electronics and power supply, or in some open bay integrated in or attached to the case. Here I opted for placing the sensor in its own bay that is attached to the outside of the case. The PMI SDS011 fine dust particle sensor has a little tube attached to it that samples air. This tube needs a little opening in the protecting case, while a secondary opening is necessary to allow air coming out of the SDS011 to exit the case. As the NodeMCU ESP8266 is fully Arduino compatible and especially because it has wifi on board this is my favorite microprocessor for this project. The fine dust particle meter has its own NodeMCU ESP8266.
GY-21P is the name of a 3.3V breakout board that contains two components: a BMP280 unit that measures barometric pressure and temperature, and a Si7021 unit that senses relative humidity and temperature (fig. 2). These are fairly accurate components; the BMP280 is said to be accurate with a range of 1 meter altitude at sea level; temperature readings have an accuracy of 0.1 degree centigrade. Temperature range is -40 oC to 85 oC. Relative humidity is registered with a deviation of 3% in the 20%-80% humidity range. The dimensions of the breakout board are 11 x 16 mm and it has an I2C interface. I2C supports only short-distance communication. The GY-21P should therefore be mounted close to its reporting microcontroller.
Figure 2. A, GY21-P breakout board. B, GY-21P mounted on a pin header soldered to a circular piece of soldering board, C and D, sensor board mounted inside the pod, at various angles.
GY-21P sensor pod
While the GY-21P must be mounted close to its microcontroller board it should remain outside the main case. I manufactured for this purpose a pod based on a design described in the weather station project*. This pod is made from an acrylic vial with a plastic cap that snaps onto the vial. The bottom of the vial is carefully removed. A circular opening is cut in the center of the cap, and the cap is then fastened on the outside of the bottom of the main protective case with two nylon bolts. At the central opening in the cap a hole is drilled in the protective case that serves both as conduit for the wires linking the GY-21P and the microcontroller board and as outlet for processed air emanating from the fine dust particle sensor. Next, a circular piece snuggishly fitting the inside of the vial was cut from a prototyping board. A 4-pin female pin header was soldered onto this circular piece to accommodate the GY-21P. The bottom pins of the pin header were wired to the proper pins of the microcontroller board (see section ‘Main Board). Figure 2B shows the components while the assembled pod can be seen in figure 2C-D. The sensor is kept in place by a small piece of perforated foam plastic. After completion the pod was snapped onto the case-mounted cap. A fine gauze glued on top of the pod prevents insects and dust from reaching the sensor or entering the case. In order to protect the vulnerable sensor pod against rain and ice a protective square plastic box has been mounted upside down over the pod, thus effectively acting as a ‘bay’ (see figure 4).
Four wires lead from the pod to the weather station’s board: power (3.3V), GND and two I2C signal wires: data (SDA) and clock (SCL).
Building the interior of the main case: the ‘base board’
Although it is possible and economical to solder a NodeMCU board and sensors directly onto a soldering board, experience learns that the most flexible construction is that a ‘base board’ is equipped first with female pin headers, board wiring and resistors, such that for final assembly all major components of the weather station can simply be plugged in: microcontroller board, sensors. The advantage of a base board is that failing parts can be replaced immediately, without de- and re-soldering. After decommissioning of a project the still usable components can easily be recovered.
Weather station: 1x Lua NodeMCU ESP 8266 microcontroller board, 1x GY-21P breakout board, 1x 80×60 mm soldering board (the ‘base board’), 2x 4.7 kΩ resistor (pull up for the SDA and SCL wires of the GY-21P, female pin headers, big weatherproof 200 x 155 x 95 mm PVC box with transparent lid (the ‘case’), Dupont pin header wires, acrylic vial with plastic cap, fine nylon gauze, nylon bolts and nuts, nylon spacers
Fine dust monitor: On request a kit is supplied by the staff at luftdaten.info that contains all the components necessary to construct a working device. The main components are a Nova PMI SDS011 sensor and a NodeMCU ESP8266 microcontroller board. The Nova P<I SDS011 is primarily a PM10 counter: a device that detects particles in the 2.5 – 10 micrometer range.
Power: Both devices are powered via their micro usb connector by a 5V DC twin outlet usb power supply plugged into the female connector of a 230V AC extension wire.
Case: The case was delivered with a DIN rail mounted inside. This rail was removed and a ‘floor’ was constructed cut out of a piece of plywood. The fine dust particle sensor assembly and the weather station base board were mounted with nylon spacers onto this plywood floor.
Assemblage of the weather station
Figure 3 shows the wiring scheme of the weather station, the NodeMCU pins assigned to the various sensors and the pull up resistors. The ‘base board’ on which the NodeMCU is positioned was re-used from the previous weather station project*. It has 4.7 kOhm pull up resistors on the SDA and SCL lines. This board is visible in figure 4.
The pins of the NodeMCU board stick into two parallel female 15-pin headers soldered onto a 80×60 mm soldering board: the ‘base board’ (visible in figure 4). An alternative to this home-made motherboard is the more luxurious ready-to-use, commercially available NodeMCU base. On the base board are soldered the 4.7 kΩ pull up resistors for the SDA and SCL lines coming from the GY-21P pin header. Without proper pull up resistors the I2C protocol will not reliably work and data from the BMP280 sensor will not be received properly by the NodeMCU board. The assembled prototyping board is shown in situ in figure 4.
Figure 3. Semi-schematic wiring diagram for the weather station.
The fine dust particle sensor has its own binary flashed into memory of the associated NodeMCU. This binary is available from luftdaten.info together with a description how to flash and how to configure.
The weather station sketch was locally developed. After developing, testing and uploading the final weather station sketch into memory of the weather station NodeMCU the combined weather station – fine dust particle sensor was mounted in a proper shady place outside the home, within range of a range extender of the wifi router. This range extender was mounted indoors, as close as possible to the combined station. Power was switched on and the weather station and fine dust particle sensor could start operating!
Figure 4. Components mounted in the interior of the protective case. The left part of the case contains the fine particle sensor with piggy-backed the NodeMCU serving it. Its air inlet sticks out of the case. The weather station ‘base board’ is on the right (green PCB) with the NodeMCU and the pin headers for the sensors. Painted colors on sensor pin headers indicate 3V (red), GND (black) and data (white).
Figure 5. Combined weather station – fine dust particle sensor up and running.
Fine dust particle sensor
The sensor was already configured a year ago and connected via the home wifi network to the server at OK Lab in Stuttgart, Germany (see the paper dealing with the construction of the fine dust particle sensor**. After registering the sensor and providing its geolocation the sensor appears as a hectagonal icon on a world map at https://luftdaten.info. Clicking on that icon shows the actual PM10 air quality expressed in micrograms per cubic meter of air. The color of the map symbol changes towards red in register with the measured air quality. Luftdaten is a citizens network that reports air quality all over the world. The air quality situation on August 14, 2020 in western Europe is shown in figure 6.
figure 6. Air quality map at http://luftdaten.info showing south England, The Netherlands, Belgium and western Germany. Air quality over western Holland, Flanders and London is poor. Every hexagonal represents a sensor location.
Weather station – sketch
ThingSpeak is a service offered on the internet by MathWorks. According to its developers, “ThingSpeak is an open source Internet of Things (IOT) application with an API (application programming interface). ThingSpeak encompasses the creation of sensor logging applications, location tracking applications, and a social network of things with status updates” (source: wikipedia – search term <ThingSpeak>). In order to use ThingSpeak, one has to register to obtain an API key / password combination. Next, channels can be configured at thingspeak.com to receive and display data. In this example, data are exported from the NodeMCU board to a channel at ThingSpeak named ‘Weather Station’ (figure 7). See for details my earlier publication about the predecessor of the weather station *.
The instructions in the sketch consist of three groups:
1. Connect via wifi to the local area network (SSID, password)
2. Identify the microcontroller to ThingSpeak (API ID, password)
3. Read the four environmental data from the GY-21P. Every ten minutes the data of three parameters (i.e., average of the two temperature readings, relative humidity and atmospheric pressure) are relayed via wifi, my router and the internet to a server run by ThingSpeak.
Results: weather station in full operation.
After some test runs to confirm that all systems were working correctly and uninterrupted, especially the wifi connection between the NodeMCU in its case outside my home and the wifi router installed inside, continuous logging was started. ThingSpeak displays on its website data in a user configurable data window. In addition it allows downloading all logged data in .csv format from the server. These data can be imported in a spreadsheet for further processing. Figure 7 shows temperature plots of data collected over a few days in early August 2020 during a period of excessive summer heat.
Figure 7. Drilling the ThingSpeak data. Graph produced by my spreadsheet showing outdoor temperatures in the period August 9 through August 13, 2020. The inset shows a screen capture from the ThingSpeak channel where for easy visualization there is an option to configure an analog looking “meter’.
Because both the (predecessor of the) weather station* and the fine dust particle sensor** had been in continuous operation for over a year there existed full confidence that the combined design would properly work. Prior to assembling the sensor pod the GY-21P had been ‘dry’ tested on a test bench in my workshop, both with an Arduino Nano and with the same NodeMCU ESP8266 as in the final design. The fully assembled weather station – fine dust particle sensor was tested next in my workshop. Wifi signal strength here is perfect, reported by the NodeMCU as -58 dB. However, initially the wifi signal at the spot where the weather station was planned was insufficient (-63 dB) for the weather station while the fine particle sensor worked as expected. What worried me most was the wifi data signal generated by the NodeMCU’s. This relatively weak signal has to pass the wall of the protecting case, bridge the distance from there to my home, pass thick double-paned windows and still have sufficient power to negotiate and deal with the wifi router.
A solution surfaced in the shape of a wifi repeater installed in the kitchen of my home. From then on reliable constant data transfer was obtained of the weather station’s NodeMCU to the Thingspeak server. With the wifi repeater wifi field strength at the position of the weather station was a crisp -54 dB.
With one (weather) data transfer to the ThingSpeak server, every ten minutes, of three sensor readings, every 24h period produces 24 x 6 x 3 = 432 data points. One month of operation results in 13,392 data points. One year of uninterrupted data collection will result in 157,680 data points. To prevent the accumulation of data to unmanageable amounts I adopted with my previous weather station a policy of downloading data every month and then remove redundant data from the server. Another approach is to reduce the number of readings to, say, one transmission every 15 minutes. Such a reduction results in a 30% saving on accumulated data points a the price of losing resolution.
Downloadable sketch: GY21P_ESP8266_weather_station.ino
* Constant monitoring of five environmental parameters with a NodeMCU ESP8266 based weather station connected to the Internet – TheSolarUniverse.wordpress.com, 2017
** Fine dust monitoring/logging at luftdaten.info with a Nova PMI SDS011 sensor, a NodeMCU ESP8266 and the internet – TheSolarUniverse.wordpress.com, 2019