Server Software

  • Single line multi platform install (does not include the Python scripts yet)

docker pull wassfila/hsm

  • Host Controller Interface publish mesh packets on MQTT
  • Python client push MQTT publications in influx time series Database
  • MQTT allows connection of IoT software such as OpenHAB and NodeRed
  • Grafana displays the sensor data history on graphs dashboard
  • docker image available for grafana, influxDB, Mosquitto, (Python clients coming)

Fork me on github

Server SW
Server Software


RF Mesh to MQTT

  • RF binary protocol has standard MQTT topics
  • No configuration required as a mapping is used
  • Bi-directional
    • Publish RF Mesh packets on MQTT
    • Subscribe to MQTT and Broadcast commands on the RF Mesh
  • floats used as payload for connection to database without configuration

RF Mesh to MQTT Mapping
RF Mesh to MQTT Mapping


Detailed Software Interaction

  • MQTT is the central element connecting all processes
  • Any further custom client can be added such as here wemo for smart sockets or milight for light control
  • The web browser clients are as well an MQTT client thanks to the websocket recompilation of Mosquitto (see Install)
  • Any Ruler can be used such as NodeRed, or here a more flexible Python Ruler that isolates between configuration, rules and ruling client.


Install

Note that this docker install does not contain the Python scripts that map mqtt to the database yet. For a complete install please check the Install page.

Simple for no-brainer users

docker pull wassfila/hsm

The first run allows you to configure the port mapping :

docker run -it --name=hsm -p 3000:3000 -p 8086:8086 -p 1883:1883 -p 1884:1884 ubuntu:18.04 /bin/bash

Note that once a container is created, you can only stop it and start it, if port mapping change is required you’ll need first to create a new image out of it.

Then the daily usage example in interactive mode to edit the container from inside :

docker container start hsm -i

more on how to use docker

Custom for Hackers

as a pro, you’ll clone the nRF52_Mesh repository and find a step by step guide in the Install page.

Configuration

Nodes database

The nodes info is json file containing a map from node id to node parameters, such as the name, the unique identifier, RF channel, sleep time for low power nodes,…

The default path is ‘/home/pi/nRF52_Mesh/raspi/mesh_wizard/nodes.json’ if the repo was cloned on that path, and it is possible to override its location with the environment variable “NODES_CONFIG

{
    "7":   {   "name"          :"nRF_SensorTag_1",
        "board"         :"nRF51_Sensors",
        "program"       :"nRF51_Sensors",
        "uid"           :"0xF9 71 99 F8 46 FA 63 38",
        "data"          : ["acceleration"],
        "channel"       : "2",
        "sleep"         : "10"
            },
    "8":   {   "name"          :"nRF_SensorTag_2",
        "board"         :"nRF51_Sensors",
        "program"       :"nRF51_Sensors",
        "uid"           :"0x77 56 76 2C 40 61 C4 60",
        "data"          : ["acceleration"],
        "channel"       : "2",
        "sleep"         : "10"
            },
    "9":   {   "name"          :"rfserv Dongle5",
        "board"         :"nRF52_Dongle",
        "program"       :"nRF52_Dongle",
        "uid"           :"0x7D F1 29 09 89 99 9C F5",
        "position"      :{ "x":"-1","y":"-1.3","z":"3.7"},
        "channel"       : "2",
        "sleep"         : "60",
        "is_listening"  : "0xBABA",
        "is_router"     : "0",
        "is_uart_cmd"   : "0xBABA",
        "is_rf_cmd"     : "0xBABA",
        "is_rf2uart"    : "0xBABA",
        "is_testmode"   : "0",
        "rtx_timeout"   : "5",
        "rtx_count"     : "3"
            }
}

Host Controller Interface

The configuration is made simple with a json file as input seen below.

{
    "serial":{
        "port":"COM4",
        "baud":460800
    },
    "mqtt":{
        "host":"localhost",
        "port":1883,
        "keepalive":60,
        "client_id":"hci_client",
        "subscriptions":[
            "Nodes/#"
        ],
        "actions" : ["dimmer","heat"],
        "enable"    :false,
        "rf_2_mqtt" :false,
        "mqtt_2_rf" :false
    },
    "log":{
        "logfile":"./hci_client.log",
        "level":"Debug"
    }
}

