Building a esp8266 based weather sensor

In a previous post i wrote about integration of a netatmo weather station into a telegraf/influxdb/grafana stack. The second part of the project was to build a weather sensor for my basement and to integrate it into this stack.

The used esp8266 is a cheap low-power 32bit microcontroller often used for IoT devices. I used a Sparkfun “The Thing” board because it already has a LiPo-charger and a connector for an external antenna on board. But the board has no build in serial/usb connector. You have to connect a USB-RS232 temporary for programming the chip. I used a simple FTDI breakout.

The sensor chip is a DHT22. A digital sensor for temperature and humidity. Since it uses a digital protocol wiring is really easy. Just connect it to 3V3 and GND for power and to a GPIO pin for data.

On the software side i used ESPEasy which is a complete firmware for the esp with everything included. It just must be compiled and falshed. Then everything can be configured by browser. I patched it a little bit to also calculate the value for absolute humidity.

I’m using the build-in “OpenHAB MQTT” connector to upload values to an mosquitto mqtt broker. This format could be read with telegraf with the following configuration:

The finished board.

Prototype on a breadboard.

Integrate Netatmo Weather station into TIG stack

To integrate my netatmo weather station with custom esp8266 based weather sensors i decided to setup a TIG stack.

The components of the stack are

  • Telegraf – collects data from different sources and pushes them to influxdb
  • Influxdb – a metric database
  • Grafana – a visualization and dashboard application

The netatmo weather stations have no direct interface to capture the collected data, but there is an API server provided by Netatmo to retrieve data from it.

To access the API you must log into the developer website with your netatmo account and register an application:

https://dev.netatmo.com/

After you created an application on their website an client_id and client_secret is assigned to this application. You need this information together with your account credentials to access your stations data within the API.

I wrote an integration script to read the data from the API and output it as JSON suitable for telegrafs exec input:

https://github.com/benningm/docker-telegraf-netatmo

The script could be used directly or as a docker container:

https://hub.docker.com/r/benningm/telegraf-netatmo/

See the github page or docker hub page for usage instruction.