I currently working on a python code but the code seemed to stop after I added math. I added a psychometric formula for a greenhouse to measure certain condition and trigger the system, but it seems like I write the math wrong?
Because before the math formula was added, everything worked perfectly.
I am a newbie and would greatly apreciate all your help!
Thank you
This is the lines of code that caused the problem
if(temp>suhu and humidity<hum):
t1 = temp*math.atan(0.151977*(math.sqrt(humidity+8.313659)))
te1= suhu2*math.atan(0.151977*(math.sqrt(hum2+8.313659)))
t2 = math.atan(temp+humidity)
te2= math.atan(suhu2+hum2)
t3 = math.atan(humidity-1.676331)
te3= math.atan(hum2-1.676331)
t4 = 0.00391838*(math.sqrt(humidity**3))
te4= 0.00391838*(math.sqrt(hum2**3))
t5 = math.atan(0.023101*humidity)
te5= math.atan(0.023101*hum2)
t6 = t4*t5
te6= te4+te5
t7 = 4.686035
te7= 4.686035
twi = t1+t2-t3+t6-t7
twe = te1+te2-te3+te6-te7
c1 = -5.8002206*1000
c2 = 1.3914993
c3 = -4.8640239/100
c4 = 4.1764768/100000
c5 = -1.4452093/100000000
c6 = 6.5459673
po = 101.325
c = 273.15
e = 0.622
d = 0.000662
f = 0.00116
twii = twi+c
twee = twe+c
estwi = (c1/twii)+c2+(c3*twii)+(c4*(twii**2))+(c5*(twii**3))+(c6*math.log(twii))
estwi = math.exp(estwi)/1000
estwe = (c1/twee)+c2+(c3*twee)+(c4*(twee**2))+(c5*(twee**3))+(c6*math.log(twee))
estwe = math.exp(estwe)/1000
ei = estwi-(d*po*(temp-twi))
ee = estwe-(d*po*(suhu2-twe))
xi = e*ei*1000/(po-ei)
xe = e*ee*1000/(po-ee)
dx = abs(xi-xe)
puk= -0.0046*temp+1.2978
print("tw")
print(twi)
print(twe)
print("twii&twee")
print(twii)
print(twee)
print("estw")
print(estwi)
print(estwe)
print("e")
print(ei)
print(ee)
print("x")
print(xi)
print(xe)
print("dx")
print(dx)
print("puk")
print(puk)
print(no)
print(date)
print(temp)
print(humidity)
print(h)
ket2 = 'Aktif'
print(ket2)
try:
connection = mysql.connector.connect(host='localhost',database='mydb',user='pi',password='agustus12')
cursor = connection.cursor()
mySql_insert_query = """INSERT INTO rumahkaca (TANGGAL, SUHU, KELEMBABAN, UVINDEX, KET) VALUES (%s, %s, %s, %s, %s)"""
record=(date, temp, humidity, h, ket2)
cursor.execute(mySql_insert_query, record)
connection.commit()
print("sukses")
except mysql.connector.Error as error:
print("Failed to insert into MySQL table {}".format(error))
GPIO.setup(relay,GPIO.OUT)
GPIO.output(relay,GPIO.LOW)
time.sleep(60)
GPIO.output(relay,GPIO.HIGH)
time.sleep(30)
time.sleep(60)
anyone can help me? thank you
Aucun commentaire:
Enregistrer un commentaire