fixed python

This commit is contained in:
Senad Uka
2016-10-29 17:57:26 +02:00
parent 16bf8c8f3e
commit f93f1cbe13
2 changed files with 9 additions and 5 deletions

View File

@@ -4,7 +4,7 @@ import requests
import Adafruit_DHT
import config
import RPi.GPIO as GPIO
import onewire
import drivers.onewire as onewire
# Try to read the state of GPIO_PIN_TANKLEVELx and GPIO_PIN_TANKFULL
GPIO.setmode(GPIO.BCM)
@@ -46,13 +46,18 @@ humidity, temperature = Adafruit_DHT.read_retry(SENSOR_TYPE, config.GPIO_PIN_DHT
temperatures = []
try:
temperatures = onewire.read_many_thermo(config.ONE_WIRE_TERMO_SENSORS)
temperatures = onewire.read_many_thermo(config.ONE_WIRE_THERMO_SENSORS)
except:
print("onewire thermo error:", sys.exc_info()[0])
# Un-comment the line below to convert the temperature to Fahrenheit.
# temperature = temperature * 9/5.0 + 32
print 'Temp={0:0.1f}*C'.format(temperature)
print 'Humidity={0:0.1f}%'.format(humidity)
print 'onewire temp:'
print temperatures
# Note that sometimes you won't get a reading and
# the results will be null (because Linux can't
# guarantee the timing of calls to read the sensor).
@@ -68,8 +73,7 @@ if tankFull is not None:
"startPumpingAt": startPumpingAt,"stopPumpingAt": stopPumpingAt,"controllerId": controller_id,
"temperatures": temperatures
})
print 'Temp={0:0.1f}*C'.format(temperature)
print 'Humidity={0:0.1f}%'.format(humidity)
if response.status_code != 200:
print 'Failed to send temperature!'