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

Power consumption custom board, BLE

Hi all, I'm developing a project based on nrf52832 and a custom board, what I want to know is if it's correct the actual power consumption.

The custom board has the following sensors:

Accelerometer gyroscope and magnetometer (BMX055 from Bosch: datasheet) Ultraviolet sensor (SI1133 datasheet ) Gas gauge / battery monitor datasheet

We are using I2C and SPI communications, all sensors are set in low power mode or deep suspend mode, because we are not using them righ now.

The custom board has a buzzer connected and two leds, and it is connect to a mobile phone by BLE.

We are using the softdevice s132 with the SDK v13.

Right now, we have 2.3mA when it's connected by BLE, and with the buzzer and leds turned off, when a led is turned on, the consumption is 3.8mA more or less.

Is it a normal power consumption? Or it could be lower than what we have right now?

I attach the main code to make easier any help.

#include <stdint.h>
#include <string.h>
#include "nordic_common.h"
#include "nrf.h"
#include "ble_hci.h"
#include "ble_advdata.h"
#include "ble_advertising.h"
#include "ble_conn_params.h"
#include "softdevice_handler.h"
#include "nrf_drv_twi.h"
#include "nrf_ble_gatt.h"
#include "nrf_drv_rtc.h"
#include "nrf_drv_clock.h"
#include "nrf_delay.h"
#include "bmx055.h"
#include "boards.h"
#include "app_timer.h"
#include "ble_nus.h"
#include "app_uart.h"
#include "app_util_platform.h"
#include "bsp.h"
#include "Configuration_Muvone.h"
#include "Flash_memory_library.h"
#include "si1133.h"
#include "STC3115.h"
#include "stc3115_I2C.h"
#include "stc3115_Driver.h"

const uint32_t UICR_ADDR_0x20C __attribute__((at(0x1000120C))) __attribute__((used)) = 0xFFFFFFFE;			/**<Value to configure non volatile memory for use port 10 as gpio. */

/**************Variables to make slots*************************************/ 
uint8_t i_variable;
extern uint8_t Impact_lsb;																																							 
extern uint8_t Impact_msb;
extern uint8_t Steps_lsb;
extern uint8_t Steps_msb;
extern uint8_t UV_sensor_lsb;
extern uint8_t UV_sensor_msb;
extern uint8_t Impact_lsb_ant;
extern uint8_t Steps_lsb_ant;
extern uint8_t slot_lsb;
extern uint8_t slot_lsb_ant;
extern uint8_t slot[8];																								 																		
uint8_t time_slot[8];
uint8_t Date[13];
uint8_t Date_ant[13];
uint8_t Sync_flag[8];
int j,Longitud,m,x;
uint8_t First_slot[17];
/***************************************************************************/

/***************Variables mainly for accelerometer***************************************************/
extern double Impact_vector;
extern uint16_t x_axis;
extern uint16_t y_axis;
extern uint16_t z_axis;
extern uint8_t x_axis_lsb;
extern uint8_t x_axis_msb;
extern uint8_t y_axis_lsb;
extern uint8_t y_axis_msb;
extern uint8_t z_axis_lsb;
extern uint8_t z_axis_msb;
extern double accData[3];
extern double offset_x_axis;
extern double offset_y_axis;
extern double offset_z_axis;
uint32_t slot_n_32;
extern float lectura_2;
extern float lectura;
extern float Send_seconds;
extern uint8_t readedData[12];
extern uint8_t Slot_to_send[13];
uint8_t first_time_saving_date=0;
/*****************************************************************************************************/

/**Variable for the battery.***************************************************************/
uint8_t battery_percent;
uint8_t battery_level;
/******************************************************************************************/

/*************Flags for synchronising******************************/
bool flag_real_time=false;	
bool oldest_slot_date=true;
bool flag_connected=false;
bool flag_disconnected=false;
bool flag_received_alert_fast=false;
bool flag_received_alert_slow=false;
bool flag_received_red_on=false;
bool flag_received_red_off=false;
bool flag_received_green_on=false;
bool flag_received_green_off=false;
bool flag_send_mac=false;
bool flag_received_A=false;
bool flag_sent_A=false;
bool flag_send_first_slot=false;
bool flag_low_battery=false;
bool synchronized =false;
bool flag_send_slots=false;
bool flag_start_send_slots_form_app=false;
bool flag_start_real_time_from_app=false;
bool disconnected_mode_available=false;
bool flag_first_sync_slot=false;
extern bool Accelerometer_available;
extern bool Timer_accepted;
extern bool flag_save_slot;
bool flag_send_battery_level = false;
/*******************************************************************/

