Questions tagged [i2c]

I2C is a two-wire serial bus. It is used to interface with low-speed peripherals in embedded systems and computer motherboards.

Use this tag when asking questions concerning the I2C bus or SMBus, which is a more strictly defined subset of I2C.

Devices you can communicate with using I2C might include the temperature and voltage sensors on your motherboard. In embedded systems, a vast amount of devices ranging from memory chips to camera modules use I2C for control and data transfer.

I2C bus consists of two signals: SCL and SDA. SCL is the clock signal, and SDA is the data signal.

I2C connection schematics

The clock signal is always generated by the current bus master; some slave devices may force the clock low at times to delay the master sending more data (or to require more time to prepare data before the master attempts to clock it out). The common clock frequency of I2C bus is 100KHz (100Kbps) and 400KHz (400 Kbps). There are high speed versions with clock frequency at or greater than 1MHz (1Mbps) available which is product specific by the semiconductor manufacturers.

The bus is a multi-master bus, which means that any number of master nodes can be present. Additionally, master and slave roles may be changed between messages (after a STOP is sent).

At any given time only the master will be able to initiate the communication. Since there is more than one slave in the bus, the master has to refer to each slave using a different address. When addressed only the slave with that particular address will reply back with the information while the others keep quit. This way we can use the same bus to communicate with multiple devices.

The voltage levels of I2C are not predefined. I2C communication is flexible, means the device which is powered by 5v volt, can use 5v for I2C and the 3.3v devices can use 3v for I2C communication. A 5V I2C bus can’t be connected with 3.3V device. In this case voltage shifters are used to match the voltage levels between two I2C buses.

There are some set of conditions which frame a transaction. Initialization of transmission begins with a falling edge of SDA, which is defined as ‘START’ condition in below diagram where master leaves SCL high while setting SDA low. After this all devices on the same bus go into listening mode.

In the same manner, rising edge of SDA stops the transmission which is shown as ‘STOP’ condition in above diagram, where the master leaves SCL high and also releases SDA to go HIGH. So rising edge of SDA stops the transmission.

I2C conditions

With I2C, data is transferred in messages. Messages are broken up into frames of data. Each message has an address frame that contains the binary address of the slave, and one or more data frames that contain the data being transmitted. The message also includes start and stop conditions, read/write bits, and ACK/NACK bits between each data frame:

I2C message format

Address Frame: A 7 or 10 bit sequence unique to each slave that identifies the slave when the master wants to talk to it.

Read/Write Bit: A single bit specifying whether the master is sending data to the slave (low voltage level) or requesting data from it (high voltage level).

ACK/NACK Bit: Each frame in a message is followed by an acknowledge/no-acknowledge bit. If an address frame or data frame was successfully received, an ACK bit is returned to the sender from the receiving device.

More information:

I2C Standards Doc

I2C primer

1748 questions
0
votes
1 answer

Atmel SAM4S pulling TWI/I²C lines low

We are using the Atmel SAM4S2C 32 bit ARM microprocessor along with a smart battery, controlled by a bq20z45 controller in it. The Battery sends a message to a (non-present) smart battery charger on the SMBus. It seems that within 24 - 72 hrs the…
0
votes
1 answer

I2C Bus multi master multi slave

I am working on Ti's EK-TM4C1294XL which is basically a Arm Cortex M4 evaluation board. I was going through I2C bus of the same and have the following question regarding the I2C bus. I understand I2C support multi master multi slave configuration.…
0
votes
2 answers

Getting data from an RFID reader

I have a an RFID reader with very scant documentation. It has some wires hanging out and they come from a connector with "+12V", "GND", "NC" , "COM" (or CDM) , "NO", "SW", "D0" , "D1" pins. I don't know what they are but "+12V" and "GND" are for…
user1231247
  • 193
  • 1
  • 8
0
votes
1 answer

I2C SCL line, clock issue on STM32F4

In I2C interface, SCL, clock line will transmit clock signals even if there are no devices on the bus? How can we debug the I2C?
Lingaraj
  • 99
  • 2
  • 13
