This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to poll data from sensor using an android app nrf52 nordic

I am developing on the nRF52 boards with a capacitive sensor. I followed the tutorial in this link and created a custom service with 3 read characteristics. I am able to use the nordic connect app to read the values in those 3 characteristics continuously. I am also able to modify the nrf uart app to read those values and print it out on the phone continuously when I connect to the nrf52.

However, what I want to do now is polling data from the nrf52 when I press a button on the android app. For example, my nrf52 will be in sleep mode, then when I connect it to the phone and pressed a button, then the nrf52 will wake up and send some data over to the phone for a few seconds then nrf52 goes back to sleep again.

I'm having trouble on how to set up my application so that it will only send data when I press a button. Any suggestion on how to implement this would be appreciated it.

Thank you

Parents
  • What do you call "sleep" and what do you mean by wake-up? If you are fine with standard operation of nRF5x (= it runs some scheduled operation by RTC timer - either in BLE stack or in your app - and otherwise it sleeps) then simply keep it advertising, once you want to connect from phone you can do so, as soon as connection link is established you can directly start your procedure with capacitive sensor (or whatever else) and as soon as you have any data then nRF5x sends them immediately to the phone as GATT Notify or Indicate, no need to pulling it out of nRF5x by reads (basically no one is doing it because there is no reason). If you want to do it differently (= read instead of notify) then you certainly can. Maybe can you formulate shorter and technically clearer question(s) so someone will be able to answer them?:)

Reply
  • What do you call "sleep" and what do you mean by wake-up? If you are fine with standard operation of nRF5x (= it runs some scheduled operation by RTC timer - either in BLE stack or in your app - and otherwise it sleeps) then simply keep it advertising, once you want to connect from phone you can do so, as soon as connection link is established you can directly start your procedure with capacitive sensor (or whatever else) and as soon as you have any data then nRF5x sends them immediately to the phone as GATT Notify or Indicate, no need to pulling it out of nRF5x by reads (basically no one is doing it because there is no reason). If you want to do it differently (= read instead of notify) then you certainly can. Maybe can you formulate shorter and technically clearer question(s) so someone will be able to answer them?:)

Children
No Data
Related