picture client side ready
This commit is contained in:
@@ -4,6 +4,7 @@ import requests
|
||||
import Adafruit_DHT
|
||||
import config
|
||||
import RPi.GPIO as GPIO
|
||||
import camera
|
||||
|
||||
# Try to read the state of GPIO_PIN_TANKLEVELx and GPIO_PIN_TANKFULL
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
@@ -42,6 +43,10 @@ stopPumpingAt = config.STOP_PUMPING_AT
|
||||
# to 15 times to get a sensor reading (waiting 2 seconds between each retry).
|
||||
humidity, temperature = Adafruit_DHT.read_retry(SENSOR_TYPE, config.GPIO_PIN_DHT)
|
||||
|
||||
picture_base64 = camera.get_transfer_picture_base64()
|
||||
if picture_base64 is not None:
|
||||
camera.remove_transfer_picture()
|
||||
|
||||
# Un-comment the line below to convert the temperature to Fahrenheit.
|
||||
# temperature = temperature * 9/5.0 + 32
|
||||
|
||||
@@ -51,7 +56,8 @@ humidity, temperature = Adafruit_DHT.read_retry(SENSOR_TYPE, config.GPIO_PIN_DHT
|
||||
# If this happens try again!
|
||||
if tankFull is not None:
|
||||
response = requests.post(config.SENSORDATA_URL, json={"owner": owner, "temperatureValue": temperature, "humidityValue":humidity, "tankLevel0": "1" if tankLevel0 else "0","tankLevel1": "1" if tankLevel1 else "0","tankLevel2": "1" if tankLevel2 else "0","tankLevel3": "1" if tankLevel3 else "0", "tankLevel4": "1" if tankLevel4 else "0", "tankFull": "1" if tankFull else "0",
|
||||
"startPumpingAt": startPumpingAt,"stopPumpingAt": stopPumpingAt,"controllerId": controller_id
|
||||
"startPumpingAt": startPumpingAt,"stopPumpingAt": stopPumpingAt,"controllerId": controller_id,
|
||||
'picture': picture_base64
|
||||
})
|
||||
print 'Temp={0:0.1f}*C'.format(temperature)
|
||||
print 'Humidity={0:0.1f}%'.format(humidity)
|
||||
|
||||
Reference in New Issue
Block a user