Wire (I2C)

setSpeed()

Sets the I2C clock speed. This is an optional call (not from the original Arduino specs.) and must be called once before calling begin(). The default I2C clock speed is 100KHz and the maximum clock speed is 400KHz.

// SYNTAX
Wire.setSpeed(clockSpeed);
Wire.begin();

// PROTOTYPE
void setSpeed(uint32_t);

Parameters:

  • clockSpeed: CLOCK_SPEED_100KHZ or CLOCK_SPEED_400KHZ, see notes below.

Gen 4 Devices (RTL872x) (P2, Photon 2, and M-SoM):

On Gen 4 devices, CLOCK_SPEED_100KHZ or CLOCK_SPEED_400KHZ are supported on all version of Device OS.

In Device OS 6.3.5 and later, you can also specify an arbitrary frequency between 10 KHz and 99 KHZ, in addition to CLOCK_SPEED_100KHZ and CLOCK_SPEED_400KHZ.

Gen 3 Devices (nRF52) (B-Series SoM, Tracker SoM, Tracker One, Boron, Argon, and E404X):

On Gen 3 devices, CLOCK_SPEED_100KHZ or CLOCK_SPEED_400KHZ are supported on all version of Device OS.

In Device OS 6.3.5 and later, you can also specify an arbitrary frequency between 10 KHz and 99 KHZ, in addition to CLOCK_SPEED_100KHZ and CLOCK_SPEED_400KHZ.

Gen 2 Devices (STM32) (E-Series, Electron, Photon, and P1; does not include E404X):

On Gen 2 devices, a user-specified frequency can be used.