The I2C class represents an I²C two-wire serial port, of which the imp contains two. See I² Explained for more background on the I²C bus.

The i2c objects are instantiated at start-up, and are accessed via hardware.i2c12 or hardware.i2c89. Pins 1 and 8 are assigned to each bus' clock line (SCL); pins 2 and 9 are assigned to data (SDA). For more information on the imp modules' pin-outs, see the Pin Mux page.

When implementing I²C using an imp, please note that external pull-ups are required. It is not possible to enable the internal pull-ups when pins are used for I²C.

The i2c object has the following member functions:


Reading an sa56004x temperature sensor.