To sleep or not to sleep?

To sleep or not to sleep?

lastrun_1 = 0 lastrun_2 = 0

while True: now = time.time()

if (lastrun_1 == 0) or (now - lastrun_1 >= 60):
    read_sensor_1()
    lastrun_1 = now
if (lastrun_2 == 0) or (now - lastrun_2 >= 300):
    read_sensor_2()
    lastrun_2 = now

machine.idle()

If we were only reading a single sensor (or multiple sensors at the same interval), we could drop the loop and juse use the ESP8266’s deep sleep mode (assuming we have wired things properly):

read more →

Animating a map of Covid in the Northeast US

<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
  <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/zGN_zEzd_TE?autoplay=0&amp;controls=1&amp;end=0&amp;loop=0&amp;mute=0&amp;start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"></iframe>
</div>
read more →