Mercurial > templog
diff web/test.py @ 75:ca08442635ca
report raw ds18b20 values instead
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 03 Jul 2012 22:44:21 +0800 |
parents | 048143905092 |
children |
line wrap: on
line diff
--- a/web/test.py Tue Jul 03 21:55:50 2012 +0800 +++ b/web/test.py Tue Jul 03 22:44:21 2012 +0800 @@ -1,5 +1,12 @@ #!/usr/bin/env python -import log import time +import struct +import sys +import binascii -log.sensor_update("test1", [22,22,22.1,22.4,22.5], time.time() - 10, 300) +def convert_ds18b20_12bit(reading): + value = struct.unpack('>h', binascii.unhexlify(reading))[0] + return value * 0.0625 + +if __name__ == '__main__': + print convert_ds18b20_12bit(sys.argv[1])