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 github : https://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
It might be me, but it took me quite some effort to get through using node-red for a little bit advanced not too advanced examples, so I show some screenshot for very quick start with node-red.
The input is an mqtt input with the broquer address configuration where mosquitto is running :
I used json node with this config :
Then a switch node that selects which event has happened in the button :
The Flash green example :
Then the mqtt output to the esp topic :
Conclusion
For connecting events to actions, node-red is really a wonderful tool that bring up visibility to your iot network.
When playing with timing already, for generating 300 ms or 500 ms pulses, that's where node-red frontier stops. The ethernet and mosquitto jitter is much higher than such time scales, so ideally for next time, I'll implement a flash function in the esp32 directly and special topic for it so that node-red only need to send one message for flashing and not the start and the end of it.
I wish I could rid of that "to json" box, and maybe use functions in the future, less boxes is always good.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.