Python program to subscribes to the MQTT broker of The Things Network and saves incoming data into InfluxDB.
Find a file
Angel Maldonado f7407e54eb
Update README.rst
Improve readme readability
2024-05-06 18:37:39 +01:00
connections Added python logging module to log the program traces 2022-07-12 20:57:36 +02:00
etc/systemd Updated path 2022-07-17 20:16:48 +02:00
ttn2influxdb Improve the function to send data frame to influxdb 2022-07-14 21:28:01 +02:00
.gitignore Update gitignore 2022-07-21 18:47:02 +02:00
LICENSE Initial commit 2022-07-09 19:15:31 +02:00
README.rst Update README.rst 2024-05-06 18:37:39 +01:00
setup.py Added python logging module to log the program traces 2022-07-12 20:57:36 +02:00

Python program to subscribes to the MQTT broker of The Things Network (v3 stack) and saves incoming data into InfluxDB.

TTN (`The Things Network`_) is building a global open LoRaWAN™ network.

******************
Configuration file
******************
The configuration file contains the basic parameters to establish a connection to The Things Network's MQTT broker and the influxdb database. The schema of this file is as follows:
::

    [ttn]

        app_id = 
        access_key = 
        broker_url = eu1.cloud.thethings.network
        broker_port = 1883

    [influxdb]

        user = 
        password = 
        database = 
        measurement = 

More than one configuration file can be added to establish different connections to the MQTT broker.

*****
Setup
*****

Clone the repository and create a new python virtual environment in which to install the ttn2influxdb package.
::

    git clone https://github.com/AngelJMC/agriot-ttn-influxdb-connector
    cd agriot-ttn-influxdb-connector
    sudo python3 -m venv /opt/ttn2influxdb/pyenv
    source /opt/ttn2influxdb/pyenv/bin/activate
    sudo /opt/ttn2influxdb/pyenv/bin/python3 setup.py install

Copy the configuration file to the installation directory and add the configuration parameters.
::

    # Copy configurations
    sudo mkdir /opt/ttn2infuxdb/connections
    sudo cp connections/config-example.ini /opt/ttn2influxdb/connections
    
    # Edit configuration file
    sudo nano /opt/ttn2influxdb/connections/config-example.ini


Configure program execution
::

    sudo cp etc/systemd/ttn2influxdb.service /opt/ttn2influxdb
    ln -sr /opt/ttn2influxdb/ttn2influxdb.service /usr/lib/systemd/system/
    
    systemctl enable ttn2influxdb
    systemctl start ttn2influxdb
    systemctl status ttn2influxdb
    journalctl -u ttn2influxdb -f



.. _The Things Network: https://www.thethingsnetwork.org/
.. _MQTT: https://mqtt.org/
.. _InfluxDB: https://github.com/influxdata/influxdb