Forward to Influxdb from RPICT
We will introduce you to the forwarding tool for Influxdb 'lcl-gateway'.
Prerequisites
- Influxdb is already installed and a database has been created.
- RPICT unit has been tested with the cat or lcl-run commands first.
- RPICT is using the default output format number 3.
Installation
Get the lcl-gateway tool and install it this way.
wget https://github.com/lechacal/lcl-gateway.py/releases/download/v2.1.0/lcl-gateway_2.1.0_armhf.deb
sudo dpkg -i lcl-gateway_2.1.0_armhf.deb`
Configuration
You can now edit the configuration file
sudo nano /etc/lcl-gateway.conf
The file looks like this
[system]
port=/dev/ttyAMA0
baud=38400
[emoncms]
enabled = False
hostname = emoncms.org
apikey = --apikey-from-emoncms-goes-here--
node = 20
[influxdb]
enabled = True
version = 1
measurement = rpict3t1
# Parameters for version 1 below
db = home
url = http://192.168.1.65:8086/write
# Parameters for version 2 below
#url = http://192.168.1.169:8086/api/v2/write
token = NbMVAzr35B0uZehxgd_lPgVpqjDGM2-r2UF15Qd3F4D0uv-VKtVsWslH4-7vVDH1r95A-imvdqPALt1m9bW6rA==
org = lcl
bucket = home
[localsave]
enabled = False
directory = /tmp/
There are 2 versions of Influxdb. You should indicate which version is used in the version parameter.
For version 1 you must indicate the db and url parameters.
For version 2 you must indicate the url (uncomment it by removing the leading #) and also token org and bucket. token is the API token that can be obtained from the Influxdb interface. org and bucket are set when you first setup the Influxdb database.
Start lcl-gateway
Foreground execution
If you prefer running the program by hand to assess debugging information use the command below:
/usr/local/bin/lcl-gateway.py -d
Background execution
To run the gateway in the background we first need to configure the service configuration.
Open the file
nano /lib/systemd/system/lcl-gateway.service
You will find a line showing User=pi
modify pi
in this line with the user being used.
You can launch the gateway in the background using
sudo systemctl start lcl-gateway
To make the gateway start automatically at boot time enter:
sudo systemctl enable lcl-gateway