Version to support the reading if the tank is full (BCM GPIO 20 used)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
GPIO_PIN_DHT = 4 # BCM
|
||||
SENSORDATA_URL = 'http://tfm.meteor.com/api/sensorData'
|
||||
GPIO_PIN_TANKFULL = 20 # BCM
|
||||
GPIO_PIN_VALVE = 21 # BCM
|
||||
API_BASE_URL = 'http://tfm.meteor.com/api'
|
||||
CONTROLLER_ID = '120' # every controller must have a different one
|
||||
|
||||
@@ -3,8 +3,17 @@ import sys
|
||||
import requests
|
||||
import Adafruit_DHT
|
||||
import config
|
||||
import config
|
||||
import RPi.GPIO as GPIO
|
||||
|
||||
# Try to read the state of GPIO_PIN_TANKFULL
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setup(config.GPIO_PIN_TANKFULL, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||
tankFull = GPIO.input(config.GPIO_PIN_TANKFULL)
|
||||
GPIO.cleanup()
|
||||
print 'Bacva puna: {}'.format(tankFull)
|
||||
|
||||
# Go on to DHT
|
||||
SENSOR_TYPE = Adafruit_DHT.DHT11
|
||||
|
||||
if len(sys.argv) == 3:
|
||||
@@ -27,7 +36,7 @@ humidity, temperature = Adafruit_DHT.read_retry(SENSOR_TYPE, config.GPIO_PIN_DHT
|
||||
# guarantee the timing of calls to read the sensor).
|
||||
# If this happens try again!
|
||||
if temperature is not None and humidity is not None:
|
||||
response = requests.post(config.SENSORDATA_URL, json={"owner": owner, "temperatureValue": temperature, "humidityValue":humidity})
|
||||
response = requests.post(config.SENSORDATA_URL, json={"owner": owner, "temperatureValue": temperature, "humidityValue":humidity, "tankFull":tankFull})
|
||||
print 'Temp={0:0.1f}*C'.format(temperature)
|
||||
print 'Humidity={0:0.1f}%'.format(humidity)
|
||||
if response.status_code != 200:
|
||||
|
||||
Reference in New Issue
Block a user