|Top Previous Next|
Allows external devices to be controlled via the I²C bus, also called Two-Wire Interface or SMBus.
WebCell pins C0 and C1 can be configured as an I²C bus master. Pin C0 is serial data (SDA) and pin C1 is serial clock (SCL). Per the I²C bus specification, each pin needs a pull-up resistor to the 3.3V power supply.
Multiple I²C devices can be connected to the bus. Each device should have a unique address. The address is typically set by manufacturer of the device, but can sometimes be altered with pin connections. Note that the address is a 7-bit value occupying the most-significant bits of the byte; bit 0 of the address byte is not used.
The I²C bus is enabled by setting the bitRate property to a positive value. Setting the bitRate property to zero disables the I²C bus and allows the corresponding pins to be used for other functions. Most I²C devices operate at 400 kHz although some use 100 kHz. You must check the specifications of the devices you connect and use the lowest rate.
Data is transferred on the bus using the writeRead function. This function allows data to be both transmitted and then received in the same transaction.