Wowwee MIP Movement Panel icon Wowwee MIP Movement Panel — UART-based EZ-B/ESP32 skill to control WowWee MIP, enabling ESP32-Cam camera support and flexible battery-powered integration. Try it →
 

I2C

Talk to I2C devices connected to an EZB, such as sensors, displays and expansion boards. Each device has an address; write bytes or text to it and read bytes back. The clock speed sets how fast the I2C bus runs.

Where to find it: type I2C. in a Python script, or open the ARCx API view of the script editor and expand I2C


Commands

Command What it does
I2C.Read Reads the given number of bytes from an I2C device on the first EZB, waiting until they arrive.
I2C.ReadByte Reads one byte from an I2C device on the first EZB.
I2C.ReadString Reads the given number of bytes from an I2C device on the first EZB and returns them as ASCII text.
I2C.SetClockSpeed Sets the I2C bus clock speed on the first EZB.
I2C.Write Writes one byte to an I2C device on the first EZB.
I2C.WriteString Writes text as ASCII to an I2C device on the first EZB.

Details

I2C.Read

Reads the given number of bytes from an I2C device on the first EZB, waiting until they arrive. Gives zeros if the EZB is not connected.

I2C.Read(address, bytesToExpect)
I2C.Read(address, bytesToExpect, ezbIndex)
Value Type What it is
address int The device's 7 bit I2C address, such as 0x1D.
bytesToExpect int How many bytes to read, up to 255.
ezbIndex int Optional. Which EZB to use, 0 being the first one.

Gives back: list[int]. The bytes read.

I2C.ReadByte

Reads one byte from an I2C device on the first EZB. Gives zeros if the EZB is not connected.

I2C.ReadByte(address)
I2C.ReadByte(address, ezbIndex)
Value Type What it is
address int The device's 7 bit I2C address, such as 0x1D.
ezbIndex int Optional. Which EZB to use, 0 being the first one.

Gives back: int. The byte read, 0 to 255.

I2C.ReadString

Reads the given number of bytes from an I2C device on the first EZB and returns them as ASCII text. The script waits until the bytes arrive.

I2C.ReadString(address, bytesToExpect)
I2C.ReadString(address, bytesToExpect, ezbIndex)
Value Type What it is
address int The device's 7 bit I2C address, such as 0x1D.
bytesToExpect int How many bytes to read, up to 255.
ezbIndex int Optional. Which EZB to use, 0 being the first one.

Gives back: str. The received text.

I2C.SetClockSpeed

Sets the I2C bus clock speed on the first EZB. An error is raised if the EZB's firmware cannot change it.

I2C.SetClockSpeed(speed)
I2C.SetClockSpeed(speed, ezbIndex)
Value Type What it is
speed int The clock speed in hertz, such as 100000 for 100 kHz.
ezbIndex int Optional. Which EZB to use, 0 being the first one.

I2C.Write

Writes one byte to an I2C device on the first EZB. Nothing is sent if the EZB is not connected.

I2C.Write(address, @byte)
I2C.Write(address, byteArray)
I2C.Write(address, @byte, ezbIndex)
I2C.Write(address, byteArray, ezbIndex)
Value Type What it is
address int The device's 7 bit I2C address, such as 0x1D.
byteArray object Only in some forms. The bytes to write, as a bytearray.
ezbIndex int Only in some forms. Which EZB to use, 0 being the first one.
@byte int Only in some forms.
  • I2C.Write(address, @byte): Writes one byte to an I2C device on the first EZB. Nothing is sent if the EZB is not connected.
  • I2C.Write(address, byteArray): Writes bytes to an I2C device on the first EZB. Between 1 and 255 bytes can be sent; an empty or longer array raises an error.
  • I2C.Write(address, @byte, ezbIndex): Writes one byte to an I2C device on the chosen EZB. Nothing is sent if the EZB is not connected.
  • I2C.Write(address, byteArray, ezbIndex): Writes bytes to an I2C device on the chosen EZB. Between 1 and 255 bytes can be sent; an empty or longer array raises an error.

I2C.WriteString

Writes text as ASCII to an I2C device on the first EZB. Between 1 and 255 characters can be sent; empty or longer text raises an error.

I2C.WriteString(address, str)
I2C.WriteString(address, str, ezbIndex)
Value Type What it is
address int The device's 7 bit I2C address, such as 0x1D.
str str The text to write.
ezbIndex int Optional. Which EZB to use, 0 being the first one.