/**************Variables for battery monitor*******************************************/
STC3115_ConfigData_TypeDef STC3115_ConfigData;
STC3115_BatteryData_TypeDef STC3115_BatteryData;
/**************************************************************************************/

/**************Addresses***********************************************/
extern uint8_t Address[3];
extern uint8_t Address_for_reading[3];
uint8_t n_slots_Address[3]={0x10,0x00,0x00};
uint8_t Address_for_saving_date[3]={0x20,0x00,0x00};
uint8_t Address_for_sync_counter[3]={0x30,0x00,0x00};
/**********************************************************************/

/***********Auxiliar variables****************************************/
extern float Send_minutes;
extern float Send_seconds;
/*********************************************************************/

/*Function for the twi connection instance.****************/
extern const nrf_drv_twi_t m_twi;
/**********************************************************/

void gatt_evt_handler(nrf_ble_gatt_t * p_gatt, const nrf_ble_gatt_evt_t * p_evt)
{
    if ((m_conn_handle == p_evt->conn_handle) && (p_evt->evt_id == NRF_BLE_GATT_EVT_ATT_MTU_UPDATED))
    {
        m_ble_nus_max_data_len = p_evt->params.att_mtu_effective - OPCODE_LENGTH - HANDLE_LENGTH;
    }
}
void gatt_init(void)
{		
    ret_code_t err_code;

    err_code = nrf_ble_gatt_init(&m_gatt, gatt_evt_handler);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_ble_gatt_att_mtu_periph_set(&m_gatt, 64);
    APP_ERROR_CHECK(err_code);
}
static void gap_params_init(void)
{
    uint32_t                err_code;
    ble_gap_conn_params_t   gap_conn_params;
    ble_gap_conn_sec_mode_t sec_mode;

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);

    err_code = sd_ble_gap_device_name_set(&sec_mode, (const uint8_t *) DEVICE_NAME,  strlen(DEVICE_NAME));
    APP_ERROR_CHECK(err_code);

    memset(&gap_conn_params, 0, sizeof(gap_conn_params));

    gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
    gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
    gap_conn_params.slave_latency     = SLAVE_LATENCY;
    gap_conn_params.conn_sup_timeout  = CONN_SUP_TIMEOUT;

    err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
    APP_ERROR_CHECK(err_code);
}
void Save_number_of_slot_in_flash(void){
	EraseSectorSpiMemory(n_slots_Address);
	
	uint8_t slot_number_vector[8]={slot[0],slot[1],0,0,0,0,0,0};	
	
	SendDataToFlash(n_slots_Address,slot_number_vector);
}
static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)
{
    uint32_t err_code;

    for (uint32_t i = 0; i < length; i++)
    {
        do
        {
											
				/*Flag for the buzzer*/
				if (p_data[0]==0x67){
					flag_received_alert_slow=true;
				}
					
				if (p_data[0]==0x61){
					flag_received_alert_fast=true;
				}
				
				if (p_data[0]==0x62){
					flag_received_red_on=true;
				}
				
				if (p_data[0]==0x63){
					flag_received_red_off=true;
				}
				
				if (p_data[0]==0x64){
					flag_received_green_on=true;
				}
				
				if (p_data[0]==0x65){
					flag_received_green_off=true;
				}
				
				if (p_data[0]==0x66){
					flag_send_battery_level=true;
				}

				
				
        } while (err_code == NRF_ERROR_BUSY);
	   }

}
static void services_init(void)
{
    uint32_t       err_code;
    ble_nus_init_t nus_init;

    memset(&nus_init, 0, sizeof(nus_init));
	
		nus_init.data_handler = nus_data_handler;

    err_code = ble_nus_init(&m_nus, &nus_init);
    APP_ERROR_CHECK(err_code);
}
static void on_conn_params_evt(ble_conn_params_evt_t * p_evt)
{
    uint32_t err_code;

    if (p_evt->evt_type == BLE_CONN_PARAMS_EVT_FAILED)
    {
        err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE);
        APP_ERROR_CHECK(err_code);
    }
}
static void conn_params_init(void)
{
    uint32_t               err_code;
    ble_conn_params_init_t cp_init;

    memset(&cp_init, 0, sizeof(cp_init));

    cp_init.p_conn_params                  = NULL;
    cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
    cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
    cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
    cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
    cp_init.disconnect_on_fail             = false;
    cp_init.evt_handler                    = on_conn_params_evt;

    err_code = ble_conn_params_init(&cp_init);
    APP_ERROR_CHECK(err_code);
}
static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
{
    uint32_t err_code;

    switch (ble_adv_evt)
    {
        case BLE_ADV_EVT_FAST:
            err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
            APP_ERROR_CHECK(err_code);
            break;
        case BLE_ADV_EVT_IDLE:
				ble_advertising_start(BLE_ADV_MODE_SLOW);
            break;
        default:
            break;
    }
}
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
    uint32_t err_code;

    switch (p_ble_evt->header.evt_id)
    {
       case BLE_GAP_EVT_CONNECTED:
            err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
            APP_ERROR_CHECK(err_code);
            m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
			 
						flag_connected=true;

			 
            break; // BLE_GAP_EVT_CONNECTED

       case BLE_GAP_EVT_DISCONNECTED:
            err_code = bsp_indication_set(BSP_INDICATE_IDLE);
            APP_ERROR_CHECK(err_code);
            m_conn_handle = BLE_CONN_HANDLE_INVALID;
				    
						flag_disconnected=true;

				
            break; // BLE_GAP_EVT_DISCONNECTED

       case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
            // Pairing not supported
            err_code = sd_ble_gap_sec_params_reply(m_conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
            APP_ERROR_CHECK(err_code);
            break; // BLE_GAP_EVT_SEC_PARAMS_REQUEST

       case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST:
        {
            ble_gap_data_length_params_t dl_params;

            // Clearing the struct will effectivly set members to @ref BLE_GAP_DATA_LENGTH_AUTO
            memset(&dl_params, 0, sizeof(ble_gap_data_length_params_t));
            err_code = sd_ble_gap_data_length_update(p_ble_evt->evt.gap_evt.conn_handle, &dl_params, NULL);
            APP_ERROR_CHECK(err_code);
        } break;

        case BLE_GATTS_EVT_SYS_ATTR_MISSING:
            // No system attributes have been stored.
            err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
            APP_ERROR_CHECK(err_code);
            break; // BLE_GATTS_EVT_SYS_ATTR_MISSING

        case BLE_GATTC_EVT_TIMEOUT:
            // Disconnect on GATT Client timeout event.
            err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gattc_evt.conn_handle,
                                             BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
            APP_ERROR_CHECK(err_code);
            break; // BLE_GATTC_EVT_TIMEOUT

        case BLE_GATTS_EVT_TIMEOUT:
            // Disconnect on GATT Server timeout event.
            err_code = sd_ble_gap_disconnect(p_ble_evt->evt.gatts_evt.conn_handle,
                                             BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
            APP_ERROR_CHECK(err_code);
            break; // BLE_GATTS_EVT_TIMEOUT

        case BLE_EVT_USER_MEM_REQUEST:
            err_code = sd_ble_user_mem_reply(p_ble_evt->evt.gattc_evt.conn_handle, NULL);
            APP_ERROR_CHECK(err_code);
            break; // BLE_EVT_USER_MEM_REQUEST

        case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
        {
            ble_gatts_evt_rw_authorize_request_t  req;
            ble_gatts_rw_authorize_reply_params_t auth_reply;

            req = p_ble_evt->evt.gatts_evt.params.authorize_request;

            if (req.type != BLE_GATTS_AUTHORIZE_TYPE_INVALID)
            {
                if ((req.request.write.op == BLE_GATTS_OP_PREP_WRITE_REQ)     ||
                    (req.request.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_NOW) ||
                    (req.request.write.op == BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL))
                {
                    if (req.type == BLE_GATTS_AUTHORIZE_TYPE_WRITE)
                    {
                        auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_WRITE;
                    }
                    else
                    {
                        auth_reply.type = BLE_GATTS_AUTHORIZE_TYPE_READ;
                    }
                    auth_reply.params.write.gatt_status = APP_FEATURE_NOT_SUPPORTED;
                    err_code = sd_ble_gatts_rw_authorize_reply(p_ble_evt->evt.gatts_evt.conn_handle,
                                                               &auth_reply);
                    APP_ERROR_CHECK(err_code);
                }
            }
        } break; // BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST

        default:
            // No implementation needed.
            break;
    }
}
static void ble_evt_dispatch(ble_evt_t * p_ble_evt)
{
    ble_conn_params_on_ble_evt(p_ble_evt);
    nrf_ble_gatt_on_ble_evt(&m_gatt, p_ble_evt);
    ble_nus_on_ble_evt(&m_nus, p_ble_evt);
    on_ble_evt(p_ble_evt);
    ble_advertising_on_ble_evt(p_ble_evt);

}
static void ble_stack_init(void)
{
    uint32_t err_code;

    nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;

    // Initialize SoftDevice.
    SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);

    // Fetch the start address of the application RAM.
    uint32_t ram_start = 0;
    err_code = softdevice_app_ram_start_get(&ram_start);
    APP_ERROR_CHECK(err_code);

    // Overwrite some of the default configurations for the BLE stack.
    ble_cfg_t ble_cfg;

    // Configure the maximum number of connections.
    memset(&ble_cfg, 0, sizeof(ble_cfg));
    ble_cfg.gap_cfg.role_count_cfg.periph_role_count  = BLE_GAP_ROLE_COUNT_PERIPH_DEFAULT;
    ble_cfg.gap_cfg.role_count_cfg.central_role_count = 0;
    ble_cfg.gap_cfg.role_count_cfg.central_sec_count  = 0;
    err_code = sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &ble_cfg, ram_start);
    APP_ERROR_CHECK(err_code);

    // Configure the maximum ATT MTU.
    memset(&ble_cfg, 0x00, sizeof(ble_cfg));
    ble_cfg.conn_cfg.conn_cfg_tag                 = CONN_CFG_TAG;
    ble_cfg.conn_cfg.params.gatt_conn_cfg.att_mtu = NRF_BLE_GATT_MAX_MTU_SIZE;
    err_code = sd_ble_cfg_set(BLE_CONN_CFG_GATT, &ble_cfg, ram_start);
    APP_ERROR_CHECK(err_code);

    // Configure the maximum event length.
    memset(&ble_cfg, 0x00, sizeof(ble_cfg));
    ble_cfg.conn_cfg.conn_cfg_tag                     = CONN_CFG_TAG;
    ble_cfg.conn_cfg.params.gap_conn_cfg.event_length = 320;
    ble_cfg.conn_cfg.params.gap_conn_cfg.conn_count   = BLE_GAP_CONN_COUNT_DEFAULT;
    err_code = sd_ble_cfg_set(BLE_CONN_CFG_GAP, &ble_cfg, ram_start);
    APP_ERROR_CHECK(err_code);

    // Enable BLE stack.
    err_code = softdevice_enable(&ram_start);
    APP_ERROR_CHECK(err_code);

    // Subscribe for BLE events.
    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    APP_ERROR_CHECK(err_code);
}
void bsp_event_handler(bsp_event_t event)
{
    uint32_t err_code;
    switch (event)
		{
				case BSP_EVENT_SLEEP:
						ble_advertising_start(BLE_ADV_MODE_SLOW);
						break;

				case BSP_EVENT_DISCONNECT:
						err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
						if (err_code != NRF_ERROR_INVALID_STATE)
						{
								APP_ERROR_CHECK(err_code);
						}
						break;

				case BSP_EVENT_WHITELIST_OFF:
						if (m_conn_handle == BLE_CONN_HANDLE_INVALID)
						{
								err_code = ble_advertising_restart_without_whitelist();
								if (err_code != NRF_ERROR_INVALID_STATE)
								{
										APP_ERROR_CHECK(err_code);
								}
						}
						break;

				default:
						break;
		}
}
static void advertising_init(void)
{
    uint32_t               err_code;
    ble_advdata_t          advdata;
    ble_advdata_t          scanrsp;
    ble_adv_modes_config_t options;

    // Build advertising data struct to pass into @ref ble_advertising_init.
    memset(&advdata, 0, sizeof(advdata));
    advdata.name_type          = BLE_ADVDATA_FULL_NAME;
    advdata.include_appearance = false;
    advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;

    memset(&scanrsp, 0, sizeof(scanrsp));
    scanrsp.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    scanrsp.uuids_complete.p_uuids  = m_adv_uuids;

    memset(&options, 0, sizeof(options));
	  options.ble_adv_slow_enabled  = true;
    options.ble_adv_slow_interval = APP_ADV_INTERVAL;
    options.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;

    err_code = ble_advertising_init(&advdata, &scanrsp, &options, on_adv_evt, NULL);
    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(CONN_CFG_TAG);
}

