Example Using InfluxDB
THIS IS OUTDATED USE THE LINK BELOW INSTEAD
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.
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.
We will assume here a setup having:
- Server Side. The unit running the influxdb service and waiting for input data.
- Raspbberypi Side. The unit connected to the RPICT and forwarding data to the server above.
We have covered the case where the Raspberrypi is both the Influxdb/Grafana server and also connected to the RPICT in this guide below. Install an InfluxDB Grafana stack on a Raspberrypi
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 db01"
Replace the db01 in the above with whatever you please.
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
Run the Gateway script in background
You might need to keep the previous gateway program running in the background.
sudo apt-get install screen
screen -d -m lcl-gateway.py
To stop it just run screen (provided you are only running one screen at a time).
Press ctrl ^C to kill the program.
Press Ctrl ^A then D to let it run and detach from the screen session.
Run the Gateway script at boot time
Edit the rc.local file.
sudo nano /etc/rc.local
Then just before the exit 0 line add the following line:
screen -d -m /usr/local/bin/lcl-gateway.py
Once the Raspberrypi rebooted you can access the session using
sudo screen -r