This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Putting the device in low power mode

I am developing code for nrf52832 to read data from a connected sensor on I2C. There are two scenarios I am trying to save power: 

1- During the initial power up, I have to enable the sensor (nrf52832 asserts sensor EN pin) and then wait 50ms for it to warm up and initialize itself. 

2- During reading sensor data, I have to send measurement command on I2C, and then wait ~2.4 seconds for sensor to assert nRDY pin. Then nrf52832 collects data from the bus. 

What is the best practice to save power during these wait periods. How can I sleep the device when it is waiting for the sensor instead of using nrf_delay_ms() to wait 50ms in the first scenario and 2.4s in second scenario.  

Parents
  • Hi again

    Yes, I think you can do something like that. I take it you use the nRF5 SDK based on your code snippet. If so I would suggest using the idle_state_handle() function that we use in multiple of our applications to go to sleep. This function makes sure there are no pending logs before preparing the device for sleep and waiting for an event to minimize current consumption.

    /**@brief Function for handling the idle state (main loop).
     *
     * @details If there is no pending log operation, then sleep until next the next event occurs.
     */
    static void idle_state_handle(void)
    {
        if (NRF_LOG_PROCESS() == false)
        {
            nrf_pwr_mgmt_run();
        }
    }
    

    Best regards,

    Simon

  • Thanks Simon. 

    I have used low power RTC2 to generate an interrupt every 10 seconds to initiate a measurement. 

    In the body of my main, I just have as you mentioned:

    while (true)

    { nrf_pwr_mgmt_run(); }

    This will help me to save power everytime I am not doing any measurements. 

    but still when there is an ongoing measurement, I am using nrf_delay_ms(2400) waiting for the sensor to finish the measurement. Should I use RTC1 for this purpose to generate another interrupt? Is there any other solution because I am using RTC1 for other purposes. 

    Please advise. 

Reply
  • Thanks Simon. 

    I have used low power RTC2 to generate an interrupt every 10 seconds to initiate a measurement. 

    In the body of my main, I just have as you mentioned:

    while (true)

    { nrf_pwr_mgmt_run(); }

    This will help me to save power everytime I am not doing any measurements. 

    but still when there is an ongoing measurement, I am using nrf_delay_ms(2400) waiting for the sensor to finish the measurement. Should I use RTC1 for this purpose to generate another interrupt? Is there any other solution because I am using RTC1 for other purposes. 

    Please advise. 

Children
No Data
Related