Skip to content

Commit

Permalink
intento de fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dschlimovich committed Jul 27, 2018
1 parent 01de6d4 commit 805e7ba
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
import math
import time
import threading

import primer_funcion
import segunda_funcion
Expand All @@ -19,6 +20,8 @@
datos=primer_funcion.funcion_uno()
segunda_funcion.escribe(idExp,datos)
print('Termino la iteracion: '+str(i))
time.sleep(interavalo_seg)
#time.sleep(interavalo_seg)
print('Salio del For')


#sys.exit()
Binary file not shown.
Binary file not shown.
Binary file not shown.
113 changes: 59 additions & 54 deletions Funciones para medicion - Parte hardware/mediciones.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,69 +6,74 @@
import Adafruit_DHT
def medir_temperatura(Carpeta_Sensor):

#la onda aca es que pasandome la el sensor que quiere medir yo le devuelvo el valor que tiene
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
# Deberiamos cargar este vector con cada ID correspondiente de los sensores
#Cargamos la ruta donde se encuentra nuestro sensor.
#ruta_sensores = '/sys/bus/w1/devices/'
#Carpeta_Sensor = glob.glob( ruta_sensores + id_sensor)[0]
#print(Carpeta_Sensor)
fSensor = open(Carpeta_Sensor + '/w1_slave', 'r')
linSensor = fSensor.readlines()
fSensor.close()
#la onda aca es que pasandome la el sensor que quiere medir yo le devuelvo el valor que tiene
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
# Deberiamos cargar este vector con cada ID correspondiente de los sensores
#Cargamos la ruta donde se encuentra nuestro sensor.
#ruta_sensores = '/sys/bus/w1/devices/'
#Carpeta_Sensor = glob.glob( ruta_sensores + id_sensor)[0]
#print(Carpeta_Sensor)
fSensor = open(Carpeta_Sensor + '/w1_slave', 'r')
linSensor = fSensor.readlines()
fSensor.close()

posTemp = linSensor[1].find('t=')
# Si la posicion es valida
if posTemp != -1:
# Anadimos son posiciones mas por t=
strTemp = linSensor[1][posTemp+2:]
# Calculamos la temperatura real
temperatura = float(strTemp) / 1000.0
posTemp = linSensor[1].find('t=')
# Si la posicion es valida
if posTemp != -1:
# Anadimos son posiciones mas por t=
strTemp = linSensor[1][posTemp+2:]
# Calculamos la temperatura real
temperatura = float(strTemp) / 1000.0

return temperatura
return temperatura

def medir_ph():
# Me devuelve un array de dos valores. Primero el valor de temperatura. Segundo el valor de pH
# Me devuelve un array de dos valores. Primero el valor de temperatura. Segundo el valor de pH

calibration=21.7 ### VER SI ESTE VALOR NO CONVIENE PASARLO POR PARAMETRO osea VER COMO VAMOS A MANEJAR LA CALIBRACION
board=pyfirmata.Arduino("/dev/ttyACM0") #Puerto serial x el q la raspi lee el arduino, cambia con las conexiones
pin0=board.get_pin('a:0:i')
calibration=21.7 ### VER SI ESTE VALOR NO CONVIENE PASARLO POR PARAMETRO osea VER COMO VAMOS A MANEJAR LA CALIBRACION
board=pyfirmata.Arduino("/dev/ttyACM0") #Puerto serial x el q la raspi lee el arduino, cambia con las conexiones
pin0=board.get_pin('a:0:i')

iterator = pyfirmata.util.Iterator(board)
iterator.start()
pin0.enable_reporting()
buf=[]
time.sleep(1)
for i in range(10):
#print( "i : " + str(i) )
buf.append(pin0.read())
#print("valor sensado: " + str(buf[i]))
time.sleep(0.03)
iterator = pyfirmata.util.Iterator(board)
iterator.start()
try:
pin0.enable_reporting()
buf=[]
time.sleep(1)
for i in range(10):
#print( "i : " + str(i) )
buf.append(pin0.read())
#print("valor sensado: " + str(buf[i]))
time.sleep(0.03)
finally:
pin0.disable_reporting()
board.exit()
iterator=None

for i in range(9):
for j in range(i+1,10):
#print("i: " + str(i) + " j: " + str(j))
if buf[i] > buf[j]:
temp = buf[i]
buf[i]=buf[j]
buf[j]=temp
for i in range(9):
for j in range(i+1,10):
#print("i: " + str(i) + " j: " + str(j))
if buf[i] > buf[j]:
temp = buf[i]
buf[i]=buf[j]
buf[j]=temp

avgValue=0
for i in range(2,8):
avgValue += buf[i]
avgValue=0
for i in range(2,8):
avgValue += buf[i]

phVol=avgValue*5.0/6
phValue=-5.7 * phVol + calibration
phVol=avgValue*5.0/6
phValue=-5.7 * phVol + calibration

pin0.disable_reporting()
return phValue
return phValue

def medir_amb(tipo_sensor):
#tipo de sensor es 11 o 22
#humidity,temperature = Adafruit_DHT.read_retry(22,21)
humidity,temperature = Adafruit_DHT.read_retry(tipo_sensor,21)
return humidity,temperature
#tipo de sensor es 11 o 22
#humidity,temperature = Adafruit_DHT.read_retry(22,21)
humidity,temperature = Adafruit_DHT.read_retry(tipo_sensor,21)
return humidity,temperature
Binary file not shown.
1 change: 1 addition & 0 deletions Funciones para medicion - Parte hardware/primer_funcion.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def funcion_uno():
datos.append(-1000)

ph = mediciones.medir_ph()
#ph=-69
datos.append(ph) # ver que esto funcione

hum_amb, temp_amb = mediciones.medir_amb(11)
Expand Down
Binary file not shown.

0 comments on commit 805e7ba

Please sign in to comment.