Ground Embedded KO Subscribe

3D Labs

I2C Bus

Put two sensors on one pair of wires and call them by address. Start condition, 7-bit address, ACK and NACK, and what happens without pull-up resistors, step by step.

Send

Bus waveform top SCL · bottom SDA

The yellow band is the present moment. SDA is green while a sensor drives it and yellow while the master does.

Results

Address byte on the wire
Response
Bit time
Whole transfer

Try this

  1. Leave the address at 0x68 and press Send. The moment SDA falls while SCL is HIGH is the start condition.
  2. After the 7 address bits and the read/write bit, Sensor A pulls SDA LOW on the ninth clock. That is the ACK, and Sensor A's green LED lights.
  3. Change the address to 0x76 and only Sensor B answers. They share the wires, but a chip stays quiet unless its own address is called.
  4. Choose 0x50 (no such device): nobody pulls SDA, so it stays HIGH. The master reads that as NACK and issues a stop condition at once.
  5. Switch the direction to Read and the 8 bits after the address are driven by the sensor. The master ends with a NACK to say "stop sending".
  6. Remove the pull-up resistors and send. Neither line can rise to HIGH, so communication never starts.

How to read it

Both I2C lines are HIGH unless someone pulls them down, because of the pull-up resistors. Master and slaves can only pull LOW. That is why several chips can share a wire without fighting, and why a receiver can answer on the same wire with an ACK.

Data changes only while SCL is LOW and is read while SCL is HIGH. SDA changes while SCL is HIGH in just two cases: the start and stop conditions.

"Address byte on the wire" below is the 7-bit address shifted left one place with the read/write bit added. Writing to 0x68 sends 0xD0; reading sends 0xD1. This is why datasheets disagree about how to write an address.

FREE PDFGet the 3 free ebooksIf you want what you just ran written down: BLDC motor control, serial communication and sensors at book length. PDFs are in Korean.Get them free →

This lab is also available in Korean. More labs: all 3D labs.