What is I2c? - Well, I2C, also known as Inter-Integrated Circuit, is a serial
communication protocol used to connect microcontrollers, sensors, and
other devices together in electronics projects.
The key point is that
you can connect multiple devices to the same 2-wire I2C bus and control
any of them on command.
There are many, many more and you can find a lot of pages about them on this site.
The reason the I2C protocol is so popular is that it
reduces all wiring to just 2 wires. You can have a 16 bit ADC (ADS1115)
that, if you did not have the I2C interface, you would need 16 wires to
connect it to your microcontroller!
One way of understanding what is I2C is to ask what is it used for, and the answer is :
I2C is commonly used for connecting peripherals like sensors, LCD displays, real-time clocks (RTCs), and other microcontrollers together in an embedded system. Its bidirectional two-wire interface makes it an efficient way to exchange data between multiple slave devices and a master controller. Some common applications of I2C include:
You might have missed it but in the paragraph above I said
"connecting...microcontrollers together". You can actually send data
between controllers - it is not just from a microcontroller to a slave
As an embedded system interface, I2C allows for easy
communication between integrated circuits using just two bidirectional
open-drain lines - SDA (data) and SCL (clock).
Where is the address and how does a slave device even have an address?The address uniquely identifies a device on the I2C bus so that a master controller can communicate with it.
What if two devices have the same address?It's not common but it could happen. The answer is that usually you can slightly change the "real" address by one or two values, avoiding bus conflicts (or allowing multiple identical devices on the same bus).
Now, of course there is a down side and that is throughput (I2C is a
serial interface) - but the I2C interface goes fast 400kHz and the some
devices can adopt an even faster rate : 3.4MHz.
For example, if you have an 16 bit ADC, then the protocol will serialise the data to 16 periods of 400kHz (approx). In addition there is more data to allow the protocol to work. It means you don't get a through put of 400kHz - always less.
The way to guesstumate the through put is to divide the max I2C clock
rate by the number of bits transmitted plus add the packet that is
needed for the address.
Since packets are usually divided into 8 bit blocks and the payload
of an I2C packet is 8 bits plus 1 (acknowledge). The number
of I2C bits for the ADDS1115 is 3 packets of 9 bits, with additional
start and stop bits.
So an estimated through put (with a 100kHz master clock) is
100e3/(3*9+2) = 3448kHz or 3.5kHz
and (for a 400kHz master clock)
400e3/(3*9+2) = 13793 or 13.7kHz
So you could take a reading from the ADS1115 at a maximum rate of
3.5kHz for a 100kHz I2C clock and 13.7kHz for a 400kHz clock. Note this
does not take into account how fast the ADC (see this ADS1115 page) is capable of operating, but illustrates the principle of maximum through put or data rate.
The point is that for high speed operation you may need to
a higher speed clock or a different device - depending on your design
requirements. An alternative to the I2C interface is the simpler but
faster SPI interface (some chips come in I2C or SPI flavours e.g. MCP23017).
Note the above does not account for the processor which will need time between bursts of data to actually process the data!
Well...the answer is...it depends!
There have been cases of inexperienced designers using I2C
as a LAN network and this is absolutely how it should not be used. I2C
is designed for local board (a printed circuit board) operation
only. (if you want high speed LAN operation then use something
like RS485 - these days IOT is easier - no cables).
Each of the two I2C signals SCK and SDA are open drain
connections. These are pulled high by a single resistor on each line
The main problem here is capacitance. The signal can only
rise as fast as the current flowing into the "total capacitance on each
I2C signal line" will allow.
The longer the I2C signal lines, and the more devices
attached to those signal lines, the more capacitance you will have.
Hence, the slower the signals will rise and hence the more errors you
get - or reduce the operating speed to accommodate the slow rise times.
Written by John Main who has a degree in Electronic Engineering.
Note: Parts of this page were written using poe as a research assistant.
Have your say about what you just read! Leave me a comment in the box below.
Don’t see the comments box? Log in to your Facebook account, give Facebook consent, then return to this page and refresh it.