Rui, you have some wonderful tutorials using the ASyncWebServer library. In my application I would like to force an update of the web page when the status changes (based on digitalRead) so the status is displayed correctly. You have examples of a web page automatically updating every 10 seconds (weather station) but I’d like to know how to cause an update only when I know something has changed rather than just having the page update constantly.
Thank you!
Hi.
You can use Server-Sent Events. The server (ESP32) sends an event to the browser with whatever you want.
So, the browser updates automatically when there is a change.
We don’t have a specific tutorial for server-sent events.
However, we use them in this project: https://randomnerdtutorials.com/esp32-bme680-web-server-arduino/
See if you can apply this concept to your own project.
Let me know if you need further help with that.
Regards,
Sara
Hey Sheldon,
Want the best of both worlds?
Take a look at my tutorial about WebSocket:
ESP32 Remote Control with WebSocket