I'm not having much success. I believe this is because I'm messing up the swapping of the least significant bit and most significant bit.
- Code: Select all | TOGGLE FULL SIZE
from Adafruit_I2C import Adafruit_I2C
class TMP102 :
i2c = None
def __init__(self, address=0x48, mode=1, debug=False):
self.i2c = Adafruit_I2C(address)
self.address = address
self.debug = debug
# Make sure the specified mode is in the appropriate range
if ((mode < 0) | (mode > 3)):
print "Invalid Mode: Using STANDARD by default"
self.mode = self.__BMP085_STANDARD
self.mode = mode
"Reads the raw (uncompensated) temperature from the sensor"
raw = self.i2c.readU16(0x48) #The TMP102 returns 12-bits, I think
raw = self.i2c.reverseByteOrder(raw) #I need to get the bit order reveresed
print "DBG: Raw Temp: 0x%04X (%d)" % (raw & 0xFFFF, raw)
"Gets the compensated temperature in degrees celcius"
RawBytes = self.readRawTemp() #get the temp from readRawTemp (above)
temp = float(RawBytes) *0.0625 #this is the conversion value from the data sheet.
print "DBG: Calibrated temperature = %f C" % temp
This doesn't look like it is too complicated. That being said, i've been plugging away at this for hours. If anyone has any ideas, I'm more than happy to try them.
I'm getting values that change with the temp, but they're incredibly high.