diff --git a/i2c/ds1621_lcd.py b/i2c/ds1621_lcd.py new file mode 100755 index 0000000..5390bb7 --- /dev/null +++ b/i2c/ds1621_lcd.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import smbus +import time + +bus = smbus.SMBus(1) +address = 0x49 + +def getTemp(): + bus.read_byte_data(address, 0xEE) + tempFull = bus.read_byte_data(address, 0xAA) + counter = bus.read_word_data(address, 0xA8) + slope = bus.read_word_data(address, 0xA9) + temp = tempFull - 0.25 + float(slope - counter) / slope + bus.read_byte_data(address, 0x22) + return temp + +while True: + for c in '%9.1f' % round(getTemp(), 1) + ' C': + bus.write_byte(0x23, ord(c)) + time.sleep(1)