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

how to wake up the device by using threshold

hi ... i am using nRF52832 ,i want to save the battery so i am planning to use system off mode . how to wake up the device from system off mode using threshold value or either system on mode 

is it possible ? how to do 

Thanks in advance

Parents Reply Children
  • ok, so in order to do a comparison in software like you described you need the CPU to be running. Software is running on the CPU. If the CPU is running the chip is by definition not in sleep mode. If you are checking a temperature value in software the chip is already running.

    If you want the chip to sleep and wake up when the sensor reaches a certain temperature level, you have two choices, depending on what type of sensor you have:

    1. Either the temperature sensor itself can be programmed with a threshold-value and it can wake the chip up by asserting a GPIO pin on the chip. This method can wake the chip up either from system OFF mode or system ON mode.

    2. Or, the temperature sensor needs to be periodically polled, and you can check the threshold value in code. This method requires the RTC clock to be running, and the RTC clock will wake the chip up from system ON mode, create an interrupt, and the interrupt will be handled in software. Like this: if(m_sample > threshold). and then go back to sleep

  • Thank you sitan . option 2 is good , i can go with this , actually i tried using timer to interrupt the sleep but i couldn't reach . i don't how to write the flow to interrupt the sleep using timer .. i have succeed upto checking the threshold using timer  .can you help me

  • If you are successful in checking the threshold using timer, there's not really much more to do. The CPU automatically goes to IDLE between the interrupts, as long as there is a __WFE() in the main loop somewhere. Can you post your main function, then I can have a look.

  •  */
    int main(void)
    {
    bool erase_bonds;
    
    
    
        // Initialize.
       
        uart_init();
        log_init();
        timers_init();
    
        ret_code_t err_code =app_timer_create(&m_led_a_timer_id,   APP_TIMER_MODE_REPEATED   ,timer_sensor_event_handler);
    APP_ERROR_CHECK(err_code);
    
        buttons_leds_init(&erase_bonds);
        power_management_init();
        ble_stack_init();
        gap_params_init();
        gatt_init();
        services_init();
        advertising_init();
        conn_params_init();
    
      printf("\r\nUART started.\r\n");
        NRF_LOG_INFO("Debug logging for UART over RTT started.");
    
        advertising_start();
    
        err_code = app_timer_start(m_led_a_timer_id,APP_TIMER_TICKS(60000),NULL);
      APP_ERROR_CHECK(err_code);
     
    
    
         
    
    twi_init();
     MAX30_set_mode();
        // Start execution.
    
    
       
    
            
    
          for(;;)
                 {
    idle_state_handle();
    
          
          }
          }
                  
       
            

Related