0
votes
1 answer

I2C windows iOT find no DeviceInformation

I try to communicate between a raspberry pi 3 running windows 10 IOT build 14376 insiders and a T-REX Manual here using I2C protocol. The thing is that it always crash, so after some debug process I've found that it looks like it doesn't retrieve…
Sven Borden
  • 1,070
  • 1
  • 13
  • 29
0
votes
1 answer

STM32 HAL I2C is returning OVR (overrun/under-run) error when using an interrupt driven approach

I am attempting to implement an interrupt driven I2C slave that is continuously ready to receive (except when transmitting) on the STM32L051. The problem is that I keep receiving the HAL_I2C_ERROR_OVR error in the HAL_I2C_ErrorCallback. The below…
Devin Parker
  • 41
  • 1
  • 4
0
votes
0 answers

Can I determine number of byte transfer using DMA subsystem in linux?

I have a code that write data to a I2C-EEPROM. The i2c-driver is config to use DMA. But is there anyway I can check that data is transfered by i2c using DMA from my program in user-space? Thanks!
dvn0zzz
  • 337
  • 3
  • 13
0
votes
0 answers

I2C clock stretching details

I am new to I2C, and after reading about clock streching I become puzzled about mechanism it works. About clock stretchig I've read that slave is allowed to hold down the clock if it needs to reduce the bus speed, but haven't understand how can…
Binary Mind
  • 309
  • 3
  • 13
0
votes
1 answer

Getting/Processing the right values U get from the MPU-6050 with Arduino Due

for my project for school that decides if I pass this year or not I have to work with an MPU-6050 and an Arduino Due. The MPU works via I2C and ive got that part working. I can get values and its linked. But there is one problem, with my code it…
Martacus
  • 723
  • 6
  • 23
0
votes
1 answer

Raspberry error write in i2c socket

I'm trying to control my domotic house by smartphone, the smartphone sends 3-4 byte to Raspberry via Internet(Wi-Fi) and Raspberry send all those bytes to the corresponding Arduino throught I2C bus(I've got two Arduinos). When I send the commands to…
0
votes
0 answers

issue on interfacing adt7410 with yocto

I am trying to interface an I2C device ADT7410 with yocto but i am getting this error adt7410: probe of 4-0048 failed with error -5 and my device tree modification is TempSen: adt7410@48 { compatible = "adt7410","adt7x10"; reg = <0x48>; …
Joe Vince
  • 345
  • 4
  • 16
0
votes
1 answer

How to go about debugging from a sensor? (GCC)

Attempting to retrieve data from an adafruit sensor (sht31d). Compiling using GCC on a Fio , microcontroller is an atmega328p. The original Arduino Implementation using Wire, in readTempHum(): for (uint8_t i=0; i<6; i++) { readbuffer[i] =…
Womble
  • 345
  • 3
  • 13
0
votes
2 answers

Sending Byte from Raspberry Pi to Arduino With I2c & IoT for PWM

I am very new to the using both I2C and C#/Windows IoT so apologies up front if any of this is a dumb question. I have a Raspberry Pi 3 master and Arduino slave. I am trying to send a value from a slider on my UI form over I2C to the Arduino which I…
Ryland
  • 79
  • 8
0
votes
0 answers

I2C communication between Arduino Uno and Raspberry. Wrong values on the Pi

I have been trying to setup a I2C communication using Wire.h library between an Arduino Uno (Slave) and Raspberry Pi (Master), running Windows IoT, in order to read the values of two push buttons connected to the Arduino. The issue is that on the…
0
votes
0 answers

RAW value from Accelerometer(BerryIMU) and get Velocity

This must be an obvious and stupid question... I'm working on an Raspberry Pi 3 wired with an BerryIMU (9 ways of freedom). I'm getting the RAW values from the Accelerometer, but what the meaning of those values ? (x, y) (-57, 573) (-56, 567) (-64,…
David Pham
  • 151
  • 1
  • 1
  • 15
1 2 3
99
100