read temperature from one i2c device and send it as string to another

This commit is contained in:
mandlm 2016-01-25 22:52:24 +01:00
parent c7900baf1d
commit da29c8d56b

22
i2c/ds1621_lcd.py Executable file
View File

@ -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)