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

Not able to wake the board from deep sleep(System off)

I am very new to Nordic products so please excuse my ignorance.I have been trying to put my nrf52840 board to deep sleep. It seems to go to sleep but when I try to wake it up by pushing the buttons, it doesn't wake up.

This is how  I modified Ble_app_blinky_c, I added sleep_mode_enter(){}, buttons_leds_init(){}, and bsp_event_handler(bsp_event_t event){} from Ble app template . And then I am calling buttons_leds_init  and sleep_mode_enter in Main.c.Basically I want the board to be in deep sleep at all times and wake up only when I push the buttons.

I have included my project below.

What I am doing wrong?

Thank you in advanceble_app_blinky_c.zip

  • Hi David

    First of all, by setting sleep_mode_enter() function before the init functions causes a fatal error, and the chip to just reset over and over. Next, by setting the sleep_mode_enter() function in the main loop will cause the application to go to sleep every time it wakes up, as it resets when it wakes up, and starts the main loop from the beginning, causing the device to never be able to scan.

    The ble_app_blinky_c example kind of already implements what you're looking for, as it starts out with scanning, then goes to sleep when you press button 1 (see bsp_event_handler), and it only wakes up by either pressing the reset button or button 2 which is set to wake it up.

    Best regards,

    Simon

  • Hi Simonr

    Thank you for the response. The ble_app_blinky_c  example doesn't seem to have that implementation, the bsp_event_handler is something that I added to the app in an attempt to put it to sleep. Also, I removed sleep_mode_enter() out of main loop, and put it inside button_event_handler() after a button is pressed (basically when the button is pressed, it transmit the data and after the transmission is successful it goes back to sleep) but still that didn't work.

    I have also tried to do like how they are doing in Ble app template example, but that didn't help (that's where I took  bsp_event_handler).

  • Hi David

    So you want it to go to deep sleep by itself after the application has scanned/received for some time? In that case, you should set the SCAN_DURATION to however long you want it to scan before the device goes to sleep, as well as setting the SUPERVISION_TIMEOUT to however long you'd like a connection to be inactive before the central disconnects and goes to sleep.

    Or is the issue that you're not able to get the device into deep sleep mode at all? Because on my end, after just a few tweaks to your code, the application now goes to sleep if I press button 1 on the DK, and wakes up by a press of any button.

    Best regards,

    Simon

  • Hi Simon

    Yes, I want it to go to sleep by itself but after it had sent the data to the connected peer device. That is why I tried to put sleep_mode_enter() in  button_event_handler after ble_lbs_led_status_send() (which didn't work).

    Correct me if I am wrong, my understanding is setting SCAN_DURATION to a certain time, if it gets connected before expiration time it will never go to sleep.

    In other words what I want is  the central to always be in deep sleep. When you push button 1 or button 2 the device should wake up, send data to the connected peer device and then go back to sleep.

  • Hi

    Yes, I just mentioned SCAN_DURATION if it is relevant to you that if the device isn't able to connect to another one in a given amount of time, it might want to go back to sleep.

    SUPERVISION_TIMEOUT however, should be able to disconnect you from an inactive connection so you can go to sleep upon disconnection from the peripheral. Remember that when you go to deep sleep (System OFF) mode, the wake-up call will trigger a reset, which is why you can't start the main loop by going to sleep. If you want it to do something when it wakes up, you'll have to add that before going to sleep.

    Best regards,

    Simon

Related