I am currently working on an esp32 project and at the moment I am trying to implement a "smart" html checkbox on a web server. Let me explain.
I want to have a checkbox on a Website, which current status (checked or unchecked) should be updated every once in a while. When I say updated I mean that it's current state should adjusted to a boolean so that when i change the boolean by lets say a press of a hardware button the checkbox gets updated automatically. So that basically a buttonpress would do the same thing as ticking the checkbox but the checkbox on the webserver would get updated when a buttenpress and thus a status change would be detected.
uii, I did look at it in the last 20 min and it appears to me that the arduino IoT is kind of a different world. Because the rest of my code is already running i would like to stick to the manual approach of using the normal arduino IDE.
Like i said adjusting the presented code in the posted link would be superb.
Still thank you though.
I don't see the code, post it here.
It is not difficult to include a variable state in a webpage. To get a browser to keep requesting a webpage, there is HTML code to do that at regular intervals.
To get it to do so in some other way i don't know.
The browser has to make a request, and then the server serves the page.
Yeah so that does update the status of the checkbox when the variable state has changed. Still you will have to make a request from your browser to see the 'updated' page.
if you add
<META http-equiv="refresh" content="10;URL=/">
to the webpage, you can automate that to happen every 10 seconds
I don't know if that is what I am looking for. At least it is not the entire solution as I do not know how to set the state of the checkbox in the first place.
actually does that. checking for the state of GPIOs 2,4 & 33 (hmm this must be ESP32 code)
Personally i never use this method of including data in a webpage, because i find it rather 'unclear' what you actually do. I steer away from the whole 'rawliteral' thing.
Now i don't want to explain the method that you pulled of the internet and don't fully understand.
I don't even use ASyncWebserver, just the normal one, though differences are minimal.
If I want to host a page that has dynamic content, i create the page line by line adding to a String, and add, in this case, the word 'checked' in the appropriate location.
Ahh your right, thanks ! That's exactly the information I needed Huge Thank you for pointing that out for me
Thanks for the additional information as well. If I ever do a project with a web server again I might look into it.