Skip to main content

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​

ParameterFormatDescription
addr77-bit hex (e.g. 0x48)Device's 7-bit I2C address
reghex (e.g. 0x01)Register to write to
datahex byte arrayOne or more bytes to write

I2C read parameters​

ParameterFormatDescription
addr77-bit hex (e.g. 0x48)Device's 7-bit I2C address
reghex (e.g. 0x00)Register to read from
len1–4Number of bytes
variableany declared variableDestination; 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.