Lesson 11 – Interfacing with I2C Sensors

Background

This project showcases how to interface to 3 I2C sensors. The OPT3001 digital light sensor, TMP117 temperature sensor and HDC2080 humidity sensor.

Using these sensors is very efficient. You don’t need to worry about signal conditioning.

You simply read out the results via I2C. See the block diagram below for the OPT3001

Figure 1 – Block Diagram of the OPT3001

Operation

The I2C address of each sensor is listed below:

Table 1 – I2C Addresses

Table 2 lists out the hardware connections

Table 2 – Hardware Connections

The Code

For the code, there is 3 different flowcharts for the 3 different sensors. This is because they have different conversion modes

For the OPT3001 and TMP117, it will operate in continuous conversion mode. The resulting data is 16 bits. The first byte is high, the second byte is low.

For the HDC2080, it uses single trigger conversion mode.

The sensor will need to be triggered then the conversion data is ready after 2ms. The conversion data is 2 bytes. First byte high, second is low.

The code has 3 files:

  1. Main
  2. I2C
  3. Source communication
Figure 2 – Code flowchart

The GUI

The GUI presents the conversion data

Figure 3 – The GUI