read temperature from one i2c device and send it as string to another
This commit is contained in:
parent
c7900baf1d
commit
da29c8d56b
1 changed files with 22 additions and 0 deletions
22
i2c/ds1621_lcd.py
Executable file
22
i2c/ds1621_lcd.py
Executable 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)
|
Loading…
Reference in a new issue