I have a battery powered iOT device using BLE, I2C, and GPIO. I am focused on reducing the power consumption. When BLE is not connected, I want to have as little power usage as possible.
1. I advertise at a "slow" interval
#define BT_LE_ADV_CONN_NAME_SLOW BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | \
BT_LE_ADV_OPT_USE_NAME, \
BT_GAP_ADV_SLOW_INT_MIN, \
BT_GAP_ADV_SLOW_INT_MAX, NULL)
2. When BLE is not connected, I power off
device_set_power_state(i2c_dev, DEVICE_PM_OFF_STATE, NULL, NULL);
device_set_power_state(gpio_dev, DEVICE_PM_OFF_STATE, NULL, NULL);
3. When BLE is connected, I go active
device_set_power_state(i2c_dev, DEVICE_PM_ACTIVE_STATE, NULL, NULL);
device_set_power_state(gpio_dev, DEVICE_PM_ACTIVE_STATE, NULL, NULL);
My questions:
1. Are there any other default devices/services I should disable such as UART or console, some logging?
2. I read about power management and tickless idle. I have some questions on tickless idle. When not connected, the device is advertising BLE, and in the main function has a loop and this is the pseudo code:
loop forever {
if connected to BLE {
do some stuff
}
k_break_wait(1000000)
}
I was thinking the main function (main thread) could be suspended until BLE is connected. When BLE is disconnected, the only thread working would be the BLE advertising at 1-1.2 second intervals
Will that help with power management because of tickless idle? If so, how do I suspend and wake the main thread?
3. Is there anything else I could do for power reduction?
4. I have read on the forums people have measured the microamps being used from their devices. What equipment do they use for this? Could someone give an example?