# Post data to stream and return status def post_data(comfortZone, humidex, humidity, lat, light, lon, name, temp, zip): req = requests.get("http://data.sparkfun.com/input/robqvbvK2DIzzzoZX9Q4?" + "private_key=" + "&comfortzone=" + comfortZone + "&humidex=" + str(humidex) + "&humidity=" + str(humidity) + "&lat=" + str(lat) + "&light=" + str(light) + "&lon=" + str(lon) + "&name=" + name + "&temp=" + str(temp) + "&zip=" + str(zip)) return req.status_code statusCode = 200 while (statusCode == 200): light = lightsensor.readadc(channel, SPICLK, SPIMOSI, SPIMISO, SPICS) humidity, temp = Adafruit_DHT.read_retry(sensor, pin) temp = round(celToFar(temp), 2) humidity = round(humidity, 2) humidex = getHumidex(temp, humidity) comfortZone = getComfortZone(humidex) print light print temp, "F" print humidity, "%" print humidex print comfortZone print "Post Successful!\n" statusCode = post_data(comfortZone, humidex, humidity, lat, light, lon, name, temp, zip)
def run(self): while True: # Adds measure and keep track of num of measurements self.total += readadc(self.pin_num) self.count += 1 time.sleep(self.sleep)
req = requests.get("http://data.sparkfun.com/input/robqvbvK2DIzzzoZX9Q4?" + "private_key=" + "&comfortzone=" + comfortZone + "&humidex=" + str(humidex) + "&humidity=" + str(humidity) + "&lat=" + str(lat) + "&light=" + str(light) + "&lon=" + str(lon) + "&name=" + name + "&temp=" + str(temp) + "&zip=" + str(zip)) return req.status_code statusCode = 200 while(statusCode == 200): light = lightsensor.readadc(channel, SPICLK, SPIMOSI, SPIMISO, SPICS) humidity, temp = Adafruit_DHT.read_retry(sensor, pin) temp = round(celToFar(temp),2) humidity = round(humidity,2) humidex = getHumidex(temp, humidity) comfortZone = getComfortZone(humidex) print light print temp,"F" print humidity,"%" print humidex print comfortZone print "Post Successful!\n" statusCode = post_data(comfortZone, humidex, humidity, lat, light, lon, name, temp, zip)