Hi all,
this is quick and dirty, and does not handle exceptions as well as the demo code. but for "fresh meats" with little code experience it's a datum from which to grow...
Code: Select all
# -*- coding: utf-8 -*-
from Phidget22.Devices.TemperatureSensor import *
from Phidget22.Devices.HumiditySensor import *
from Phidget22.Net import *
TempArray = []
HumdArray = []
i = 0
while 1:
i += 1
ct = TemperatureSensor()
ch = HumiditySensor()
try:
ct.openWaitForAttachment(5000)
ch.openWaitForAttachment(5000)
except PhidgetException as e:
break
TempArray.append(ct)
HumdArray.append(ch)
for i in TempArray:
print("Serial: %s Temperature: %0.2f°C" % (i.getDeviceSerialNumber(), i.getTemperature()))
i.close()
print "================="
for i in HumdArray:
print("Serial: %s Humidity: %0.2f%%" % (i.getDeviceSerialNumber(), i.getHumidity()))
i.close()
the output looks like:
Serial: 497393 Temperature: 22.62°C
Serial: 496522 Temperature: 23.29°C
=================
Serial: 497393 Humidity: 31.24%
Serial: 496522 Humidity: 31.74%
Process finished with exit code 0