Please help building Serial to WiFi using NodeMCU

Hi

Hopefully this isn’t that hard but having looked round for days and there being loads of examples that might do having tried and modified in excess of 30 I just can’t get my head round this or make it work.

I’d appreciate any help you might be able to give.

I am trying to use a NodeMCU as a serial to WiFi converter.

I have a LoRa gateway running that gives a running 9600 baud RS232 output text stream that shows what is going on with the gateway, usage, connections etc. you get the kind of stuff.

As the LoRa gateway is in the attic I’d like to be able to keep an eye on what is going on from my PC, hence the serial to WiFi converter.

I have managed to set the NodeMCU up to receive serial test data from an Arduino Nano and display it on a web page.
But…. The data is either static and only updated (over writing the old data) when the page is refreshed (automatically or manually) or using another example the page is constantly in an updating state and the data keeps filling the page at such a rate you have to scroll down to try and see the most recent data.

What I would like to do is have the web page look like a terminal program, where the basic page stays static and a window where the incoming text stream is added to the bottom of the window row by row every few seconds (say 5 seconds) and scroll up. I don’t need it to do anything else but show the text stream, and maybe be able to start & stop it so I can pause the interesting bits…

The code attached is what I started with but it is static and all the scrolling examples I have tried haven’t been very helpful except to confuse me…

Thanks for any help.

NodeMCU_Serial.ino (2.25 KB)

One basic way of auto-updating the page is to use the the html meta tag in your header (see HTML meta http-equiv Attribute) this forces the browser to refresh your page at specified interval. This will be the equivalent of repeated pressing refresh in your browser.

Smoother-looking pages where the basic page structure is static and the content is updated dynamically involve some javascript programming and either AJAX or more recently Websockets.

If you use AJAX your ESP8266 needs to server up 2 pages- one has the HTML/Javascript for the page frame and the other is purely data which is polled by the javascript on the main page.

I would have thought https://www.hackster.io/brzi/nodemcu-websockets-tutorial-3a2013 would be pretty close to what you are trying to achieve.