maltepöggel.de

WiFi Weather Sensor

Your own weather station for the Internet of Things

Photo: Weather station

Based on the ESP8266 WiFi SoC, a tiny sensor has been developed which can transmit temperature, humidity and air pressure to the cloud or to a (local) MQTT or web server. For power supply, rechargeable batteries or a conventional USB port can be used. Through clever power saving mechanisms, the sensor easily achieves a runtime of several months in battery mode. The firmware was written in C and is freely available under GPL.

Hardware

Picture: Circuit diagram

The LDO IC3 regulates the battery voltage down to 3.3 V to power the whole system. The battery voltage is monitored by the voltage divider R7 / R8, which is turned on by FET T2 only during measurement to reduce power consumption. The air pressure sensor IC4 and the temperature/humidity sensor IC5 (alternatively IC1) are connected to the ESP8266 module IC2 via the I2C bus. Status LED (D2) and a setup button (S1) are directly connected to the WiFi module. R3 is used as a pull-up resistor for the push button, R2 for the reset pin. In low-power standby mode, XPD_DCDC (GPIO16) is pulled low on a wakeup timer event. I connected this to the reset pin via a shottky diode (D1) because GPIO16 seemed to be high otherwise, and a few milliamps of current flowed during the reset when the ESP was flashed via the serial connection.

There are three variants of the board. These differ only in the sensors used. Version 1 uses a SHT1x temperature/humidity sensor and a BMP180 air pressure sensor. In version 2, this has been replaced by an MS5637 as Bosch has discontinued the BMP180. Version 3 uses an SHT3x temperature/humidity sensor and also the MS5637 barometer. In addition, the third version offers a connection option for external sensors. The AM2302 temperature/humidity sensor, which is possible on all boards, should not be used because it does not always work reliably over a long period of time, and currently sold sensors crash due to debug output when the ESP8266 is started on the port pin used (GPIO2).

The ESP8266 can heat up slightly during longer operation, but by using a low-power standby, the short period of time for transmission does not play a significant role. The standby also allows operation with rechargeable batteries / solar cells.

Photo: Measurement of current consumption

The measured current consumption of version 2 in operation is about 120mA on average. Measurement, connection to the WLAN and data transfer take about 5 seconds. In standby only 60µA are needed. With a measurement interval of 5 minutes, the daily consumption is 50mAh. With 2500mAh Mignon batteries, operation is guaranteed for 50 days (1.5 months), 5000mAh Baby batteries double the runtime. The exact calculation can be found in the slides of my presentation at the Maker Faire on page 16.

Software
Photo: Flashing the ESP

The software can either be flashed using the pre-compiled binaries, or compiled yourself beforehand. For the transfer a USB-Serial-Converter with 3,3V TTL output is needed. This is connected to the pin header on the WiFi Weather Sensor. Detailed instructions can be found in the GitHub repository of the weather station.

Within the firmware there are two modes, normal mode and configuration mode. In normal mode, the sensor measures, and then sends data to the cloud. In configuration mode, the sensor operates as a wireless access point and is configured through a standard web browser. When the sensor is active, the mode can be changed by holding the button for about 3-4 seconds. After the first start in normal mode, the sensor remains active for one minute to allow switching. Once the sensor is in low power standby, the button has no function.

In normal mode, the LED flashes at 1 second intervals to indicate status.

Number of flashes Status
1x WiFi connect, DHCP configuration
2x Transfer measured values
3x Server error
4x First start, waiting

In configuration mode the LED flashes with 1Hz. A connection to the WLAN ESP_xxxx must be established with a laptop or smartphone, and the URL http://192.168.4.1/ must be opened in the browser. The start page shows the current measured values. The "Settings" button at the top left takes you to the settings. The default user name and password are "admin" and "insecure".

Screenshot: Start page
Screenshot: Configuration WLAN
Screenshot: Sensor configuration
Screenshot: User configuration

The sensors used are automatically detected. The data transfer can be done via HTTP request or MQTT. Via HTTP for example the platform Thingspeak can be used (optimal for beginners), but also an own backend can be used. With an own MQTT server like Mosquitto the processing is even more flexible. Here, among other options, the combination of Telegraf, InfluxDB and Grafana would be possible.

Mounting

For mounting I use the protective case TFA 98.1114.02, which is available online for about 15€. It protects against rain and heating by sunlight, and can be screwed to the wall or attached to a pole with cable ties.

Picture: Weather protection housing

Conclusion

I have, as of 2022, the weather station in operation for about 5 years in several locations. The firmware runs stable so far. However, the ESP8266 NonOS SDK used by the WiFi Weather Sensor is not further maintained by the manufacturer Espressif. Since all features are implemented in the sensor, a further development of the firmware is also no longer planned on my part. In the meantime, numerous alternatives have appeared, which are actively developed and maintained by a large community. Over a longer period of time, my sensors will therefore be replaced by LoRa sensors (several years runtime from batteries), or, if power is available, by the IoT Geiger Counter with ESP32 and ESPHome firmware.

Links and documentation
Downloads