I’ve updated this guide today (02 May 2022) with additional information about using multiple sensors, and images of the most recent design revision (hardware v12).
3 Likes
This C code works fine on a standard Raspian install, compile as shown:
#include <pigpio.h>
#include <stdio.h>
//
#define DeviceAddress 0x48
#define TempReg 0x00
#define I2CBus 1
#define SetConfig 0x01
#define ConfigReg 0x60A0
//
// gcc tmp117read.c -o tmp117read -lpigpio
//
int main(void)
{
gpioInitialise();
int handle = i2cOpen(I2CBus, DeviceAddress, 0);
char buf [10] ;
if (!(handle < 0)) {
i2cWriteWordData(handle, SetConfig, ConfigReg);
i2cWriteByte(handle, TempReg);
i2cReadI2CBlockData(handle, TempReg,buf,2);
float f = ((int8_t) buf[0] << 8 | buf[1]) * 0.0078125f;
printf("Temperature = %5.2f celsius\n", f);
}
gpioTerminate();
}
1 Like
Nice contribution @Mike155258
I’m sure there are TMP117 libraries available in Arduino, but it’s great to see a low-level implementation in just a few lines!
The TMP117 is one of those beautiful devices that doesn’t require any babysitting, just read from the one register and you have what you need