Example Using InfluxDB: Difference between revisions

From lechacal
Jump to navigation Jump to search
No edit summary
Line 5: Line 5:
==Prerequisites==
==Prerequisites==


The RPICT series board must output as CSV for this to work.
The RPICT series board must output using format=3 (default) for this to work.


Document edited using influxdb version 1.2 and python-influxdb version 4.0.
Document edited using influxdb version 1.2 and python-influxdb version 4.0.

Revision as of 10:10, 11 March 2020


This is a basic example to forward RPICT data to an InfluxDB database. Note this only covers a skeleton to start building your own application.

Prerequisites

The RPICT series board must output using format=3 (default) for this to work.

Document edited using influxdb version 1.2 and python-influxdb version 4.0.

Installation

Server side hosting InfluxDB

Install InfluxDB as recommended. This link provides compiled executables.

Github link is here.

We will call this server hostname myserver for our example below.

For our example we need to create a database within influxdb. From a terminal on the influxdb hosting server issue the command below:

$ curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"

If you want to install influDB on the Raspberrypi itself just follow this guide.
Install an InfluxDB Grafana stack on a Raspberrypi

Raspberrypi side

We are proposing a basic script template which can be installed as below.

sudo apt-get install python-requests
wget lechacal.com/RPICT/tools/lcl-gateway.py.zip
unzip lcl-gateway.py.zip
wget lechacal.com/RPICT/tools/gateway.conf
sudo mv lcl-gateway.py /usr/local/bin/
sudo mv gateway.conf /etc/

Edit the gateway.conf file to reflect your own setting. Content will be self explanatory.

sudo nano /etc/gateway.conf

Insert the RPICT and run

lcl-gateway.py -d

Run the Gateway script in background

You might need to keep the previous gateway program running in the background.

Install Screen.

sudo apt-get install screen

Then run

screen -d -m lcl-gateway.py

To stop it just run screen (provided you are only running one screen at a time).

screen -r

Then press ctrl ^C.