meta data for this page
This is an old revision of the document!
lamaPLC Communication: I²C
I²C (Inter-Integrated Circuit; pronounced as “eye-squared-C”), alternatively known as I2C, I²C or IIC, is a synchronous, multi-master/multi-slave (controller/target), packet switched, single-ended, serial communication bus invented in 1982 by Philips Semiconductors. It is widely used for attaching lower-speed peripheral ICs to processors and microcontrollers in short-distance, intra-board communication.
I²C is similar in concept to 1-Wire.
Several competitors, such as Siemens, NEC, Texas Instruments, STMicroelectronics, Motorola, Nordic Semiconductor and Intersil, have introduced compatible I²C products to the market since the mid-1990s.
System Management Bus (SMBus), defined by Intel in 1995, is a subset of I²C, defining a stricter usage. One purpose of SMBus is to promote robustness and interoperability. Accordingly, modern I²C systems incorporate some policies and rules from SMBus, sometimes supporting both I2C and SMBus, requiring only minimal reconfiguration either by commanding or output pin use.
I²C specifications
- In the most common case, the I²C bus contains only one master, but the possibility of a multimaster is also not excluded
- I²C uses an open-ended pair of wires for data transfer, the serial data line (SDA) and the serial clock signal (SCL). The two wires must be pulled to the operating voltage with resistors, the wires typically operate with a voltage of 5V or 3.3V, but a different voltage specification is also not excluded.
- Pull-up resistors are almost always 4.7k
- In principle, the maximum distance of the bus is 7.6 m, but it is typically used within 2-3 m.
- The bus typically uses 7- or 10-bit addressing, but sometimes the 16-bit solution also occurs. Typical transmission speeds:
Mode | Speed |
---|---|
Low speed mode | 10 kbit / sec |
standard mode | 100 kbit / sec |
fast mode (FM) | 400 kbit / sec |
fast mode plus (FM+) | 1 Mbit / sec |
high-speed mode (HS) | 1.7 .. 3.4 Mbit / sec |
Ultra-fast mode (UFm) | 5 Mbit / sec |
I²C Arduino
The I²C protocol involves using two lines to send and receive data: a serial clock pin (SCL) that the Arduino Controller board pulses at a regular interval, and a serial data pin (SDA) over which data is sent between the two devices.
In I²C, there is one controller device, with one or more peripheral devices connected to the controllers SCL and SDA lines.
As the clock line changes from low to high (known as the rising edge of the clock pulse), a single bit of information is transferred from the board to the I²C device over the SDA line. As the clock line keeps pulsing, more and more bits are sent until a sequence of a 7 or 8 bit address, and a command or data is formed. When this information is sent - bit after bit -, the called upon device executes the request and transmits it's data back - if required - to the board over the same line using the clock signal still generated by the Controller on SCL as timing.
Each device in the I²C bus is functionally independent from the controller, but will respond with information when prompted by the controller.
Because the I²C protocol allows for each enabled device to have it's own unique address, and as both controller and peripheral devices to take turns communicating over a single line, it is possible for your Arduino board to communicate (in turn) with many devices, or other boards, while using just two pins of your microcontroller.
- The controller sends out instructions through the I2C bus on the data pin (SDA), and the instructions are prefaced with the address, so that only the correct device listens.
- Then there is a bit signifying whether the controller wants to read or write.
- Every message needs to be acknowledged, to combat unexpected results, once the receiver has acknowledged the previous information it lets the controller know, so it can move on to the next set of bits.
- 8 bits of data
- Another acknowledgement bit
- 8 bits of data
- Another acknowledgement bit
More from Arduino I²C protocol
I²C Arduino with 3.3V
The I²C communication basically works with 5V, but in certain cases, for example, if there is a 3.3V base voltage unit (ESP32) in the network, then 3.3V is also sufficient for the 5V units. The voltage level can be stabilized with 4.7 kOhm pull-up resistors (SDO, SCL):
Sources
I²C topics on lamaPLC
Page | Date | User | Tags |
---|---|---|---|
2023/05/18 23:23 | 1-wire, communication, bus, microlan, i2c, uart, usart, ds18b20 | ||
2023/07/04 17:34 | i2c, i c, smbus, philips, bus, communication, arduino | ||
2025/05/31 18:02 | Sandor Vamos | i2c, i c, communication, arduino, energy, power, current, sensor, ina226 | |
2023/07/01 15:29 | gas, sensor, i2c, onewire, communication, mq-3, mq-4, mq-5, mq-6, mq-7, mq-8, mq-9, mq-135, gm-102b, gm-302b, gm-502b, gm-702b, alcohol, ch4, natural gas, smoke, lng, co, co2, lpg, h2, iso-butane, nox, nh3, benzene, town gas, formaldehyde, propane, humidity, temperature, voc, grv gas sens v2 | ||
2024/02/02 16:19 | sht20, sht21, sht25, sht30, sht31, sht35, sht40, dht11, dht20, dht22, am2302, dps310, bme280, bme680, bmp180, bmp280, si7021, tc1047a, ds18b20, htu21, htu21d, gy21, gy68, gy bme280, scd30, modul, humidity, temperature, air-press, sensor, i2c, spi, modbus, onewire, communication |
This page has been accessed for: Today: 4, Until now: 970