Terms and conditions
The MCP9808.

This is a small temperature sensor that is more accurate then the TC74, that communicate over the I²C bus.
You need to write the register that you want to read, first to the chip, and then read the desired register.
You cannot read all the registers directly. Look at the description in the datasheet.

Here an example with Basic4Java, running on a raspberry pi.
This is a console application, as JavaFX became unsupported, so it's not possible to make a GUI application. Still you can setup a webserver and show the result via a webpage.
In this example I only print the result to the console.
When working with I²C in B4J, use always a try-catch routine to intercept exceptions, as even an unaccessible I²C device will generate exceptions.

Use always 5K pullup resistors for the SDA and SCL lines.
You can use the internal 3.3Vdc powersupply from the raspberry to power your sensor.


MCP9808 on raspberry pi
Download project file.
You are using the software at your own risk, by downloading you agree with the Terms.