Simple I2C read/write code

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hey guys,

I am new to TAG development. Since there aren't many examples relating I2C, can someone please post a simple code that read/write registers via I2C and displays it in the console window. Thanks in advance.

0 Likes
1 Solution

i2c_temperature_sensor.c has the simplest implementation, follow temperature_sensor_read_and_print_temperature_data() and it does exactly this - reads the current temperature from the sensor and then writes it out as a debug trace.

View solution in original post

4 Replies
Anonymous
Not applicable

Hello jjafer,

Please see the I2C example in the SDK 2.1.1

pastedImage_0.png

This example explains the I2C connection to a temperature sensor.

Please also see the WICED SENSE Kit BLOG - which shows a Video Walk-Thru of the I2C code used to talk to 5 sensors over I2C bus.

Hope this helps

JT

0 Likes
Anonymous
Not applicable

Hi JT,

Thanks for the info. I went through the BLOG and watched the walk through video but the video did not talk about how the I2C was implemented and used. It just mentioned that I2C was used and the drivers to read through I2C for those particular sensors were provided by ST. I am looking for a simple code that reads a register through I2C and prints it to the console. Really appreciate your help.

Thanks.

0 Likes

i2c_temperature_sensor.c has the simplest implementation, follow temperature_sensor_read_and_print_temperature_data() and it does exactly this - reads the current temperature from the sensor and then writes it out as a debug trace.

Anonymous
Not applicable

Thanks arvinds, I will try this out.

0 Likes