[Discourse] Immediately detect BLE module wake

My ultimate plan is to create a coin cell battery powered BT switch (push button) which sends data for my RPi. For that purpose I have bought a nrf52832 based BLE module and successfully programmed it. Since I would like to make it work from a coin cell, the module is in sleep mode almost all the time, and I can wake it via a hardware interrupt (push button). My biggest problem is how to immediately detect the wake of the BLE module or how to receive a message from the module instantaneously on the Pi?

What did I achieve so far?
Currently when I power up my module, it starts to advertise itself. In this state I can connect to it with a node-red-contrib-generic-ble node. If the Pi connects to the module, it goes to sleep mode. Then if I press the push button, it wakes up and waits for a bit (1 sec) before going back to deep sleep. Meanwhile with an Inject node I start to read data from a sample characteristic every 0.5 seconds. This is the "presence detection" part. If the module is on, I can read a simple "1" value from the characteristic, otherwise I get a timeout ("Nothing to read") message from the generic-ble node because it cannot connect to it (obviously). The "1" value is an example of distinguish a separate second button later, which will set a "2" value or so, if it is pushed.

Basically this solution works, but I don't feel this continuous pinging is the correct way of doing this (and getting 2 warning logs every second). Maybe somehow notify the Pi if the module is on? I need immediately detection (<1sec) and I don't want a simple presence detection, but also reading a characteristic (or other variable) value e.g. if I want to distinct two or more buttons. Although I achieved this in Node-red, I'm open to other tools as well.

Have you got any ideas for a solution?
Thank you for your help!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.