How to send commands to be executed at a later time from Android App to ESP32?

Thread Starter


Joined Mar 19, 2022
I am trying to send commands to an ESP32 to control motors at a specific later time from an Android App using Wi-Fi. I am confused on how I would accomplish this? I tried searching for a method and came across using the AlarmManager class, but that seems to be useful for getting notifications on the Android app itself, not sending data over to the ESP32. Any info on how to accomplish this would be greatly appreciated.


Joined Jun 5, 2013
What is confusing? You send a message, the ESP32 receives it and puts the action in a queue and the action is performed when the time arrives.

For example:

M1 ON 129.5

Might mean turn motor 1 on in 129.5 seconds.

Or use an absolute time:

M1 ON 07/13/2021 14:23:52.73


Joined Jan 27, 2019
It would be exceedingly helpful if you could explain why you are doing this. That is, what is the problem it is intended to solve? The easiest way to do that well is to describe the problem, not just part of it.

If this has no other purpose than itself, it will be very hard to choose which method to use since that has to do with all of the other moving parts in a real problem. If you don’t have a real problem at this point, it would serve you well to imagine some problem to solve and work on that so you aren’t rudderless in a sea of possibility.


Joined Jan 30, 2016
I had a similar requirement, I used the RTC functionality in the ESP32 to maintain a real time clock, adjusted daily at midnight with a call via SNTP (alternately your Android app could pass the current UTC every so often). I then created a queue of actions (times and callbacks) in time order (so the head of the queue is always the next to go) maintained through a simple class which also initiated and managed a timer event every second, checked the current time and initiated a task (thread) for the appropriate callback at its allotted time (and recurring ones are placed back on the queue). All done using FreeRTOS within the ESP32. Pretty straightforward really