From dcb5d858551a1a0cd3e4c90c48760cd624994a34 Mon Sep 17 00:00:00 2001 From: LazyAssassin445 Date: Sun, 26 Feb 2017 15:52:57 +0000 Subject: [PATCH] update drySensor function --- modules/hdc1000.py | 5 ++-- modules/testhdc1000.py | 57 ------------------------------------------ 2 files changed, 2 insertions(+), 60 deletions(-) delete mode 100644 modules/testhdc1000.py diff --git a/modules/hdc1000.py b/modules/hdc1000.py index 0885c61..a420f83 100644 --- a/modules/hdc1000.py +++ b/modules/hdc1000.py @@ -38,7 +38,7 @@ def reset(extra = 0): CONFIG_HRES_14 | extra ) - bus.i2c([CONFIG_REG, config >> 8], 0) + bus.i2c([CONFIG_REG, config >> 8, config & 0xff], 0) def temperature(): # Request temperature measurement @@ -68,10 +68,9 @@ def drySensor(): # Take 1000 reading as fast as possible # (the heater is only activated when performing a reading) - for x in range(10000): + for x in range(1000): try: temperature() - time.sleep(0.1) except: pass # Turn off the heater diff --git a/modules/testhdc1000.py b/modules/testhdc1000.py deleted file mode 100644 index 9746117..0000000 --- a/modules/testhdc1000.py +++ /dev/null @@ -1,57 +0,0 @@ -#stributed with a free-will license. -# Use it any way you want, profit or free, provided it fits in the licenses of its associated works. -# HDC1000 -# This code is designed to work with the HDC1000_I2CS I2C Mini Module available from ControlEverything.com. -# https://www.controleverything.com/content/Temperature?sku=HDC1000_I2CS#tabs-0-product_tabset-2 - -import smbus -import time - -# Get I2C bus -bus = smbus.SMBus(1) - -# HDC1000 address, 0x40(64) -# Select configuration register, 0x02(02) -# 0x30(48) Temperature, Humidity enabled, Resolultion = 14-bits, Heater on -bus.write_byte_data(0x40, 0x02, 0x30) - -# HDC1000 address, 0x40(64) -# Send temp measurement command, 0x00(00) -bus.write_byte(0x40, 0x00) - -time.sleep(0.5) - -# HDC1000 address, 0x40(64) -# Read data back, 2 bytes -# temp MSB, temp LSB -data0 = bus.read_byte(0x40) -data1 = bus.read_byte(0x40) - -# Convert the data -temp = (data0 * 256) + data1 -print(hex(temp)) -cTemp = (temp / 65536.0) * 165.0 - 40 -fTemp = cTemp * 1.8 + 32 - -# HDC1000 address, 0x40(64) -# Send humidity measurement command, 0x01(01) -bus.write_byte(0x40, 0x01) - -time.sleep(0.5) - -# HDC1000 address, 0x40(64) -# Read data back, 2 bytes -# humidity MSB, humidity LSB -data0 = bus.read_byte(0x40) -data1 = bus.read_byte(0x40) - -# Convert the data -humidity = (data0 * 256) + data1 -print(hex(humidity)) -humidity = (humidity / 65536.0) * 100.0 - -# Output data to screen -print "Relative Humidity : %.2f %%" %humidity -print "Temperature in Celsius : %.2f C" %cTemp -print "Temperature in Fahrenheit : %.2f F" %fTemp -