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

nrf52832 sleep mode from android app

I am currently looking at how to put the nrf52 development board to sleep (and wake up) by sending a command from an android application (with SDK v15.2).

I have been experimenting with the nrfBlinky app and wanted to know if anyone has some advice on how one would go about doing this.

I have searched the forums but couldn't find a similar question although there are posts about calling __WFE() to put the board in low power mode from the firmware (or calling an event like sd_app_evt_wait()). I did read there are two sleep mode for this board a SYSTEM ON and SYSTEM OFF mode. I am not certain which mode suits the use case best, although I assume we would want the SYSTEM ON mode as the app would need to send an event to wake it up. Although I wouldn't be against a SYSTEM OFF mode where the reset button would need to be pressed to wake it up (so just sending a "put to sleep" command from the app). 

Any advice would be much appreciated.

Parents
  • Have you taken a look at the examples in SDK 15.2? In most of the examples, the chip is in System ON sleep mode most of the time. The way it is done is by putting the sleep function in a for loop (as Ashish mentioned). Most of the functionality related to the nRF52 chip is event driven, and is perfectly compatible with this approach.

    E.g, in the SAADC example, the chip is put to System ON sleep in a while(1) loop through the function nrf_pwr_mgmt_run(), then if  ADC data is received, the chip breaks the sleeps mode, handles the ADC event, then continues on the line after nrf_pwr_mgmt_run(). Since the function is inside a while loop, it will loop around and go to sleep once again.  The BLE examples are also event driven, and works in the same manner as the ADC example. 

    This approach only works for System ON sleep mode, and event driven activity.

    However, please tell me if you are aware of this and have a reason for invoking sleep mode yourself. If you could explain your project in more details, I would be able to give you a more constructive answer.

    Best regards,

    Simon

  • Thank you for the reply Simon.

    So I am aware of the SDK samples, probably didn't fully understand what they were doing, so thank you (and Ashish) for clarifying.

    For the project that I am working on, I would like to send a sleep command to the BLE board from an Android device (untethered so not through uart), similar to the Blinky app where you press a switch control to turn a light on the board. I was unsure the correct steps to follow to simulate this event and how one would get the board to go to sleep.

    1. So for now what I would like to do is to create an LED type event structure for an Android app (e.g. sleep button) that could put the board into sleep mode (System OFF), essentially turn it off where a person would have to press the reset button on the board to wake it up (how do you put the board into System OFF sleep?).

    2. Then as a later goal to implement the System ON mode where an event from the Android app could put the board to sleep and then another event (say turning a switch control on/off) to wake it up.

    Any ideas?

  • Have you taken a look at the nrf_pwr_mgmt example? That might give you a better understanding of the System OFF sleep mode.

  • Try changing NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF  with NRF_PWR_MGMT_SHUTDOWN_STAY_IN_SYSOFF.

  • Thanks, figured it out, used the pwr_mgmt_example added the shutdown_handler event and set the priority, then as you indicated called ..STAY_IN_SYSOFF. I checked the events by using the serial port to the dev board and outputting to PuTTY to see what was happening. 

  • I am happy to hear you figured it out! Please ask if you encounter any more problems.

Reply Children
No Data
Related