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

nrf52840 with Arduino over I2C

Hello,

We are trying to set up communication between nrf52840 and Arduino UNO over I2C.

The challenge is we don't know the slave address of the Arduino.

Anyone else has worked on this before please guide.

Thanks

Parents
  • As described in the example documentation, the nRF will output the results of the TWI bus scan to the terminal, where your Arduino device then should show up - if it is connected correctly and configured as a TWI slave.

    This is working. We are able to get the Slave address via the TWI scan example.

    One more question though: What should be passed in the first argument of nrf_drv_twi_tx? The argument requires: nrf_drv_twi_t const * p_instance?

  • Hello,

    Neel said:
    This is working. We are able to get the Slave address via the TWI scan example.

    Great, I am happy to hear that you are able to find the slave address of your connected device.
    This means that the connection is correct, and the configuration of the connected device as a slave device is correct.

    Neel said:
    One more question though: What should be passed in the first argument of nrf_drv_twi_tx? The argument requires: nrf_drv_twi_t const * p_instance?

    For the first argument of the function, you should pass your twi instance. You can see this being created at the very start of the example, in the line:

    static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);


    The TWI instance allocates memory to your TWI instance. You will need to pass this as an argument to most ( if not all ) the driver functions.

    Lastly, as a side note, I recommend that you move to using the nrfx_twim driver directly, instead of using the legacy nrf_drv driver.

    Best regards,
    Karl

Reply
  • Hello,

    Neel said:
    This is working. We are able to get the Slave address via the TWI scan example.

    Great, I am happy to hear that you are able to find the slave address of your connected device.
    This means that the connection is correct, and the configuration of the connected device as a slave device is correct.

    Neel said:
    One more question though: What should be passed in the first argument of nrf_drv_twi_tx? The argument requires: nrf_drv_twi_t const * p_instance?

    For the first argument of the function, you should pass your twi instance. You can see this being created at the very start of the example, in the line:

    static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);


    The TWI instance allocates memory to your TWI instance. You will need to pass this as an argument to most ( if not all ) the driver functions.

    Lastly, as a side note, I recommend that you move to using the nrfx_twim driver directly, instead of using the legacy nrf_drv driver.

    Best regards,
    Karl

Children
No Data
Related