Used devices

More details about deployment at https://hackaday.io/project/20388-home-smart-mesh/log/169353-sensors-to-services-deployment.

For any question or recommendation, feel free to use the comments section.

Aqara and Eurotronics hand in hand to save energy

and make life more convenient for users. In this home automation section, aqara window contact sensors are used to send a window open alert to the Eurotronic thermostat, once the alert is disabled, the thermostat resumes the previously set temperature.

The Spriit (google "eurotronic thermostat zigbee" ) has the spirit of devices compatibility introducing a zigbee product, which support is added by the zigbee2mqtt community.

In this code section below, multiple windows contacts ("apertures") are aggregated and a notification is sent when the state changes, the full code is available here.

Python Client injects selected MQTT traffic to influxdb

This project has been constatly evolving, from custom RF to zigbee sensors to DIY Thread as depicted below. It is a collection of ideas and sample code and not focusing on a single software or framework.

Thread, OpenThread, nRF52-dongle, firmware Coming soon

The evolution of WPAN (wireless private area network) has led to this moment where the 802.15.4 (already in use by zigbee) joins the ipv6 in the Thread standard managed by the threadgroup. Google, behind Nest provided an open source implementation : openthread.  Nordic has provided a very cheap and convenient nRF52840-dongle supporting all sorts of modern wireless protocols and with a direct usb connection (for bootloader sw update, logging, interfacing), sure you can get the nRF52 dev kit rather for development, but hacking the dongle is more fun and given the size and cost you can have many to test with real networks:

I prepared an OpenThread mind map here, have x5 of those dongle, managed to have the USB running to log the events of the MQTT-SN sample (to be shared soon in github)

Given the beauty of the tools and the framework, released around a raspberry pi border router, I'm glad to lead the next generation of custom low power wireless sensors toward the Thread standard, and they're likely to easily get compatible with other off the shelf future smart home products !

(You can contact me in case you'd like to help in this direction)

zigbee2mqtt 2 influx 2 grafana

Xiaomi over zigbee2mqtt to influx to Grafan Vs nRF52832 custom.
Aqara ib yellow (edgy) over zigbee2mqtt to influx to Grafan Vs nRF52832 custom in green high res.

The high resolution of the nRF52 custom sensor comes from a stunning 30 sec period log (1 min per parameter), that's been running for alomst 6 months already on a CR2032 with a +4dB configuration, so no wonder how long the CR2477 version can last.

All the environemnt and latest Python scripts are under https://github.com/nRFMesh/nRF52_Mesh

The rest of this project description is not yet updated to the new zigbee generation.

Home Smart Mesh Website

Home Smart Mesh with comprehensible structure, menu for different boards, mesh concept,...

Node-red : from Aqara motion button to esp32 RGB Leds

Below, an esp32, like the one visble on the test board, is hidden in the white 3d printed tower. 7 WS2812B have been united for the purpose. An 18650 battery power module like the one visible on the right has been used inside the tower.

Everything becomes easy when iot unite around MQTT to talk the same language. The Aqara motion button has been paired with zigbee2mqtt and picked up directly from there by node-red. I developed an esp32 mqtt application that takes json payloads to turn the grb leds with on and off. The esp32 is developed using the esp-idf, and the source code is available on githubhttps://github.com/HomeSmartMesh/esp32_iot/tree/master/rgb_led

For those not familiar with zigbee2mqtt, the aqara button click produce such publish :

zigbee2mqtt/motion button {"click":"single","battery":"100.00","voltage":3055,"linkquality":92}

 and to turn all leds red by command line (broquer on localhost) :

mosquitto_pub -t 'esp/rgb led/all' -m '{"red":60,"green":0,"blue":0}'

And the rest of the rules can either be handled by node-red as the example above, or by python for a much more flexible rules. Note that direct rules connections as simpler with node-red, but as soon as some logic is needed, then even for beginners python is more readable than node-red. github for python rules example : https://github.com/nRFMesh/nRF52_Mesh/blob/master/raspi/esp32/esp32.py

nRF52 Environemnt description

I split the nRF52 in a separate Hackaday project and github repo as the potential is so huge that it can soon take this Home Smart Mesh to a whole new level

nRF24 + nRF51 + nRF52 Mesh !

Hardware 1 : nRF52 Sensors

Hackaday ProjectnRF52 Sensors
Official websitenRF52 Sensors in Home Smart Mesh
Github reponRF52 Sesnors firmware
Tindie Product pageNot to be deployed

Hardware 2 : nRF51 Sensors

The nRF51 sensors Tag is a low cost (8 ~ 9 €) sensors Tag that can talk Bluetooth and custom radio and equipped with sensors that allow very versatile applications. See further below on why custom radio is way more efficient than Bluetooth in the case of sensors logging.

=> Finally a clean git integration based on the nRFSDK : although most of the projects are based on mbed-os, unfortunately the nRFSDK integration inside mbedos (of the time of the evaluation) only supports usage with softdevices which take control over the HW and only allow bluetooth, not esb custom radio, so I had to fall back over a bare nRFSDK usage and I was surprised how clean the experience was, the support is great (googling issues can be quickly found on the forum), so now a subset of the required sdk is integrated as a submodule in a an SDK based project.

=> Note that current available application on the github repo is only broadcasting x3 axis acceleration, other parameters are still to be added (should be fast forward).

Hardware 3 : nRF51 Beacon

The nRF51 is a market available bluetooth beacon , but I hacked it to turn it into a custom RF Mesh beacon. Main code already on github. I used the nRF SDK with the proprietary_rf examples esb_low_power_ptx. The modified code makes the beacon behave as a dash button talking to all other mesh RF nodes, every press ends up in the database and can feed any python MQTT script (actually every press, and every release are separate logged events). Given the low cost of around $4, this makes it an ideal IoT ally. I program this beacon with a jLink Edu and I designed for it this 3d printed needle adapter

Hardware 4 : STM32 IoT Board

This board issue of the #STM32 Blue pill IoT expansion boards  project, comes with multiple functions

Hardware 5 : STM8L Cell Coin Sensor Tag

Fully open source available on github 

Raspberry pi IoT Software

Grafana Interactive dashboard snapshot

Mesh Protocol

MQTT as a sensors interface for time-series databases

MQTT as a Multi-level interface for Actions

nRF51 Dash button - 3d print your own

More buttons

How to program the nRF51 Button

Is this a mesh ? Sure, with End to End Acknowledge !

We can see two use cases here, a broadcast and a Peer to peer message that is made reliable with Acknowledge and retries. All the details in the nrf24l01 Flood Mesh Protocol log entry.

The Future of the Mesh

Why not Bluetooth ? Waste of battery with either transfer way

Logging sensors data is different than collecting it inside the tag memory and then offloading them to a smartphone. Logging require transmission of the latest sample as soon as it is acquired, so that every user can access to the latest status from a database which is maintained up to date, from those clients are data analysis clients that would take an immediate action if something happens. While with custom radio, you can optimize the wake up sequence with the time spend on tx mode, using Bluetooth brings constrains that compromise communication robustness in an unknown environment over radio power optimization. Two methods are possible :

In addition to the battery waste misconception of bluetooth, its integration comes with some other expenses :

Custom RF vs Bluetooth : Simplicity Vs Complexity

Links to project Logs

The Logs consist of specific use cases based on this IoT_Framework going into some details of firmware and software :

First generation STM8L Sensor Tag