I2C Bus
The I2C palette group allows direct communication with devices on the I2C bus. Useful for ADCs, temperature sensors, multiplexers, or any I2C peripheral.
Block Reference
I2C
I2C writeaddr0x48reg0x01data[0x60, 0xA0]
I2C
I2C readaddr0x48reg0x00len2→raw_val
Both blocks work in Setup and Loop.
I2C write parameters
| Parameter | Format | Description |
|---|---|---|
| addr7 | 7-bit hex (e.g. 0x48) | Device's 7-bit I2C address |
| reg | hex (e.g. 0x01) | Register to write to |
| data | hex byte array | One or more bytes to write |
I2C read parameters
| Parameter | Format | Description |
|---|---|---|
| addr7 | 7-bit hex (e.g. 0x48) | Device's 7-bit I2C address |
| reg | hex (e.g. 0x00) | Register to read from |
| len | 1–4 | Number of bytes |
| variable | any declared variable | Destination; bytes packed as little-endian int32 |
Example — Temperature Sensor
SETUP
I2C
I2C writeaddr0x48reg0x01data[0x60, 0xA0]
LOOP ~1 kHz
I2C
I2C readaddr0x48reg0x00len2→temp_raw
Debug
log variabletemp_raw
Discovering Device Addresses
Use the SCAN_I2C command from the UDP Commands panel to list all connected I2C devices and their 7-bit addresses. See SCAN_I2C.