Comments on: ESP8266 NodeMCU Web Server using Server-Sent Events (Update Sensor Readings Automatically) https://randomnerdtutorials.com/esp8266-nodemcu-web-server-sent-events-sse/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Mon, 17 Mar 2025 11:48:09 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: John Kneen https://randomnerdtutorials.com/esp8266-nodemcu-web-server-sent-events-sse/#comment-963492 Tue, 01 Oct 2024 23:23:11 +0000 https://randomnerdtutorials.com/?p=99657#comment-963492 In reply to Manfred.

I think your program is doing exactly what it said:

if ((millis() – lastTime) > timerDelay) {

For the first pass lastTime == 0 and millis( ) is also a very small value. The millis() starts when your program starts so could be a few milliseconds at the very most. I think I would try adding if ((millis() – lastTime) > timerDelay)||(lastTime==0) {.

Alternaively you need to do the action once at the end of your setup( ) routine, That is

void setup( ){
…previous code
action( );
}

void loop( ){
if ((millis() – lastTime) > timerDelay) {
action( ); //where the new function action( ) is all the code that was in this loop
}
}

]]>
By: Manfred https://randomnerdtutorials.com/esp8266-nodemcu-web-server-sent-events-sse/#comment-963371 Tue, 01 Oct 2024 13:45:17 +0000 https://randomnerdtutorials.com/?p=99657#comment-963371 Hi Sara, hi Rui,

this sample-code works absolut fine – thanks for that. So what i found is a tricky situation in this code. When i set the loop-delay to 1 Minute (60000) and the code starts for the first time, i see the webpage and the gauges – so far , so good. But i have to wait 1 minute before the “first” sensor-data is shown in the gauges. This is about the following code-snipet in the loop() as follow:

if ((millis() – lastTime) > timerDelay) {

How can i reach the goal that when the system starts and the startpage (index_html) is rendered the first time that sensor valus is shown immediately as the form is loaded in the browser-page? Same situation when refreshing the browser page with e.g. F5. The startpage is loaded immediately but i have to wait for the first loop-running to get actual sensor-values.

Would be nice if you could show a solutions for this “little gap”. I think a normal loop-timing could be between 10 Minutes up to 1 Hour to cover the changes in all sensor-parameters for a normal detection.

Thanks a lot,
Greeting from Manfred

]]>
By: Conya https://randomnerdtutorials.com/esp8266-nodemcu-web-server-sent-events-sse/#comment-867130 Sat, 21 Oct 2023 22:25:09 +0000 https://randomnerdtutorials.com/?p=99657#comment-867130 HI Sara. Very good job. Helped a lot. But the question is whether it is really necessary to call getSensorReadings(); subprogram in both the processor function and the loop routine. I had big problems with controller restarts until I deleted this call from the processor subprogram.

]]>
By: Ivan Goga https://randomnerdtutorials.com/esp8266-nodemcu-web-server-sent-events-sse/#comment-720262 Thu, 20 Jan 2022 21:17:54 +0000 https://randomnerdtutorials.com/?p=99657#comment-720262 In reply to Sara Santos.

Thank you.
Ivan

]]>
By: Sara Santos https://randomnerdtutorials.com/esp8266-nodemcu-web-server-sent-events-sse/#comment-716594 Mon, 03 Jan 2022 15:06:24 +0000 https://randomnerdtutorials.com/?p=99657#comment-716594 In reply to Ivan Goga.

Hi.
This works on a local network.
You need to open a tunnel in your router to access it from anywhere.

Alternatively, you can host the readings in a paid server that you can access from anywhere.
Here’s an example: https://randomnerdtutorials.com/visualize-esp32-esp8266-sensor-readings-from-anywhere/
This is another example:
https://randomnerdtutorials.com/cloud-weather-station-esp32-esp8266/

Or, you can also use Firebase (it’s free):
https://randomnerdtutorials.com/esp32-esp8266-firebase-bme280-rtdb/
https://randomnerdtutorials.com/esp32-esp8266-firebase-web-app-sensor/

I hope this helps.

Regards,
Sara

]]>
By: Ivan Goga https://randomnerdtutorials.com/esp8266-nodemcu-web-server-sent-events-sse/#comment-715499 Fri, 31 Dec 2021 17:41:37 +0000 https://randomnerdtutorials.com/?p=99657#comment-715499 Hi.
I like this project. I want to ask if this works within the world or just within one wifi? I would like to measure the temperature in my cottage and view it on the phone at work. Does it work like this? Thank you for your response.
Have a nice day
Ivan

]]>
By: Ulhas Rane https://randomnerdtutorials.com/esp8266-nodemcu-web-server-sent-events-sse/#comment-715253 Fri, 31 Dec 2021 03:34:10 +0000 https://randomnerdtutorials.com/?p=99657#comment-715253 Hi
Thanks for great sharing

Is it possible to use esp32or esp8266 as sse EventListener or client so that it can listen to data sent by website hosted on share webservers

]]>
By: Sara Santos https://randomnerdtutorials.com/esp8266-nodemcu-web-server-sent-events-sse/#comment-690616 Thu, 28 Oct 2021 21:38:18 +0000 https://randomnerdtutorials.com/?p=99657#comment-690616 In reply to Bjorn.

Uauu.
That looks awesome!
Great work 🙂
Regards,
Sara

]]>
By: Bjorn https://randomnerdtutorials.com/esp8266-nodemcu-web-server-sent-events-sse/#comment-690476 Thu, 28 Oct 2021 15:07:50 +0000 https://randomnerdtutorials.com/?p=99657#comment-690476 In reply to Sara Santos.

Hi Sara!

Thanks alot for the pointers in the right direction! I`ve been testing the tutorials over and over again and have something cooked up now. Ment for the green house monitoring, got it all working inlc history logging, graphing is done with RGraph javascript, wifimanager etc. Most of the code ive got out of RNT esp8266 tutorials.

https://imgur.com/a/yoO45FV
https://imgur.com/a/Rxvdmz9

Amazing what one can learn out of the tutorials thanks again to the RNT team!

]]>
By: Sara Santos https://randomnerdtutorials.com/esp8266-nodemcu-web-server-sent-events-sse/#comment-681227 Sat, 09 Oct 2021 23:13:11 +0000 https://randomnerdtutorials.com/?p=99657#comment-681227 In reply to bjorn.

Hi.
We have these tutorials with web servers with charts:
https://randomnerdtutorials.com/esp32-esp8266-plot-chart-web-server/
https://randomnerdtutorials.com/esp8266-nodemcu-plot-readings-charts-multiple/

If you want to instantly load the last 20 readings, for example, you need to save your readings in a file (using a microSD card or SPIFFS) in JSON format, for example.
Then, when the page loads it would call the file that contains the readings and display them on the charts.
https://randomnerdtutorials.com/esp32-microsd-card-arduino/
https://randomnerdtutorials.com/esp32-vs-code-platformio-spiffs/
https://randomnerdtutorials.com/install-esp32-filesystem-uploader-arduino-ide/

I hope this helps.
Regards,
Sara

]]>