I’ve created another improvement and video which might help you conserve battery life.
First I’ve set node to sleep with 500ms receive timeout
bc_radio_init(BC_RADIO_MODE_NODE_SLEEPING);
bc_radio_set_rx_timeout_for_sleeping_node(500);
Then to wake-up the module I need to send beacon every 10 seconds, so I’ve added this periodic function (application_task
is called internally, no need to call it from anywhere)
void application_task()
{
bool parameter = true;
bc_radio_pub_bool("update_request", ¶meter);
// increase when more nodes will be connected!
bc_scheduler_plan_current_relative(10000);
}
Then I’ve created this flow which will be triggered by MQTT message update_request
, then the message is created with latest orderID and immediatelly send to the node until the 500ms receive timeout window closes.
Import to node-red
[{"id":"c49c9358.c5d8f","type":"inject","z":"2c41a2bd.aa36ae","name":"","topic":"node/bcf-qr-code:0/blokko/order/qr/0","payload":"\"000\"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":350,"y":180,"wires":[["4b14d3ab.83af1c"]]},{"id":"9eb8c94d.85d638","type":"mqtt out","z":"2c41a2bd.aa36ae","name":"","topic":"node/bcf-qr-code:0/blokko/order/qr/0","qos":"","retain":"","broker":"29fba84a.b2af58","x":910,"y":360,"wires":[]},{"id":"2b238f66.d486e","type":"inject","z":"2c41a2bd.aa36ae","name":"","topic":"node/bcf-qr-code:0/blokko/order/qr/0","payload":"\"123\"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":350,"y":220,"wires":[["4b14d3ab.83af1c"]]},{"id":"a8ad18d8.04a868","type":"mqtt in","z":"2c41a2bd.aa36ae","name":"","topic":"node/bcf-qr-code:0/update_request","qos":"2","datatype":"auto","broker":"29fba84a.b2af58","x":300,"y":360,"wires":[["2d61e655.003d1a"]]},{"id":"4b14d3ab.83af1c","type":"change","z":"2c41a2bd.aa36ae","name":"","rules":[{"t":"set","p":"orderId","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":200,"wires":[[]]},{"id":"2d61e655.003d1a","type":"change","z":"2c41a2bd.aa36ae","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"orderId","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":360,"wires":[["9eb8c94d.85d638"]]},{"id":"e6748dc.13b8a7","type":"mqtt in","z":"2c41a2bd.aa36ae","name":"","topic":"node/bcf-qr-code:0/battery/-/voltage","qos":"2","datatype":"auto","broker":"29fba84a.b2af58","x":300,"y":440,"wires":[[]]},{"id":"29fba84a.b2af58","type":"mqtt-broker","z":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]
I’ve also noticed that after node-red Deploy I always see messages node/bcf-qr-code:0/blokko/order/qr/0
. Not sure why they are started to appear after I imported your flow. It could be maybe because he messages were “retained”. You don’t need retained messages in case you was using them.