-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial version of TFHT01 testing script.
- Loading branch information
Showing
5 changed files
with
62 additions
and
530 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/python | ||
|
||
# Python library for SHT3101A MLAB module with SHT31 Temperature and relative humidity sensor. | ||
|
||
#uncomment for debbug purposes | ||
#import logging | ||
#logging.basicConfig(level=logging.DEBUG) | ||
|
||
import time | ||
import datetime | ||
import sys | ||
from pymlab import config | ||
|
||
#### Script Arguments ############################################### | ||
|
||
if len(sys.argv) not in (2, 3): | ||
sys.stderr.write("Invalid number of arguments.\n") | ||
sys.stderr.write("Usage: %s PORT ADDRESS\n" % (sys.argv[0], )) | ||
sys.exit(1) | ||
|
||
port = eval(sys.argv[1]) | ||
|
||
if len(sys.argv) == 3: | ||
address = eval(sys.argv[2]) | ||
else: | ||
address = 0x44 | ||
|
||
#### Sensor Configuration ########################################### | ||
|
||
cfg = config.Config( | ||
i2c = { | ||
"port": port, | ||
"device": 'hid', | ||
}, | ||
bus = [ | ||
{ | ||
"name": "sht", | ||
"type": "sht31", | ||
"address": address, | ||
}, | ||
], | ||
) | ||
|
||
|
||
cfg.initialize() | ||
|
||
print ("SHT31 sensor readout example \r\n") | ||
sensor = cfg.get_device("sht") | ||
|
||
#sensor.soft_reset() # TODO, not implemented in pymlab dev branch. | ||
time.sleep(0.1) | ||
|
||
#### Data Logging ################################################### | ||
|
||
try: | ||
while True: | ||
temperature, humidity = sensor.get_TempHum() | ||
sys.stdout.write("Sensor status: %s, Temperature: %0.2f, Humidity: %0.2f\r\n" % (sensor.get_status(), temperature, humidity)) | ||
sys.stdout.flush() | ||
time.sleep(1) | ||
except KeyboardInterrupt: | ||
sys.exit(0) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.