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

TWI scanner and sensors

Hello,

I am working with an nRF52 and two sensors using TWI. My code is based on the TWI_sensor example from SDK 12.2. I made an interesting discovery today when trying to get my HRMI board working over TWI.

When I load and run the TWI_scanner example, both of my sensors appear as they should, but only when I switched the SCL and SDA pins around. So far, my accelerometer has been giving me data when the SCL line is connected to pin 26 and SDA on pin 27. However, the TWI_scanner will only read the I2C address of the accelerometer when the SCL line is on pin 27 and SDA on pin 26 with nothing else changed in the circuitry.

The code I wrote defines SCL to pin 26 and SDA to pin 27, and when I reverse these in my code the sensor data will not display. I am doing all of this to try and read heart rate monitor data from my HRMI board (open devzone question here). I am trying to understand TWI better now to fix my problem. Am I on to something here?

Edit: Here is a zip file for my Levi Project.zip updated.

  • My mistake! I attached my source files now, thanks!

  • Are you sure you have defined the pins correctly? The TWI scanner example define SCL line on pin 27 and SDA on pin 26 by default. Did you change the example to swap these pins?

  • Hello guys,

    I've been through the same trouble while trying to scan for the addresses of two sensors using de TWI scanner from the SDK on my nRF52 DK. What happens is that while gathering documentation for my project, I ran over two versions of the same 'wrong documentation' on the DK. I'm calling them wrong because they lead to these misconceptions if someone isn't looking into the header files.

    The first one is this Portuguese publication about the DK here, this is a very famous tech site here in Brazil so I think you should reach out to them and warn about it. The second one is a publication in English, located here, which is one of the top results while searching for 'nrf52 dk pinout'.

    Well, this is just a way to help someone who might have been caught by these 'wrong pinouts' and has been struggling to find a way out. Just as a reminder: It's always good to take a look at the headers of the examples, the answer to this problem is there but I think these misconceptions really get us confused.

Related