0

I'm working on a few arduino projects where I've needed a flexible scheduler and/or timer library and was wondering if anyone has a library they recommend?

Case 1: I have a sensor that needs to collect observations every hour, but it has a specific measurement sequence:

  • Power up/boot (takes about 15 seconds)
  • Warm-up for 60 seconds.
  • Observe (2 min), collect raw data, generate stats
  • Cool-down for 5 min.
  • Power off

In this case have a single micro-controller acting as a data-logger that is controlling multiple sensors and writing to an SD card.

Case 2: I have an oven that needs to be controlled to a user-specified temperature profile (up say to 6 points of change), i.e.:

  • Turn on heater
  • Set temperature, 100C and hold for 2 min
  • Set temperature, 160C and hold for 15 min
  • Set temperature, 250C and hold for 1 hr
  • ....
  • Set temperature, 100C and hold for 1 hr
  • Turn off heater

I'm familiar with non-blocking timers and (in the past) have cobbled together a few simple timers with millis() and some ulong variables. Alas, the complexity and debugging time rapidly grows with the number of dependent timers. Before I sit down and sketch out a class definition, I figured I'd ask what others are using.

2
  • You could use a RTC for more accurate timing. – Python Schlange Feb 8 at 16:53
  • You might want to take a look at Arduion_FreeRTOS which implement an FreeRTOS kernel under the Arduino environement. – hcheung Feb 9 at 3:52
1

Some libraries I find good (opinion-based):

  • TaskManagerIO: https://github.com/davetcc/TaskManagerIO
    • does a good job at managing events / scheduling things for a certain (system) time, or even repetitively.
    • with that you could e.g. use a scheduleFixedRate() API to call a function every 60 minutes. Then starts the power up (I assume asynchronously, by setting a pin or something), and just primes the scheduler with the scheduleOnce() API to call another function in 15 seconds. That target function then starts the warmup and schedules the next function / step for 60 seconds into the future, et cetera. It would express the flow very naturally.
  • If accurate timekeeping is needed so that it's really every hour, you might want to use an external RTC module. Also depends on the microcontroller you're using, many have a builtin one that you can feed with a 32.768 kHz crystal and thus you don't need an external chip

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.