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

  • 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;

  • When I use the latest version. The scl, sda pins are all pulled up to vcc, which makes the sensor still work, because my hardware has SCL and SDA suspension resistors.
    And one more thing is, when I turned the sensor on and off, even though i2c was not declared, the chip was still restarted.

  • HuanVH said:
    And one more thing is, when I turned the sensor on and off, even though i2c was not declared, the chip was still restarted.

    Like I said in my answer above, the chip will only restart if an error is reported. Please debug the application to find which function is reporting an error.

Related