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

Error when turn on sensor with TWI

I need to save energy for my ble application. So I turned off the sensor when there was no ble connection. A ble connection is a condition for me to turn on the sensor, but I cannot connect to the peripheral, when placing a connection command on nRF Connect, the debugger reports "Memory read failure".
Whether declared or not declared i2c, the phenomenon still occurs.

I am using a port to turn on and off the si7021 sensor as shown below:

When the central connection comes in, during the BLE_GAP_EVT_CONNECTED event I will turn on the sensor by setting the output of port 15 to 1. I have a problem connecting, the debugger does not report an error. Chip rebooted.

I am using twi with library twi_sw_master.c. So how do I turn this sensor on and off? Please help me, thanks a lot

P/s: nRF52832 s132 ver 6.1.1 SDK 15.3

Parents Reply
  • I need to save energy for my ble application. So I turned off the sensor when there was no ble connection. A ble connection is a condition for me to turn on the sensor, but I cannot connect to the peripheral, when placing a connection command on nRF Connect, the debugger reports "Memory read failure".
    Whether declared or not declared i2c, the phenomenon still occurs.

Children
  • Whether declared or not declared i2c, the phenomenon still occurs

    So you're saying this has nothing to do with your I2C sensor - it is purely a BLE thing?

    If this is about energy saving, are you putting the CPU to sleep - so that the debugger loses connection ?

  • I mean when I need to save energy, so I turn off the sensor. When I need to read I turn it on.
    The problem I'm having, even though the CPU is not sleeping, when I connect to the device, the device will turn on the sensor. The process of turning on the sensor caused the nrf52832 to be restarted.

    Even though the sensor is set to power down, it still consumes about 0.51mA, which is great for my ble application.

            case BLE_GAP_EVT_CONNECTED:
                NRF_LOG_DEBUG("Connected");
                app_timer_stop(app_timer_adv);
                m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
                err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle);
                APP_ERROR_CHECK(err_code);
                nrf_gpio_pin_write(BLE_SENSOR_PIN, 1);
                nrf_delay_ms(1);
    
                twi_init();            
                break;

Related