This is the third part of my temperature sensor network series, as explained in Part1. This part describes the network and communication setup.

Connectivity

To create a 802.15.4 border router, I used the RIOT-os border router example with the fifth dongle. There is some configuration that needs te be done: using usb-cdc and setting the correct network parameters. This configuration is included in the project on github (RiotTempsensor)

For this border router to function, the device it is attached to needs to configure some networking things, and needs to run an udhcp daemon. Riot-os contains a handy script to start these things (${RIOTTOOLS}/usb-cdc-ecm/start_network.sh) The project also contains a service definition to let systemd automatically start this script.

Verify the connection by using a node to see if you get an IPV6 prefix. Connect both the border router and a node via usb. Open a shell on the node, and see if you can ping the border router, and the host machine.

COAP to MQTT

As I mentioned before, the goal of this system is to display temperatures in my homeassistant setup. Homeassistant has easy support for sensors publishing over MQTT. Thus we need something that can translate the CoAP messages from the sensor nodes to MQTT. And we will need to distinguish between the different nodes. As all temperature nodes send their measurements to the same endpoint.

Thus I have written Culex. A little python program that bridges CoAP and MQTT.

Culex sets up a CoAP server on the host, and registers the sensor enpoints. For now this is only /temp, but more can be added.

It uses the IPv6 address of the nodes, which should be unique and static, to distinguis between the different nodes. If a node is known, c.q. it has a name, the sensor value is published on MQTT to /culex/{name}/temp.

Unknown nodes are written down in the configuration file, so that you can give them a name.

More information on Culex can be found in the github project (Culex)

The total network setup now looks something like this: Network setup

Reliability

Both the border router and Culex need to be reliable, that is why both projects contain a .service file that can be used to automatically (re)start both services. They have been running for a few weeks now in my own setup, and bar a few connectivity issues, the sensors have been very reliable.

Next, Part4: Casing, will show the casing and the mounting of the sensors.