Create I2C communications

The DAQ module provides a dedicated I2C port, making it easy to interface an application with a variety of I2C-compliant sensors. The I2C interface is accessed using simple Read and Write functions, with up to 255 bytes per transfer. I2C bus speeds up to 400kHz are supported.

I2C Interface:

void I2C.Write(Speed speed, UInt16 address, byte[] buffer, int offset = 0, UInt16 length = 0): sends a byte array to the I2C device @ 'address' using the specified bus speed. Optionally, an offset into the byte array and a buffer length can be specified.
void I2C.Read(Speed speed, UInt16 address, byte[] buffer, int offset = 0, UInt16 length = 0): receives a byte array from the I2C device @ 'address' using the specified bus speed. Optionally, an offset into the byte array and a buffer length can be specified.
bool I2C.IsBusBusy(): returns 'true' if the I2C bus is in use (i.e. a transfer is ongoing) and 'false' otherwise.
void I2C.BusReset(): resets the DAQ's hardware interface with the I2C bus.
Sensor Library

See the "\Library\Nwazet.Go.DAQ\Sensors" folder for drivers currently provided with the DAQ module.

Connecting I2C Sensors to the DAQ module

The easiest method of connecting I2C sensors equipped with standard 0.1" male pin headers, such as Adafruit sensor breakout boards, is to use a small breadboard and jumper wires. Each sensor exposes at least the following pins: SDA (data), SCL (clock), power (VCC) and ground (GND). Using jumper wires, respectively string together the SDA, SCL, power and ground pins across all sensors and terminate the connections at the DAQ's I2C connector. Power the sensors using either 3.3v or 5v taken from a power rail connected to the DAQ's digital I/O connectors (D0-D7). Avoid mixing I2C sensors with different power requirements on the same bus unless you know exactly what you're doing. For the sake of simplicity, the sensors that we support all work with 3.3v.

Note about Sensirion sensors

Sensirion uses a proprietary variant of the I2C protocol, which we do not support at this time. However, there are alternatives to Sensirion sensors, with comparable specifications and 100% I2C-compliant. Given the choice, we prefer supporting manufacturers who respect standards and inter-operability.

Example driver

The following sample shows the I2C driver written for the Honeywell HumidIcon Digital Humidity/Temperature sensor (HIH613x), along with the application using it.

Sample Output

Temp: 19 Celsius
Humidity: 60 %