The main serial port parameters can be adjusted. The MQTT client can have its  client_id adjusted to allow multiple clients to connect from the same machine.

  • actions : here “dimmer” and “heat”, publishing into these MQTT topics will generate an RF message to be sent in the mesh network.  The MQTT payload is a text of a generic float number. A post looks like this
Topic Payload text float
“Nodes/28/heat” “26.6”
  • “enable” : if false the MQTT client will not be used.
  • “mqtt_2_rf” : when true, the HCI will capture the MQTT posts from the “subscriptions” path and broadcast them on the RF mesh.
  • “rf_2_mqtt” :when true, every packet captured on the RF mesh broadcast will be published on the protocol defined corresponding MQTT topic.

Note that true and false are not in text here, but json keywords.

Database Client

{
    "mqtt":{
        "host":"10.0.0.12",
        "port":1883,
        "keepalive":60
    },
    "influxdb":{
        "host":"10.0.0.12",
        "port":8086,
        "db":"meshNodes",
        "logfile":"/home/pi/share/influx_client.log",
        "mqtt_client_id":"py_influx",
        "enable":false
    }
}
  • The MQTT configuration is fast forward, the keep alive is not important and was introduced for debug purpose.
  • The ifnfluxdb is also surprisingly easy to configure, what you’ll love about influxdb is that by default the install is newbie friendly and require no security complex configuration, which goes well with a local network configuration. So all what’s required in addition to the ip and port is the database name.

InfluxDB Create database

Here you’ll only find the most necessary indications, for deeper dive please consider having a look at the official influxDB doc website.

See below for the installation, once installed or if you got a ready to roll image, all what is required is to add the database that we configured to use with Python above.

pi@rfserv:~ $ influx
Connected to http://localhost:8086 version 1.4.2
InfluxDB shell version: 1.4.2
>CREATE DATABASE meshNodes

InfluxDB Backaup and restore

some ready scripts are available on the github repo for backup and restore, here we can see how simple they are, note that you can adjust the time and date of the backup beginning :

#!/bin/bash
influxd backup /home/pi/share/$(date +%F)_influx_backup
influxd backup -database meshNodes -since 2017-12-01T00:00:00Z /home/pi/share/$(date +%F)_influx_backup
#!/bin/bash
sudo systemctl stop influxdb
backup_path=$1
influxd restore -metadir /var/lib/influxdb/meta $backup_path
influxd restore -database meshNodes -datadir /var/lib/influxdb/data $backup_path
sudo chown -R influxdb:influxdb /var/lib/influxdb
sudo systemctl start influxdb

Grafana datasource

With the default install grafana is reachable on “http://yourip:3000”

You should login before you can access the configuration, default access is “admin:admin”

As Grafana has native support for influxDB, no plugins are required, just go to Configuration\Datasources and click add datasource:

Make sure you retype the url in the grayed URL section as the grayed text is not considered.

Grafana Sensor Node

The most difficult is already through, now it’s time to add the sensor nodes to the Dashboard. Please have a look at the official Grafana website for more details.

From the + menu create a dashboard, then click on add a panel, select the type Graph. Don’t get frighted by the data that appears, if you didn’t select influxDB as the default datasource some random data will be displayed. From the panel title click on Edit. Toggle the edit mode that allows to paste the query in one text line and fill such as the screenshot.

From the menu on the right, it is possible to “duplicate” entries for quick additions, all that has to change is :

  • Node id : The mesh RF Network Node Identifier e.g. “node76”, corresponds also to the physical sensor item.
  • sensor parameter : Such as “temperature” or “humidity” that could come from the same node id.

Note that from the local client, it is possible to export snapshots of data to snapshot.raintank.io, they contain the selected measurements time window and can be shared for an interactive use case demonstration. An example of export can be found following the link of the image below.

Grafana sensors snapshot