Date triggered state machine instead of time/duration triggered states

I´m planing to use some of the arduino state machines (FSM, Simple FSM...) to implement a controll for a pool.
Up to now I only found time (duration) triggered state machine functions, like "fsm.add_timed_transition". I wonder, if there is a state machine function to trigger specific states by date (i.e. every Monday @ 8:00pm) and not by duration?
What I have in mind is someting like the TimeAlarms.h functions (i.e. " Alarm.alarmRepeat(dowSaturday,8,30,30,WeeklyAlarm); // 8:30:30 every Saturday") or do I have to trigger the states by the TimeAlarms.h functions?
Thank you in advance

Are you talking about any specific realization of the FSM?
FSM is only a programming principle and everybody can use it in the program. You can trigger states by interval, time of the day, date, sensor signals and so on

1 Like

I think by the time you get either of those libraries to function smoothly in your project, you will have spent a great deal of time just getting things over to where they want you to be, that is to say the struggle with the library will most of the work.

It would be time better spent actually learning how to roll your own FSM programs.

Even if you decide ultimately that a library is perfect and meets your needs as if the author wrote it with you and your requirements exactly in mind.…

it would be good to know how such "magic" is performed. Either because you decide to continue with your own code, or that getting an FSM to function would get you further as a programmer in general.

Google is your friend.

 Arduino finite state machine


 Arduino two things at once


 Arduino traffic lights 


 Arduino traffic lights finite state machine

TBC it isn't magic, it's code. And although it requires a different way of thinking about things, the code is not that hard to understand and the techniques not that hard to apply where appropriate.

a7

1 Like

@mogulan Welcome! You're new here, maybe also to programming, but maybe not. Either way, this playground has some basic guidelines. Please read all 4 pinned posts here:
Programming questions guidelines
Generally, I agree with @alto777 , you'll learn more by DIY, but if you're only here to implement the one project, that doesn't apply. Please indicate therefore, what you're really wanting to do, the one project, or that as an introduction to the world of programming Arduinos.

do you really need a state machine? don't you really need some action(s) triggered on a schedule. those actions may be to both turn a pump on and off?

why not a table of times and actions. have an index into the table for the next time something needs to be done, executing when that time comes and advancing the index to the next time/action

state machines are often used to handle various stimuli in various states. in this case there's only a single stimuli, that some time is reached and possibly 2 states, from which the pump is turned on and off

Hello mogulan

I guees a simple state sequencer module will help.

This, especially if you're looking for assistance here - most if not all of of the regular respondents can help with a classic switch case FSM, but rather fewer will know whichever library you've chosen.

Thanks a lot for the many and fast replies.
I know state machines from work, there they are implemented in the electronic control units of our combustion engines.
Therefore I just wanted to use the same approach here.
As I´m no friend of reinventing the wheel and curious, I just wondered, if there is an arduino FSM able to handle this requirement already.
I understand from the numerous replies, that this is not the case, therefore I will do switch/case or FSM+TimerAlarms.
Thanks again for the fast and constructive replies

Youll need an RTC module. Don't fixate on the FSM. It's a simple app and regular code will work fine. Sit in a loop showing the time. When the time is right (Monday, 9p) fire your action.

Ok, thanks a lot. I´ll do so.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.