Part of the Getting Started with ESP8266 + Arduino series.
While learning to write applications for the ESP8266/Arduino platform, I wanted to make sure I could post data from the microcontroller to my home InfluxDB instance. The result of this is the
influxdb branch of my
esp8266-basic-wifi repository on GitHub.
This was remarkably straightforward, thanks to the open-source InfluxDB Arduino Client library!
At first I was concerned I’d have to figure out how to keep an accurate clock on the ESP8266, but that turns out not to be the case unless you’re performing batch writes. (I also learned, while working on my HTTPS demo, that this is surprisingly easy.)
The client library’s documentation is quite comprehensive, so I don’t actually have a lot to write about here. But there are two points I’d like to call out:
You can’t post a data point using this library from inside an async callback, like the ones provided by akaJes/AsyncPing. I tried that initially and got a crash. At the time I hadn’t figured out how to set up exception decoding, but commenting out the
writePoint call fixed the crash.
You can write client code with this library that’s compatible with InfluxDB v1 and v2, using some simple preprocessor directives. See the
InfluxDBClient definition in my demo code, and the accompanying configuration example.