Hi,
I’m new on forum, sorry if my question was already asked but I’m stuck in my project.
I store data in an array (defined length in .ino: myTable[100];) this data is received by ESP NOW and when a new data is added to array I want to display it in my table on my web server. So, how to ask to js to grab data only when new data is coming without doing setInterval checking array a unlessly.
And my hardest difficulty is: how to display new value in a table? Actually, I know display table write in raw in my .html but how increase dynamically the table using .js?
I apologize if I wasn’t clear, and thank you if you take your time to help me.
Hi Théo.
To add new rows to the table using JavaScript and set its value, take a look at this: https://www.w3schools.com/jsref/met_table_insertrow.asp
I think this is exactly what you are looking for.
To get new data without setInterval, you can use websockets or server-sent events.
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. When new readings are available, send those readings to the browser as events.
At the moment, we don’t have any tutorial about websockets. We plan to do it in a near future. Meanwhile, you can take a look at this tutorial created by one of our readers: https://m1cr0lab-esp32.github.io/remote-control-with-websocket/
I hope this helps.
Regards,
Sara
Hi Sara,
Your help and RNT website is so helpful. Just thanks for all!
Regards,
Théo