# \[Discourse\] Immediately detect BLE module wake

**URL:** <https://discourse.nodered.org/t/discourse-immediately-detect-ble-module-wake/28188>\
**Category:** General\
**Created:** [11 June 2020 16:26 UTC](https://discourse.nodered.org/t/discourse-immediately-detect-ble-module-wake/28188 "2020-06-11T16:26:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adamhun94](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@adamhun94](https://discourse.nodered.org/u/adamhun94)\
**Post date:** [11 June 2020 16:26 UTC](https://discourse.nodered.org/t/discourse-immediately-detect-ble-module-wake/28188/1 "2020-06-11T16:26:25Z")

</div>

_ **Description** _  
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.

_ **Improvements** _  
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!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [10 August 2020 16:26 UTC](https://discourse.nodered.org/t/discourse-immediately-detect-ble-module-wake/28188/2 "2020-08-10T16:26:29Z")

</div>

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