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

send ESB massage before sleep

Hello,

My board reads data from acceleration sensor and sends it to ESB message.

When acceleration is under threshold, nRF52832 went sleep mode.

Before entering sleep mode, I want to send a ESB message which notify nRF52832 is in sleep mode.

But It doesn't work as I expected. Time to time, sleep message is sent. But most of time sleep message isn't sent.

I tried "nrf_esb_flush_tx" and "nrf_esb_is_idle". But It still not work.

How could I sure that sleep message is sent before entering sleep mode?

 

Before sleep_mode_enter, sleep message is sent(battery 0 percent).

static void stopSensor(void *p_data, uint16_t p_size)
{
    uint8_t batteryPercent;
    bool esbState;

    tx_payload.length = NRF_ESB_PAYLOAD_LENGTH;
    tx_payload.noack = false;
    /* device id */
    tx_payload.pipe = NRF_ESB_PIPE_ID;
    
    memcpy(tx_payload.data,&seqData,sizeof(uint32_t));

    batteryPercent = 0;
    memcpy(tx_payload.data+sizeof(uint32_t)+TOTAL_DATA_BYTE_IN_FRAME, &batteryPercent, sizeof(uint8_t));
    
    nrf_esb_flush_tx();

    if (nrf_esb_write_payload(&tx_payload) == NRF_SUCCESS)
    {
        seqData++;
    }
    else
    {
        NRF_LOG_INFO("Sending packet failed\n\r");
    }
    
    do{
        esbState = nrf_esb_is_idle();
    }while(!esbState);

    nrf_gpio_pin_write(PIN_LED3_ON,0);

    /* Disable sensor. */
    lis3mdl_operating_mode_set(&lis_ctx, LIS3MDL_POWER_DOWN);

    sleep_mode_enter();
}

bat:0 isn't received well.

Parents
  • Hi 

    It should be sufficient to wait for the ESB callback to be triggered, telling you whether or not the TX packet was successfully sent, or if you got a TX failure. 

    Do you have the callback set up in your code?

    Also, it should be possible to go to __WFE() sleep while the ESB library is busy, in order to put the CPU to sleep and reduce the power consumption. Whenever the ESB library needs to do some processing the CPU will wakeup automatically. 

    Best regards
    Torbjørn

Reply
  • Hi 

    It should be sufficient to wait for the ESB callback to be triggered, telling you whether or not the TX packet was successfully sent, or if you got a TX failure. 

    Do you have the callback set up in your code?

    Also, it should be possible to go to __WFE() sleep while the ESB library is busy, in order to put the CPU to sleep and reduce the power consumption. Whenever the ESB library needs to do some processing the CPU will wakeup automatically. 

    Best regards
    Torbjørn

Children
No Data
Related