for measurement from my custom weather station I'm currently using two nested while loops to gather measuremet in 5seconds during 5min period as follows:
interval = 300
short_interval = 5
while True:
start_time = time.time()
while time.time() - start_time <= interval:
measurement_start = time.time()
reset_counter()
while time.time() - measurement_start <= short_interval:
store_directions.append(wind_direction.get_value())
final_speed = calculate_speed(wind_interval)
store_speeds.append(final_speed)
measure_rain()
do other stuff, mqtt etc.
which works fine - storing every 5seconds and sending everything out every 5mins
What I'm bit struggling is to accomodate another timeinterval of 60mins to gather rainfall. Now it's measured every 5mins with measure_rain()
What would be best way how to keep 5min measurements for wind and another one for rainfall which will take 60min? Another while? I was trying that, but ended up messing everything up ;) Thank you for any help!