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

Parents
  • Okay, thank you for clarifying! Then I guess you want to disconnect (using sd_ble_gap_disconnect) after the data has been transferred, so call the disconnect when the data has been received by the peripheral and then go to sleep after you've disconnected.

    As for the data being sent depending on what button you push, I don't think you can set this with the same button push you wake up the device with. So I think you either have to press the button twice, once for wake-up and once for what data you are to send or holding the button and set an "if BTN1 is held, send data 1" after the device has woken up.

    Best regards,

    Simon

Reply
  • Okay, thank you for clarifying! Then I guess you want to disconnect (using sd_ble_gap_disconnect) after the data has been transferred, so call the disconnect when the data has been received by the peripheral and then go to sleep after you've disconnected.

    As for the data being sent depending on what button you push, I don't think you can set this with the same button push you wake up the device with. So I think you either have to press the button twice, once for wake-up and once for what data you are to send or holding the button and set an "if BTN1 is held, send data 1" after the device has woken up.

    Best regards,

    Simon

Children
  • Thank you Simon.

    I have been trying to play with code a bit, now my challenge is getting connection_handle instance in button_event_handler.I am trying to the board to sleep after the data has been successfully sent, but we don't have access to the conn_handle in order to disconnect in button_event_handler. See code below

    case LEDBUTTON_BUTTON_PIN:
                err_code = ble_lbs_led_status_send(&m_ble_lbs_c, button_action);
                if (err_code != NRF_SUCCESS &&
                    err_code != BLE_ERROR_INVALID_CONN_HANDLE &&
                    err_code != NRF_ERROR_INVALID_STATE)
                {
                    APP_ERROR_CHECK(err_code);
                }
                if (err_code == NRF_SUCCESS)
                {
                    NRF_LOG_INFO("LBS write LED state %d", button_action);
                    //sd_ble_gap_disconnect(conn_handle,BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION); 
                    sleep_mode_enter();
                }
                break;

Related