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

1459 questions
-2
votes
1 answer

How can I emulate an I2C device on Linux?

I have a custom SOM (based on iMX6) board being developed that will run Ubuntu, and has several I2C devices attached to one of the iMX6 I2C "adapters". Given the hardware is not yet available, I'd like to write software to access and control said…
Bob
  • 437
  • 5
  • 13
-2
votes
1 answer

Camera bt656 without i2c. How capture?

I have camera (camera + videoprocessor TW8834) sending video data over bt656 protocol, but the camera interface have not i2c on cable, so, it isn't recognizing by linux video driver.Is there some way to capture video from my camera in linux without…
-2
votes
1 answer

Debain i2c driver builtin no /dev/i2c-*

I've a problem and can't solve it by myself, soo... I have an OrangePi zero and I use Debian on it. The i2C module is a buildin driver but I don't know how to use it. $ uname -a Linux d621 5.3.5+ #2 SMP Fri Nov 15 16:24:33 CST 2019 armv7l…
-2
votes
1 answer

How to get response from adv7513 i2c

I want to use hdmi monitor with cyclone V GX board, but I don't get an acknowledgement from adv7513 on i2c bus. I think there is a problem with the address that I am sending at the beginning of the i2c transaction (I get no acknowledgement of…
Matt
  • 1
  • 3
-2
votes
1 answer

Raspberry communication with multiple Arduino's over long distance wire

Recently i was digging information about communication between RaspberryPi and multiple Arduino slaves over long distance wire (10-15 meters). My initial thought was to use I2C, but after doing some research i have found out that wire length is a…
ArnArm
  • 1
-2
votes
1 answer

I2C Master-slave address

I am working on a project where I'm trying to implement I2C master-slave communication so as to read some data from a magnetic sensor. That's all OK and I have written the code. However, I am not quite sure about the slave address needed for the…
Strale030
  • 1
  • 4
-2
votes
1 answer

I2C Communications and polling

I am developing on a HummingBoard Pro (Armbian). I want to talk with a peripheral using I2C. I read the datasheet and found that it provides datastream at the address 0xff. So I wrote a tool that periodically checks if data is available and prints…
Francesco.S
  • 35
  • 1
  • 6
-2
votes
1 answer

Which Commands do I have to use SSD1306 over I²C?

I want to create a simple linux driver for the SSD1306 that I have connected to my Raspberry Pi over I²C. Before I start coding, I want to get to know the device and which commands I have to send. I use the i2c-tools for linux to test my commands. I…
p0kR
  • 80
  • 1
  • 10
-2
votes
1 answer

arduino global variable using I2C and LCD

I'm using Arduino Uno in my project : One is a Master and the other is a Slave. I send Data from the Master to the Slave using I2C. I need to send float, but because I2C can only send char, so I'm obligated to transform float into String, then send…
-3
votes
1 answer

I2C - MCP4725 DAC (12bit)

i have alternative signal , want to reconstruction ADC signal with DAC and see result. i'm not Write DAC value to MCP4725 for reconstruction ADC signal . how to done it ? please help me for solve it thank's
navid
  • 3
  • 3
-3
votes
2 answers

Can anyone tell me about the pin configuration of 16 pin I2C module?

I am using I2C with 4*4 keypad. But i cannot find the pinout of I2C. Can anyone help me with this? The link for I2C image is:- https://www.14core.com/wp-content/uploads/2015/09/I2C-LCD-Module-Board-Arduino-AVR-PIC.jpg I want to know the pinout of…
-3
votes
1 answer

Writing .Net window application in C++

I have a task to do: I have to write a graphical (window) application in .Net which is going to read temperature from the three sensors (namely MCP9808, SI7051 and STS31-DIS) connected via MCP2221 I2C/USB converter and display it on the…
-3
votes
1 answer

two i2c sensors cant work simultaneously

I tested all sensors onboard GY86(MPU6050-HMC8553-MS5611) and tiny RTC module ds1307 separately with an Arduino Uno. Now I am trying to connect both of them and get results simultaneously. Exactly when i connect DS1307 to I2C bus,suddenly i get…
a.ghad
  • 13
  • 6
-3
votes
1 answer

real time clock using pic16lf1902/03

I'm finding difficult in implementing real time clock for pic16lf1902, wherein their are no serial protocols for communicating/interfacing with builtin LCD drive. Is their a convenient way to solve the problem? For example using I2C software…
user1890
  • 9
  • 1
-4
votes
1 answer

Raspberry Pi C++ I2C/SPI Examples

Hello and please do not delete right away. I'm having trouble finding good CODE examples for the I2C/SPI programming on the Raspberry Pi using C++. I've looked at wiringPi and other sources but they don't give much documentation with their source…
1 2 3
97
98