Install

For an overview of the Raspberry pi software have a look at the top page Raspberry pi.

In this guide, you’ll find a step by step guide to install the following software. It has been tested on a raspberry pi 3 raspbian “stretch”.

Software Type Function Required
uucp tool Serial Port Logger Troubleshooting
Mosquitto service MQTT Broquer Yes
InfluxDB service Time Series Database Yes
Grafana service Sensors Data Dashboard Yes
HSM Scripts scripts serial port to mqtt to database clients Yes

Serial Port Tool

What is UUCP

sudo apt-get install uucp

Test the RF Dongle

The nRF52 Dongle firmware UART is configured to 460800 Kbps

cu -l /dev/ttyUSB0 -s 460800

If you have Nodes running on the Mesh, such output log should be visible:

pi@touchpi:~ $ cu -l /dev/ttyUSB0 -s 460800
Connected.
pid:19;ctrl:0x82;src:45;accx:0.050;accy:0.012;accz:0.916
pid:7;ctrl:0x82;src:91;light:29.700
pid:19;ctrl:0x82;src:64;accx:-0.001;accy:0.044;accz:0.864
pid:7;ctrl:0x82;src:78;light:8017.920
pid:10;ctrl:0x82;src:91;temp:27.98;hum:42.185;press:978.18
pid:10;ctrl:0x82;src:78;temp:31.47;hum:32.211;press:979.11

it is possible to stop the serial port log by entering

~. (then press return)

 


Mosquitto with websockets

reference from smoothfit on github

Dependencies

sudo apt-get update
sudo apt-get install build-essential python quilt python-setuptools python3
sudo apt-get install libssl-dev
sudo apt-get install cmake
sudo apt-get install libc-ares-dev
sudo apt-get install uuid-dev
sudo apt-get install daemon
sudo apt-get install libwebsockets-dev

Mosquitto 1.4.10

make sure you install the same version as supported by the distribution so that other tools can interact with it such as mosquitto_sub

cd Downloads/
wget http://mosquitto.org/files/source/mosquitto-1.4.10.tar.gz
tar zxvf mosquitto-1.4.10.tar.gz
cd mosquitto-1.4.10/
sudo nano config.mk

Edit this line in config.mk to

WITH_WEBSOCKETS:=yes

Then install

make
sudo make install
sudo cp mosquitto.conf /etc/mosquitto
sudo nano /etc/mosquitto/mosquitto.conf

Add this content to mosquitto.conf

port 1883
listener 1884
protocol websockets

If required debug and dev tools, note that ‘libmosquitto-dev’ is important for troubleshooting

sudo apt-get install libmosquitto-dev

Add moquitto user

sudo adduser mosquitto

 


Grafana

Make sure the linux version is matching by checking it with “cat /etc/osrelease” here “stretch

sudo apt-get install apt-transport-https curl
curl https://bintray.com/user/downloadSubjectPublicKey?username=bintray | sudo apt-key add -
echo "deb https://dl.bintray.com/fg2it/deb stretch main" | sudo tee -a /etc/apt/sources.list.d/grafana.list

sudo apt-get update
sudo apt-get install grafana
systemctl daemon-reload

Edit “/etc/grafana/grafana.ini” if required

### Anonymous Auth ###
[auth.anonymous]
enabled = true

InfluxDB

This is an install collector, for better influx install see official website.

Check linux version with “cat /etc/osrelease” here it is updating for “stretch

sudo apt install apt-transport-https
echo "deb https://repos.influxdata.com/debian stretch stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt-get update && sudo apt-get install influxdb

Start the database and create a new table for HomeSmartMesh use case

sudo systemctl start influxdb

influx -precision rfc3339

>CREATE DATABASE meshNodes

Issue : if influx command is not found, make sure it is installed try the install again.


nRF52 HomeSmartMesh scripts

Dependencies

Here is a detailed one by one optional install, see HSM Scripts section for one liner.

The MQTT Python client

sudo pip install paho-mqtt

The influxDB Python client

sudo pip install influxdb

Milight Python client (Optional)

sudo pip install milight

Wemo smart sockets Python client (Optional)

sudo pip install git+https://github.com/iancmcc/ouimeaux.git

HSM Scripts

