Disclaimer: This is not an official Google product.
This script reads data from a serial device, typically Arduino, in InfluxDB's line protocol format and forwards it into an Influx database.
Write an Arduino program that sends data in InfluxDB's format on the serial line without timestamps (which are generally unavailable on Arduino). For example:
plant,pin=A15 moisture=140,temperature=27.4,humidity=67.3
Prepare an Influx database where you want to store the data. Then run:
python3 collect.py -d /dev/ttyUSB0 -H localhost:8086 -D plants -T location=foo
This reads data from /dev/ttyUSB0
and writes them to the database plants
running on localhost:8086
(the default value for -H
). It also adds tag
location=foo
to each sample, in addition to the above pin=A15
sent by
Arduino.
For detailed information about command line arguments run
python3 collect.py --help
If the Influx database runs on a different machine, it might be helpful to run Telegraf locally. This has the advantage that Telegraf can buffer messages in the case the connection to the database fails, and also allows to collect monitoring data about the machine, which is generally a good thing for long-running systems.
Keep in mind that Telegraph only allows posting data to a single database, the
one configured in Section [[outputs.influxdb]]
. It ignores the database name
passed to it by collect.py
(or any other script).
- Python 3.6+
- Python libraries:
- retrying
- pyserial
- persistent-queue-log -
included as a
submodule; just
clone this repository with
--recurse-submodules
.
On Debian the first two can be installed using
sudo apt-get install python3-retrying python3-serial
Contributions welcome, please see Code of Conduct and Contributing. Currently I'd like to add: