January 2019
Intermediate to advanced
458 pages
10h 35m
English
Recording the sensor readings and later the statistics read from the coffee machines was a priority from the beginning. The ideal database for this kind of data is a time series database, of which Influx is a common one. The biggest problem with this database is that it does not support MQTT, only offering its HTTP and native interface.
To fix this, a simple MQTT-to-Influx HTTP line protocol bridge was written, again using the Mosquitto client library as well as the POCO framework's HTTP functionality:
#include "mth.h"#include <iostream>using namespace std;#include <Poco/Net/HTTPRequest.h>#include <Poco/Net/HTTPResponse.h>#include <Poco/StringTokenizer.h>#include <Poco/String.h>using namespace Poco; ...