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

how to wake up from sleep mode

hi.....

i am using nrf52832 ........

i want to wake up my device from sleep mode ... i have used the command for sleep mode sd_app_evt_wait() ...... i dono  what command to give for waking up device from sleep mode 

thanks in advance

suggest me an answer

  •  i have called sd_app_evt_wait() in main loop 

    but it doesn't go to sleep 

    /**@brief Application main function.
     */
    int main(void)
    
    {
        bool erase_bonds;
    
        // Initialize.
        uart_init();
        log_init();
        timers_init();
        buttons_leds_init(&erase_bonds);
        power_management_init();
        ble_stack_init();
        gap_params_init();
        gatt_init();
        services_init();
        advertising_init();
        conn_params_init();
        
    
    
        // Start execution.
        printf("\r\nUART started.\r\n");
        NRF_LOG_INFO("Debug logging for UART over RTT started.");
        advertising_start();
        
        twi_init();
        LM75B_set_mode();
        
          while (true)
        {
            nrf_delay_ms(5000);
    
            do
            {
                __WFE();
            }while (m_xfer_done == false);
          
         
           
            // read_sensor_data();
           //  power_manage();
             threshold_value();
          sd_app_evt_wait();
            NRF_LOG_FLUSH();
        }
        }

    help me 

  • Yes, but I am still not sure what type of interrupt you want. Does the sensor that generate a interrupt signal, so that you just want to wake the nRF up on a pin interrupt? If so you can refer to the Pin Change Interrupt Example.

  •  not using pin interrupt ... when my temperature goes beyond threshold it should wake up automatically 

    see the code here i didn't use sleep mode

    static void threshold_value()
    
    {
       
          m_xfer_done = false;
        uint16_t length1;
        uint16_t threshold;
     
        char str[80];
         threshold= 30;
     if (m_sample < threshold )
    
        {      
     
        length1 = sprintf(str,"%d", m_sample);
      nrf_drv_twi_rx(&m_twi, LM75B_ADDR, &m_sample, sizeof(m_sample));
         ble_nus_data_send(&m_nus,str,sizeof(m_sample), m_conn_handle);
          
      
    }
    }

  • Looking at your code snippets I see there are a number of misunderstandings here:

    • You have to read data via TWI to see if the temperature has crossed the threshold. So clearly the nRF cannot wake on that event, as the only way it can know about it is to wake up regularly and read the sensor.
    • You do a busy wait in your main loop, which waits by spending CPU cycles. This means that your application will spend 5 seconds consuming a lot of power while doing nothing for every iteration of your main loop.
    • The sd_app_evt_wait() call should cause the CPU to sleep for a bit of time, but only until the TWI transaction has finished. All the rest of your waiting happens in the busy wait (sd_app_evt_wait()).

    The proper way to do what you want is to have a main loop which does close to nothing other than calling sd_app_evt_wait(). Then you should use a low power timer (RTC), typically via the timer library to read the sensor at a regular interval.

Related