本文整理匯總了Python中protocol.Protocol.getHumidity方法的典型用法代碼示例。如果您正苦於以下問題:Python Protocol.getHumidity方法的具體用法?Python Protocol.getHumidity怎麽用?Python Protocol.getHumidity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類protocol.Protocol
的用法示例。
在下文中一共展示了Protocol.getHumidity方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: print
# 需要導入模塊: from protocol import Protocol [as 別名]
# 或者: from protocol.Protocol import getHumidity [as 別名]
print ('Trying with serial_port = ' + serialPort + ' and serial_speed = ' + str(baudRate))
else:
print ('Command line: getweather.py serial_port serial_speed')
sys.exit(1)
currenttime = time.time()
db = DBHelper(dbFileName)
device = Protocol(serialPort, baudRate, logEnabled)
if device.ping(deviceAddress):
pressure, sernumP = device.getPressure(deviceAddress)
if 10 < pressure < 1000:
print ('Pressure - ' + str(pressure) + ' mmHg')
pressureSensorId = db.getSensorId(pressureSensorType, sernumP)
db.storeValue(currenttime, pressure, pressureSensorId)
humidity, sernumH = device.getHumidity(deviceAddress)
if not math.isnan(humidity):
print ('Humidity - ' + str(humidity) + '%')
humiditySensorID = db.getSensorId(humiditySensorType, sernumH)
db.storeValue(currenttime, humidity, humiditySensorID)
values = device.getTemp(deviceAddress)
i = 1
for (temperature, sn) in values:
print ('T' + str(i) + ' - ' + "%.1f" % temperature + ' C, sensor'),
device.printPacket(sn)
i += 1
termSensorId = db.getSensorId(termSensorType, sn)
db.storeValue(currenttime, temperature, termSensorId)
device.close()
db.updateAvgTables()
db.updateAllRecordsView()