d for dynamic, m for mapping and way from gateway.
The objective of this project is to develop an application that links a network of sensors and Thingsboard. This application includes :
- checking the format of the data received by the sensors
- data persistence
- the creation of sensors on Thingsboard
- the provision of data on Thingsboard
This approach is a direct alternative to Thingsboard Gateway, offering a more generic view by providing dynamic mapping.
Here is how dmway fits into our network architecture :
If you want a lower-level view to understand how dmway works, a flowchart is available.
- Raspbian Strech (desktop and lite version)
- Raspbian Buster (desktop and lite version)
First, you must have Thingsboard platform running.
If not, you can follow the Thingsboard installation guides.
You can install a MQTT broker locally or use a MQTT broker on the cloud.
These following way use a local Mosquitto broker but you can use your own MQTT broker.
$ sudo apt update
$ sudo apt install -y mosquitto mosquitto-clients
You may also need to install the git tool for cloning the dmway project from Github :
$ sudo apt install -y git
dmway requires at least Python 3.5 version so you don't need to upgrade Python to a newer version :
$ sudo apt install -y python3.5 python3-pip
Clone the dmway source code and install dmway dependancies :
$ git clone https://github.com/martindenion/dmway.git
$ cd dmway
$ sudo pip3 install -r requirements.txt
To run dmway, 3 methods are possible depending on the needs :
Then, you can execute the app.py Python file :
$ cd dmway
$ python3 app.py
Output:
Connecting to SQLite database ...
Connected to SQLite database 2.6.0
Connected with result code 0
dmway is now waiting for receiving JSON data by MQTT.
$ cd dmway
$ chmod +x make_service.sh
$ sudo ./make_service.sh 'dmway' '/home/pi/dmway/app.py' 'dmway.service' yes
Output :
Created symlink /etc/systemd/system/multi-user.target.wants/dmway.service → /etc/systemd/system/dmway.service.
$ sudo reboot
dmway is now waiting for receiving JSON data by MQTT.
TO DO
Considering this format, execute the following command line :
$ mosquitto_pub -h localhost -m "json_message" -t "topic"
Note : if you ran dmway using the development way, execute the previous command line from another duplicated shell to let dmway running correctly.
In order to better understand what does this command in the dmway context, see this diagram.