I would need help from you. I´m trying to build my own solution to build a machine that will TurnON/OFF 2 devices based on the scheduler. So my task also was to split the day into 3 periods:
1) morning
2) Day
3) evening
- each period may start/end at a specified time. and "Switch" can be different for every period
tools Description:
Firmware - 1.14
Board - lolin d32 pro
So my solution:
build 4 timers based on which will be triggered based on a defined period whole through the day and inside called function there is "if" block to determine whether RTC is within time range or not. Unfortunately non of the timer is triggered.
Code Example:
Code: Select all
#----------------------------------------------------#
def morning_timer0(pin):
RTC read
If statemen to compare wheter RTC is within day period:
process
def day_timer1(pin):
RTC read
If statemen to compare wheter RTC is within day period:
process
def evening_timer2(pin):
RTC read
If statemen to compare wheter RTC is within day period:
process
def timer3(pin):
process
#----------------------------------------------------#
# Timers definition
SCHED_TIME0 = 21 600 000 # Becuse it should run only 4 times per day
tim0 = machine.Timer(0)
tim0.init(mode=machine.Timer.PERIODIC, period=SCHED_TIME0, callback=morning_timer0)
# - all of them has the same definition, there is just "period" changing --> so they are called in different moment of the day
2) I need them to run parallelly
3) I tried to use also "uasyncio" library with no success (based on documentation - https://docs.micropython.org/en/latest/ ... yncio.html)