Totally doable. You know the Particle devices have an in-built RTC, so you don’t really need an external one? They also sync time over the internet, so it’s up-to-date.
Considering the “blink an LED over the internet” example; You use an HTML request to sens a function with a parameter. In this case, the parameter is “on” or “off”. There’s really no reason why you shouldn’t be able to change that to whatever you desire.
In the function, the argument you passed is known as “command” (since that’s what you’ve called it).
int ledToggle(String command) {
//the variable "command" is the argument you passed
}
Using that, you should be able to assign the argument to a variable you need, after parsing it accordingly.
I’m going to assume you need the minimum of 4 values for startH
/endH
and startM
/stopM
? If you were to pass that argument as epoch time, you could parse it on the device. Then you’d only need two functions for the start and stop time. If it’s always a fixed time it needs to run, you could set a fixed stop time: stopTime = startTime + 20 minutes
.
Enough said, time for you to try some things. What is the code you’ve come up with so far, if any?
Try creating some code with 4 functions, in which you set your variables by passing it the above-mentioned arguments, after parsing them accordingly.
While testing, I suggest you make use of Serial.print() to print the various things over a serial monitor, so you can see what’s going on. If you want to call functions with arguments easily, you can use the Particle Dev, or perhaps this webpage I made.
I’d recommend starting off easy: 1 function, and just print the argument over serial. Then gradually move up: parse the argument. Then assign it to your variable. Meanwhile, keep printing everything you’re doing so you can keep track.
Once you’ve got the code on the device working properly, you can start with the webapp, which shouldn’t be too complicated
Let us know if you require further assistance/help.