def __init__(self, owmApiKey, owmLocation='Sydney, au', cacheSeconds=60): self.openWeather = owm.Weather(owmApiKey, owmLocation) self.sensorLocation = owmLocation self.id = 0
import iothub_client from iothub_client import * import time import sys sys.path[0:0] = [ '../common' ] ## path to shared owm.py (open weather map) and iothub.py (azure iot hub python) files import owm import iothub sensorLocation = "Sydney" owmLocation = 'Sydney,AU' iothubConnectionString = 'HostName=IoTCampAU.azure-devices.net;DeviceId=UbuntuPython34;SharedAccessKey=32JQMI0quRp69GEosVSUF2tkdq5r0nzi2lPAn1rZckY=' openWeather = owm.Weather('c204bb28a2f9dc23925f27b9e21296dd', owmLocation) iot = iothub.IotHub(iothubConnectionString) msg_txt = "{\"Geo\":\"%s\",\"Humidity\":%d,\"HPa\":%d,\"Celsius\": %.2f,\"Light\":%d,\"Id\":%d}" def callback(message, properties): print(message) print("Properties: %s" % properties) def iothub_client_sample_run(): id = 0 iot.initialise(callback) while True: