Now we're going to implement simple code that can be used to read TMP102 temperature sensor data through the Raspberry Pi I2C bus 1. Listing 4-2 presents the Java class TemperatureSensor.java, which can be used to read the sensor data from TMP102 with the pi4j library. Add a new Java class file to your project by right-clicking on the IoTDashboard node, and from the context menu, click New|Java Class. Type Temperature Sensor in the Class Name text box and click the Finish button. An empty class file will be added to your project. Type all the lines listed under listing 4-2.
Listing 4-2: TemperatureSensor.java
package com.packt.B05688.chapter4;import com.pi4j.io.i2c.I2CBus;import com.pi4j.io.i2c.I2CDevice; ...