I hope you can help me, it is worth mentioning that I am relatively new to micropython
Code: Select all
async def dataout():
while True:
uart = UART(0, baudrate=9600, tx=machine.Pin(16), rx=machine.Pin(17))
d1d = uasyncio.create_task (h())
d2d = uasyncio.create_task (t())
d3d = uasyncio.create_task (humedadsustrato())
d4d = uasyncio.create_task (tempico())
d5d = uasyncio.create_task (tsustrato())
ji = await uasyncio.gather(d1d, d2d, d3d, d4d, d5d)
d1 =ji[0]
d2 =ji[1]
d3 =ji[2]
d4 =ji[3]
d5 =ji[4]
if d1 == None:
p1 = "xxx"
else:
p1 = "{0:.3f}".format( float(d1))
if d2 == None:
p2 = "xxx"
else:
p2 = "{0:.3f}".format( d2)
if d3 == None:
p3 = "xxx"
else:
p3 = "{0:.3f}".format( d3)
if estatus == True:
p4 = "on"
if estatus == False:
p4 = "of"
if ledazul.pin.value() == 0:
p5 = "aon"
if ledazul.pin.value() == 1:
p5 = "aof"
if ledblanco.pin.value() == 0:
p6 = "bon"
if ledazul.pin.value() == 1:
p6 = "bof"
if ledrojo.pin.value() == 0:
p7 = "ron"
if ledrojo.pin.value() == 1:
p7 = "rof"
if bomba1.pin.value() == 0:
p8 = "xon"
if bomba1.pin.value() == 1:
p8 = "xof"
p9 = "{0:.3f}".format( d4)
if d5 == None:
p10 = "xxx"
else:
p10 = "{0:.3f}".format( float(d5))
data_send =str("a"+p1+"b"+p2+"c"+p3+"d"+p4+"e"+p5+"g"+p6+"h"+p7+"i"+p8+"j"+p9+"k"+p10+"l")
uart.write(data_send)
await uasyncio.sleep(2)
Code: Select all
async def main():
horas_de_luz = 20
horas_de_obscuridad = 15
while True:
huj = uasyncio.create_task( humedadfun( humedadsustrato() ))
tpl= uasyncio.create_task( tempo( estatus, horas_de_luz, horas_de_obscuridad))
llo = uasyncio.create_task( dataout() )
await uasyncio.gather(huj, tpl, llo)
Code: Select all
try:
estatus = True
uasyncio.run(main())
except onewire.OneWireError:
pass
except TypeError:
pass
except KeyboardInterrupt:
pass
except InvalidPulseCount:
pass
except InvalidChecksum:
pass
finally:
uasyncio.new_event_loop()