cd ~
git clone https://github.com/nRFMesh/nRF52_Mesh.git
sudo pip install -r nRF52_Mesh/raspi/requirements.txt

Note that the “sudo” for the python requirements install is needed as it is expected to start the scripts from the /etc/rc.local which by default starts them as a root. It is also possible to change that script to run them as another user. But if experimenting with both sudo and normal user is required then another install of these requirements should be performed

pip install -r nRF52_Mesh/raspi/requirements.txt

Then make sure the “raspi_run.sh” script is run on startup by editing the “rc.local” for example

sudo nano /etc/rc.local

and add the following before “exit 0”

export NODES_CONFIG=/home/pi/nRF52_Mesh/raspi/mesh_wizard/nodes.json
cd /home/pi/nRF52_Mesh/raspi
./raspi_run.sh &

If something goes wrong, it is possible to debug the output log of scripts run on startup by adding a log file location, so that the complete file ends up as follows

exec 2> /home/pi/share/rc.local.log      # send stderr from rc.local to a log file
exec 1>&2                      # send stdout to the same log file
set -x                         # tell sh to display commands before execution

export NODES_CONFIG=/home/pi/nRF52_Mesh/raspi/mesh_wizard/nodes.json
cd /home/pi/nRF52_Mesh/raspi
./raspi_run.sh &

exit 0

then reboot to make sure everything gets newly started

Log

make sure to either create a “/home/pi/share/” folder or update the log path of every script

mkdir ~/share

 


Troubleshooting

Verifying that everything is running

Check that services are running

sudo systemctl status influxdb
sudo systemctl status grafana-server

If any of the services is not active make sure it is enabled with

sudo systemctl enable influxdb

Then Check that the broker and the scripts are running

ps aux | grep mosquitto
ps aux | grep mesh_controller
ps aux | grep influx_client
ps aux | grep ruler
ps aux | grep wemo_client
ps aux | grep milight_gateway

Have a look at the MQTT broadcasts

mosquitto_sub -t 'Nodes/#' -t 'jNodes/#' -v

The log should look similar to this

pi@rfserv:~ $ mosquitto_sub -t 'Nodes/#' -t 'jNodes/#' -v
Nodes/76/light 121.68
jNodes/64/acceleration {"y": 0.046, "x": -0.005, "z": 0.861}
jNodes/64/acceleration {"y": 0.046, "x": -0.005, "z": 0.861}
Nodes/37/power 1.025
Nodes/40/power 115.15
Nodes/82/light 262.079
Nodes/77/pressure 977.95
Nodes/77/humidity 45.948
Nodes/77/temperature 26.63

Finally, make sure the data is reaching the database

pi@rfserv:~ $ influx
> use meshNodes
> SHOW FIELD KEYS FROM "node82"
> SELECT "temperature" FROM "node82" WHERE time > now() - 10m

The complete input and output

pi@rfserv:~ $ influx
Connected to http://localhost:8086 version 1.4.2
InfluxDB shell version: 1.4.2
> use meshNodes
Using database meshNodes
> SHOW FIELD KEYS FROM "node82"
name: node82
fieldKey    fieldType
--------    ---------
alive       float
battery     float
humidity    float
light       float
pressure    float
reset       float
temperature float
> SELECT "temperature" FROM "node82" WHERE time > now() - 10m
name: node82
time                temperature
----                -----------
1530347660705070080 23.9
1530347721300134912 23.9
1530347721401367040 23.9
1530347780449580032 23.91
1530347840958992128 23.91
1530347900814477056 23.92
1530347961212564992 23.93
1530348021246364160 23.93
1530348141116084992 23.96
1530348200962253056 23.95
>

Issues

mosquitto_sub error

pi@touchpi:~ $ mosquitto_sub -t 'Nodes/#' -t 'jNodes/#' -v
mosquitto_sub: /usr/lib/arm-linux-gnueabihf/libmosquitto.so.1: version `MOSQ_1.5' not found (required by mosquitto_sub)

uninstall older versions of mosquitto before installing mosquitto-dev see stack-overflow

cannot view webgl on raspberry pi output

In case of no webgl rendering visible, Chromium had an issue at the time of this guide, test with firefox (not yet much of a success).