I2COpen (Set up I2C)

The I2COpen instruction sets up the datalogger for Inter-Integrated Circuit (I2C) communications.

NOTE: Campbell Scientific documentation has been updated to replace legacy industry terms with modern terminology. Controller-peripheral are now used to describe I2C communications. The I2C controller initiates communications and makes requests of peripheral device(s). Peripheral devices process requests and return an appropriate response.

Syntax

I2COpen ( BeginPort, BitRate )

Remarks

I2C uses two bidirectional open-drain lines, the Serial Data Line (SDA) and Serial Clock Line (SCL) pulled up with resistors. By definition, I2C is a Multi-Controller, Multi-Peripheral communication interface; however the datalogger only supports Single-Controller, Muti-Peripheral configurations. The datalogger provides pull-ups to allow communications, but the pull resistors are not strong enough for high speed communications. If higher speeds are required, external pull-up resistors will be necessary. The datalogger does not support “clock stretching”, where the peripheral can slow down the clock by holding the SCL line low. However, the BitRate parameter can be used to slow or speed up the clock.

NOTE: A prior understanding of the operation and details of the I2C protocol is assumed.

I2COpen must be declared prior to using I2CRead or I2CWrite.

Parameters

BeginPort (Begin Port)

Specifies the beginning port used for the two signals for I2C communications. The first port is the clock signal and the next higher port is used for the data signal. Valid options are C1, C3, U1, U3, U5, U7, U9, and U11.

Type: Constant

BitRate (Bit Rate)

The bit rate, in Hertz, to use for communications.

Type: Constant

NOTE: The datalogger's 100k ohm pull-up resistors are too weak for communication at the standard clock frequency of 100kHz. Therefore, to run at faster speeds, an external pull-up resistor should be added. The external resistor can either be pulled to the +5V supply on the terminal blocks or it can be pulled high by another control port that is not being used for the I2C function. The control port (Cx) can be configured to drive at either +5V or +3.3V with the PortPairConfig() instruction. The external pull-up resistor should be sized appropriately for the speed and capacitance of the cable. Refer to the following graph to determine the appropriate external pullup resistor size.