Unable to detect a i2c sensor using twi_scanner example

I want to use a sensor with nrf52 dev kit. for the same purpose I am first scanning sensor using twi_scanner example but it does not detect.


configuration used for nrf_drv_twi_config_t is :

>>
    const nrf_drv_twi_config_t twi_config = {
       .scl                = 8,
       .sda                = 14,
       .frequency          = NRF_TWI_FREQ_250K,
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = true
    };

    err_code = nrf_drv_twi_init(&m_twi, &twi_config, NULL, NULL);


I have tried the .frequency as NRF_TWI_FREQ_250K, NRF_DRV_TWI_FREQ_100K, NRF_TWI_FREQ_400K and also checked on other GPIOs but still it did not worked.
I checked the same sensor with Ardunio and Raspberry Pi , there it works fine.

Parents Reply Children
  • Have you tried debugging to ensure that the TWI functions are used are actually reached?

  • Yes..

    Addition to this as mentioned already.. I am able to detect other i2c sensor ( like accelerometer) using same scanner code without any modifications

  • Yes...

    I am trying to figure out what the issue is, but I do not have access to the same TWI sensor that you are using. Therefore, if you are telling me that you are running the TWI scanner example and it isn't detected, I suspect that one of the two following things are happening:

    1: The scanner part of the code is not reached. This can be easily checked by debugging and seeing that the nrf_drv_twi_rx() is reached with the address that you believe it is using, and that err_code = NRF_SUCCESS at that point in time (after err_code = nrf_drv_twi_rx() is executed).

    2: The sensor, as it is detected by other microcontrollers, such as your arduino, requires a different voltage than what the nRF provides. Did you check your VDD with a multimeter? Depending on the arduino you were using, it may have different GPIO voltage. Perhaps it has 5V GPIOs? My suspicion is that the nRF GPIOs doesn't have a high enough voltage for your sensor. 

Related