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.  

  • Hi

    1. I'm not sure I understand the question here, during initialization there's not much to do except waiting for the devices to initialize and get ready to transmit.

    2. When the device is going to wait for 2.4 seconds I think it would be best to go into IDLE mode during this time with and be in a sleep state "system ON" mode. This is done differently depending on what SDK you're using for development. Are you using the nRF5 SDK or the nRFConnect SDK? It might also be best to stop and uninitialize the I2C peripheral while in sleep mode as well, but you should test this to see what is the best procedure in your specific use case.

    Best regards,

    Simon

  • I have used twi_handler so that device waits to get data on I2C bus in that 2.4s period. How can I put device in idle mode in that 2.4s period? 

  • 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. 

  • Hi

    Will you not be able to run the nrf_pwr_mgmt_run(); whenever the measurement has started, and then wake up when the sensor reports that the measurement is finished and ready to transmit to the nRF?

    Best regards,

    Simon

Related