void power_manage(void){
	sd_app_evt_wait();
}

//Main function.
int main(void)
{		
	
	
  	/***Leds and buzzer init.*******************/
		bsp_board_leds_init();
		/********************************/		
	
		/*Timer init.********************/
		interrupt_init();
		/********************************/
	
		/*BLE init.*******************************/
    ble_stack_init();
    gap_params_init(); 
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();
		ble_advertising_start(BLE_ADV_MODE_SLOW);
		/*****************************************/
		/*TWI communications and accelerometer init.**/
		conn_TWI(&m_twi);
		/*********************************************/

		GasGauge_Initialization(&STC3115_ConfigData,&STC3115_BatteryData);

	
	/**SPI communication starts.******************/
		spiConfiguration();
	/*********************************************/
	
		/*UV sensor configuration.********************/
		SI1133_configuration(&m_twi);		
		/*********************************************/
	
		/*Accelerometer configuration*****************/
		accelerometer_configuration(&m_twi);
		/*********************************************/
		
				
/*Infinite loop*****************************************************************************/			
	while(true){
		
		power_manage();
		
		if (flag_connected==true){			
			
			bsp_board_led_off(1);
			bsp_board_led_on(2);
			bsp_board_led_on(0);
			nrf_delay_ms(200);
			bsp_board_led_off(0);
			nrf_delay_ms(200);
			bsp_board_led_on(0);
			nrf_delay_ms(200);
			bsp_board_led_off(0);
			flag_connected=false;
		}
		
		if (flag_disconnected==true){
			bsp_board_led_off(0);
			bsp_board_led_on(1);
			nrf_delay_ms(200);
			bsp_board_led_off(1);
			nrf_delay_ms(200);
			bsp_board_led_on(1);
			
			nrf_delay_ms(200);
			bsp_board_led_off(1);
			flag_disconnected=false;
		}
		
		if (flag_received_red_on==true){
			bsp_board_led_on(1);
			flag_received_red_on=false;
		}
		
		if (flag_received_red_off==true){
			bsp_board_led_off(1);
			flag_received_red_off=false;
		}
		
		if (flag_received_green_on==true){
			bsp_board_led_on(0);
			flag_received_green_on=false;
		}
		
		if (flag_received_green_off==true){
			bsp_board_led_off(0);
			flag_received_green_off=false;
		
		}
		
			/******************Battery level****************************************************/
	GasGauge_Task(&STC3115_ConfigData, &STC3115_BatteryData);            
	battery_percent=STC3115_BatteryData.SOC/10;
			if(battery_percent > 1 && battery_percent < 100){
				battery_level = battery_percent;
				if(battery_percent < 95  && flag_low_battery == false){
						flag_low_battery = true;
						bsp_board_led_off(0);
						bsp_board_led_on(1);
				}
				else if (flag_low_battery == true && battery_percent > 99){ //Evitar margen de error de 1% y cambio de leds indeseado
					flag_low_battery = false;
				}
				else if (battery_percent >= 10 && flag_low_battery == false){
						flag_low_battery = false;
						bsp_board_led_off(1);
				}
			
				if(flag_send_battery_level==true){
					ble_nus_string_send(&m_nus, &battery_level, sizeof(battery_level));		
					flag_send_battery_level=false;
				}
				
		}
			
	/************************************************************************************/  
		
		if (flag_received_alert_fast==true){
			
			for (int times=1;times<6;times++){
				bsp_board_led_off(0);
				bsp_board_led_on(1);
				bsp_board_led_off(2);
				nrf_delay_ms(200);
				bsp_board_led_off(1);
				bsp_board_led_on(2);
				nrf_delay_ms(1500);
				}
			
			flag_received_alert_fast = false;
		};
		
		if (flag_received_alert_slow==true){
			
			for (int times=1;times<3;times++){
				bsp_board_led_off(0);
				bsp_board_led_on(1);
				bsp_board_led_off(2);
				nrf_delay_ms(100);
				bsp_board_led_off(1);
				bsp_board_led_on(2);
				nrf_delay_ms(700);
				}
			
			flag_received_alert_slow = false;
		};


	}
}
/****************************************************************************************************/

Let me know if you need more details, thank you.

Parents Reply Children
  • Hi bjorn-spockeli, yes, they are initialized before that function

  • I was asking if you are de-initalizing them before going to sleep. Any peripheral that explicitly enabled before going to sleep will be active during sleep, i.e. if you want the lowest current consumption, then you should initalize the drivers when you wake-up and de-initialize them before you go to sleep. 

  • I took a quick look at the datasheets of the sensors, if they're all in the lowest power state they should contribute with 

    Si1133: 0.550uA

    BMX Acc  + Gyro + Mag: 2.1uA + 5uA + 1uA = 

    STC3115:   2uA

    ---------------------------------------------------------------
    Total contribution from Sensors: ~ 11uA 

    Just to be certain that its not these sensors that are the culprits, could you comment out all code that refers to these sensors in your main and then redo the measurements? The best case would be if you have a board that is only populated with the nRF52832 and not the sensors. I also see that you call the function interrupt init, could you post the code from that function? I does not seem to be defined in main.c

    Lastly, what kind of preferred connection interval have you configured?

     

     

  • If I comment that code, the sensors are in normal mode, and it consumes about 20mA, I've tested the blinky example and that is the consumption.

    Unfortunately, I haven't got that kind of board.

    -------------------------------------------------------------------------------------

    Interrupt function:

    void interrupt_init(void){

    lfclk_config();
    app_timer_init();

    }

    lfclk_config():

    static void lfclk_config(void)
    {
    ret_code_t err_code = nrf_drv_clock_init();
    if (err_code!=NRF_SUCCESS){

    err_code = nrf_drv_clock_init();
    nrf_delay_ms(5);

    }

    nrf_drv_clock_lfclk_request(NULL);
    }

    app_timer_init():

    ret_code_t app_timer_init(void)
    {
    // Stop RTC to prevent any running timers from expiring (in case of reinitialization)
    rtc1_stop();

    // Initialize operation queue
    m_op_queue.first = 0;
    m_op_queue.last = 0;
    m_op_queue.size = APP_TIMER_CONFIG_OP_QUEUE_SIZE+1;

    mp_timer_id_head = NULL;
    m_ticks_elapsed_q_read_ind = 0;
    m_ticks_elapsed_q_write_ind = 0;

    #if APP_TIMER_WITH_PROFILER
    m_max_user_op_queue_utilization = 0;
    #endif

    NVIC_ClearPendingIRQ(SWI_IRQn);
    NVIC_SetPriority(SWI_IRQn, SWI_IRQ_PRI);
    NVIC_EnableIRQ(SWI_IRQn);

    rtc1_init(APP_TIMER_CONFIG_RTC_FREQUENCY);

    m_ticks_latest = rtc1_counter_get();

    return NRF_SUCCESS;
    }

    -----------------------------------------------------------------------------------------------------------

    Lastly, preferred connection interval:

    #define MIN_CONN_INTERVAL MSEC_TO_UNITS(500, UNIT_1_25_MS) 
    #define MAX_CONN_INTERVAL MSEC_TO_UNITS(1000, UNIT_1_25_MS)

    I also tried with:

    #define MIN_CONN_INTERVAL (uint16_t)(MSEC_TO_UNITS(15, UNIT_1_25_MS)) 
    #define MAX_CONN_INTERVAL (uint16_t)(MSEC_TO_UNITS(100, UNIT_1_25_MS))

    I could send you the whole project to make easier your help.

    Thank you.

Related