fixed python
This commit is contained in:
@@ -17,4 +17,4 @@ PICTURE_TRANSFER_FILE='/mnt/zoblakdata/picture_transfer_ready.jpg'
|
|||||||
PICTURE_INPUT_FILE='/mnt/zoblakdata/picture.jpg' # must match file in PICTURE_COMMAND
|
PICTURE_INPUT_FILE='/mnt/zoblakdata/picture.jpg' # must match file in PICTURE_COMMAND
|
||||||
PICTURE_COMMAND="""avconv -i rtsp://192.168.5.10:554//user=admin_password=_channel=1_stream=0.sdp -i /home/pi/projects/tfm/controller/zoblakLogo.png -filter_complex "[0:v]drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:fontsize=30:box=1:boxcolor=black@0.75:text='%d\.%m\.%Y\. %H\:%M\:%S':fontcolor=white@0.8: x=10: y=10[text]; [text][1:v]overlay=main_w-overlay_w-5:5 [filtered]" -map "[filtered]" -f image2 -vframes 1 /mnt/zoblakdata/picture.jpg""" # filename must match PICTURE_INPUT_FILE path
|
PICTURE_COMMAND="""avconv -i rtsp://192.168.5.10:554//user=admin_password=_channel=1_stream=0.sdp -i /home/pi/projects/tfm/controller/zoblakLogo.png -filter_complex "[0:v]drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:fontsize=30:box=1:boxcolor=black@0.75:text='%d\.%m\.%Y\. %H\:%M\:%S':fontcolor=white@0.8: x=10: y=10[text]; [text][1:v]overlay=main_w-overlay_w-5:5 [filtered]" -map "[filtered]" -f image2 -vframes 1 /mnt/zoblakdata/picture.jpg""" # filename must match PICTURE_INPUT_FILE path
|
||||||
PICTURE_URL = 'http://agrar.zoblak.com/api/v1.0/picture'
|
PICTURE_URL = 'http://agrar.zoblak.com/api/v1.0/picture'
|
||||||
ONE_WIRE_TERMO_SENSORS = ['/dev/sys/bus/w1/devices/xxx/w1_slave'] # xxx is a serial number
|
ONE_WIRE_THERMO_SENSORS = ['/dev/sys/bus/w1/devices/xxx/w1_slave'] # xxx -serial
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import requests
|
|||||||
import Adafruit_DHT
|
import Adafruit_DHT
|
||||||
import config
|
import config
|
||||||
import RPi.GPIO as GPIO
|
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
|
# Try to read the state of GPIO_PIN_TANKLEVELx and GPIO_PIN_TANKFULL
|
||||||
GPIO.setmode(GPIO.BCM)
|
GPIO.setmode(GPIO.BCM)
|
||||||
@@ -46,13 +46,18 @@ humidity, temperature = Adafruit_DHT.read_retry(SENSOR_TYPE, config.GPIO_PIN_DHT
|
|||||||
temperatures = []
|
temperatures = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
temperatures = onewire.read_many_thermo(config.ONE_WIRE_TERMO_SENSORS)
|
temperatures = onewire.read_many_thermo(config.ONE_WIRE_THERMO_SENSORS)
|
||||||
except:
|
except:
|
||||||
print("onewire thermo error:", sys.exc_info()[0])
|
print("onewire thermo error:", sys.exc_info()[0])
|
||||||
|
|
||||||
# Un-comment the line below to convert the temperature to Fahrenheit.
|
# Un-comment the line below to convert the temperature to Fahrenheit.
|
||||||
# temperature = temperature * 9/5.0 + 32
|
# 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
|
# Note that sometimes you won't get a reading and
|
||||||
# the results will be null (because Linux can't
|
# the results will be null (because Linux can't
|
||||||
# guarantee the timing of calls to read the sensor).
|
# 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,
|
"startPumpingAt": startPumpingAt,"stopPumpingAt": stopPumpingAt,"controllerId": controller_id,
|
||||||
"temperatures": temperatures
|
"temperatures": temperatures
|
||||||
})
|
})
|
||||||
print 'Temp={0:0.1f}*C'.format(temperature)
|
|
||||||
print 'Humidity={0:0.1f}%'.format(humidity)
|
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
print 'Failed to send temperature!'
|
print 'Failed to send temperature!'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user