Current system time: loading...
Time | GPIO | New State |
---|
This example shows you a web-page that can be used to control GPIOs 25, 26, 27, 32 and 33 to be turned on or off at a given time.
For simplicity, we use the system uptime here, which you can see at the top of the page.
The page uses the REST API provided at /api to commuicate with the ESP32.
GET /api/uptime returns the current system uptime:
{"uptime":42}
This node is polled every 10 seconds to stay synchronized.
GET /api/events returns the current list of events:
[{"gpio":27,"state":1,"time":42,"id":0}, ...]
This node is polled every 60 seconds to stay synchronized
POST /api/events can be used to add new events. The response object will contain an additional id that can be used to refer to the event.
DELETE /api/events/id will delete the event with the specified id. If events are executed (time < uptime), they are deleted as well.
The client side javascript synchronizes your view even if not explicit request is sent to the ESP32.