Friday, March 25, 2016

Graphing temperature on DataDog from an esp8266

One of my colleagues, Jules, is totally hot. I think his desk is under an air conditioning vent or perhaps he just works too hard. Anyhow, it gave me an idea. Recently we've been using the cloud logging service DataDog to send data to and have it graph and alert us. I wanted to log the temperature from an esp8266 01 board.


DataDog has a simple API for sending measurements to which you post JSON with an array of data points and a unix timestamp. Then you can make up dashboards with graphs like this:



The temperature and humidity sensor is one I grabbed at Jaycar, they call it a Duinotech XC4432 that contains a DHT11 sensor. Unfortunately the resolution seems only to be a degree so I'm waiting for something better to come in the post.

Because DataDog wants a time stamp with every reading, I get the time from an NTP server. The code is mushed together from three samples:

  • DHTester from Ladyada
  • The ESP8266 BasicHttpClient (but using POST instead of GET)
  • The UdpNtpClient from the Ethernet library
I'm using GPIO 2 on the esp8266 to read the sensor. 

No comments: