Hi,
I'm using the NRF52832, as peripheral, to read data from a HTS221 sensor via I2C.
I'm using the TWI_sensor module following this example, but I want it to enable and disable this module to decrease the device consumption.
I've defined a timer to manage the sensor reads every 10 seconds as follows:
1. 1 second before reading, it enables the sensor's power supply and inits the module
2. It reads the sensor register to save temperature
3. 1 seconds after reading, it uninits the module and disables the sensor's power supply
I've used 1 second between each action to ensure the last action is done before the next one.
if (sensor_action == 1){
sensor_action = 0;
nrf_gpio_pin_set(GPIO_DCDC_ENABLE);
twi_config();
}
else if (sensor_action == 2){
sensor_action = 0;
hts221_read();
}
else if (sensor_action == 3){
sensor_action = 0;
nrf_twi_mngr_uninit(&m_nrf_twi_mngr);
nrf_gpio_pin_clear(GPIO_DCDC_ENABLE);
}
If I keep the module enabled continously it works well, but when I try to do this process, it doesn't read the sensor registers.
In addition, when I use this process and I try to connect the peripheral to a central, I get NRF_ERROR_INVALID_STATE after function nrf_ble_qwr_conn_handle_assign() in ble_evt_handler.
I dont't know how changes in TWI module affect the BLE module.