The bus
The Uno (the controller) and an MCP9808 temperature sensor (a target) share two wires: SDA for data, SCL for the clock. Pull-up resistors hold both at 5 V; a chip can only pull a wire low. The sensor answers to address 0x18.
Wire.beginTransmission() only fills a buffer in RAM. endTransmission() sends it, and every transfer begins with START: the Uno pulls SDA low while SCL is still high. Every chip on the bus starts listening.
The address 0x18 is seven bits: 0011000. Wire shifts it left and adds R/W = 0 for write, making 0x30. Eight bits go out, most significant first, one per SCL pulse. A lit lamp is 1: SDA left high.
On a ninth clock pulse the Uno lets go of SDA. The sensor recognises its address and pulls SDA low: that low bit is the ACK, meaning "I am here, go on". If no chip pulls, SDA stays high: a NACK.
Reading a register
Inside, the sensor keeps numbered registers. Wire.write(0x05) sends the register pointer: 0x05 is T_A, the ambient temperature. The sensor stores the number and ACKs again. Nothing is read yet.
endTransmission(false) ends with a repeated START instead of a STOP, so the Uno keeps the bus. requestFrom(ADDR, 2) sends the address again with R/W = 1: 0x31. The sensor ACKs and gets ready to talk.
Now the sensor drives SDA: 0xC1, then 0x74. The Uno ACKs the first byte to ask for more, and NACKs the last to say "enough". Then STOP: SDA rises while SCL is high, and the bus is free.
The top three bits of hi are alarm flags (two are set: the limits start at 0). hi & 0x1F clears them: 0x01. lo is 0x74 = 116. t = 1 × 16 + 116 / 16 = 16 + 7.25 = 23.25 °C.
Finding a bug
A common slip: copying 0x30, the 8-bit write byte, as the address. Wire shifts it again and sends 0x60. No chip has address 0x30, so SDA stays high on the ninth clock: NACK. endTransmission returns 2.
A logic analyser decodes the two wires: "S 0x30 W NACK". Wire wants the 7-bit address, so ADDR must be 0x18. Fixed, the analyser shows ACKs again and the sketch prints 23.25.
What happens
;; step 1/10 · bus controller Arduino Uno R3 (ATmega328P) target MCP9808, address 0x18 = 0011000 SDA pin A4 data, both directions SCL pin A5 clock, from the controller pull-ups keep both wires high when idle open drain chips pull low or let go, never drive high
The card shows only the read. The whole sketch also calls Wire.begin() in setup(), checks the value endTransmission() returns, converts the two bytes and prints the temperature once a second. The MCP9808 compares each reading with three limit registers (critical, upper and lower), which are 0 at power on. A room above 0 °C is therefore at or above T_CRIT and above T_UPPER, so bits 15 and 14 of T_A read 1 until you set real limits. Below 0 °C the sign bit (0x10 in hi) is set and the sketch subtracts 256.