# Need to see serial port data

**URL:** <https://discourse.nodered.org/t/need-to-see-serial-port-data/61914>\
**Category:** General\
**Created:** [28 April 2022 08:59 UTC](https://discourse.nodered.org/t/need-to-see-serial-port-data/61914 "2022-04-28T08:59:12Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![dzairo](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@dzairo](https://discourse.nodered.org/u/dzairo)\
**Post date:** [28 April 2022 08:59 UTC](https://discourse.nodered.org/t/need-to-see-serial-port-data/61914/1 "2022-04-28T08:59:12Z")

</div>

Hi all.  
I need see what my ESP32 send to serial port, there are lots of lines string.  
is there any node to see it ?  
all my string are end with \n  
easy solution if possible , not complicated .. any idea?

---

<div class="post-metadata">

**Author:** ![hardillb](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hardillb/32/12373_2.png) [@hardillb](https://discourse.nodered.org/u/hardillb)\
**Post date:** [28 April 2022 09:46 UTC](https://discourse.nodered.org/t/need-to-see-serial-port-data/61914/2 "2022-04-28T09:46:30Z")

</div>

What have you already tried and how didn't it work?

Have you looked at the serial port nodes? [node-red-node-serialport (node) - Node-RED](https://flows.nodered.org/node/node-red-node-serialport)

---

<div class="post-metadata">

**Author:** ![dzairo](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@dzairo](https://discourse.nodered.org/u/dzairo)\
**Post date:** [28 April 2022 10:12 UTC](https://discourse.nodered.org/t/need-to-see-serial-port-data/61914/3 "2022-04-28T10:12:33Z")

</div>

Hi.  
Right now I use serial port node and write to file . now all data write to file ..  
But I don't need store to file .. just easy terminal like in Arduino IDE ..  
Now working with write to file .. but see in web page .. for max 10k of char ..

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 April 2022 15:15 UTC](https://discourse.nodered.org/t/need-to-see-serial-port-data/61914/4 "2022-04-28T15:15:20Z")

</div>

So you need to create a web page that shows each received entry on a web page up to 10k entries.

Lots of ways to do that depending on your experience level.

The easiest method of showing a web page is usually Dashboard. However, I don't think it has a log style output so you would need to hand-craft that.

If you can do some basic HTML and JavaScript, it would be pretty easy to do using uibuilder. However, if you've not used Node-RED before or don't know any HTML, you might find getting going a little daunting.

I've done some similar outputs with uibuilder before though so if you are lucky, I might be able to find enough time to knock up a quick demo.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 April 2022 22:47 UTC](https://discourse.nodered.org/t/need-to-see-serial-port-data/61914/5 "2022-04-28T22:47:18Z")

</div>

Here is the quick and dirty uibuilder version. Though note that it doesn't currently truncate the text output.

### index.html

```html
<!doctype html>
<html lang="en"><head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Simple log page - Node-RED uibuilder</title>
    <meta name="description" content="Node-RED uibuilder - Simple log page">
    <link rel="icon" href="./images/node-blue.ico">

    <!-- Your own CSS -->
    <link type="text/css" rel="stylesheet" href="./index.css" media="all">

</head><body class="uib">
    
    <h1>uibuilder Simple log page</h1>

    <pre id="loggy"></pre>

    <!-- #region Supporting Scripts. These MUST be in the right order. Note no leading / -->
    <script src="../uibuilder/vendor/socket.io/socket.io.js">/* REQUIRED: Socket.IO is loaded only once for all instances. Without this, you don't get a websocket connection */</script>
    <script src="./uibuilderfe.min.js">/* REQUIRED: remove 'min.' to use dev version */</script>
    <script src="./index.js">/* OPTIONAL: Put your custom code here */</script>
    <!-- #endregion -->

</body></html>

```

### index.js

```javascript
uibuilder.start()

uibuilder.onChange('msg', function(msg){
    const eMsg = document.getElementById('loggy')
    eMsg.textContent += msg.payload + '\n'
})

```

Doesn't get much easier than that! Here is the flow:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/8/d8047852c587f99bed88f792ec8c51b3c9fd8488.png)  
Yup, only 1 node, just connect your serial-in to the uibuilder node.

Of course, this is rather noddy but at least it shows you how little code you need for something simple in uibuilder. Most of the HTML is actually the default blank template.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 April 2022 15:59 UTC](https://discourse.nodered.org/t/need-to-see-serial-port-data/61914/6 "2022-04-29T15:59:51Z")

</div>

And here is an amended index.js that limits the length of the log by dropping the top elements. New elements are added to the end as in the previous example.

```auto
uibuilder.start()

const maxLogLength = 10

uibuilder.onChange('msg', function(msg){
    const loggy = document.getElementById('loggy')

    while (loggy.childElementCount >= maxLogLength) {
        loggy.removeChild(loggy.firstChild)
    }

    const c = document.createElement('span')
    c.setAttribute('class','loggyline')
    c.innerText = `${msg.payload}${'\n'}`
    
    loggy.appendChild(c)
})

```

---

<div class="post-metadata">

**Author:** ![dzairo](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@dzairo](https://discourse.nodered.org/u/dzairo)\
**Post date:** [1 May 2022 15:16 UTC](https://discourse.nodered.org/t/need-to-see-serial-port-data/61914/7 "2022-05-01T15:16:19Z")

</div>

Hi.  
Thanks .. but .. ehm .. I don't know who to use it .. but in fact , right now use text file .. and working  
good .. , now don't have free time , later I look at it ..

best regards , and thanks for your time ..

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [4 May 2022 20:42 UTC](https://discourse.nodered.org/t/need-to-see-serial-port-data/61914/8 "2022-05-04T20:42:05Z")

</div>

Just put your msg.payload into that template node.  
this should do the trick.

```auto
[
    {
        "id": "bb6b9203fe0f6550",
        "type": "ui_template",
        "z": "03b2c8e647d8021c",
        "group": "310c82156d24681c",
        "name": "",
        "order": 5,
        "width": "23",
        "height": 10,
        "format": "\n<!--<pre><code id=\"shell\" class=\"language-bash bash\" ng-bind=\"msg.payload\"></code></pre>-->\n<pre><code id=\"shell\" class=\"language-bash bash\"></code></pre>\n\n<script>\n $(document).ready(function() {\n $('#shell').each(function(i, e) {hljs.highlightElement(e)});\n }); \n</script>\n\n\n<script>\n(function(scope) {\n scope.$watch('msg', function(msg) {\n if (msg) {\n debugger\n $(\"#shell\").text(msg.payload);\n $('#shell').each(function(i, e) {hljs.highlightElement(e)});\n //$(\"#shell\").scrollTop(function() { return this.scrollHeight; });\n $(\"#shell\").closest(\".nr-dashboard-template\").scrollTop(function() { return this.scrollHeight; });\n }\n });\n})(scope);\n</script>",
        "storeOutMessages": true,
        "fwdInMessages": true,
        "resendOnRefresh": true,
        "templateScope": "local",
        "className": "",
        "x": 560,
        "y": 500,
        "wires": [
            []
        ]
    },
    {
        "id": "310c82156d24681c",
        "type": "ui_group",
        "name": "Test",
        "tab": "b58c8f02fe80b3fc",
        "order": 1,
        "disp": false,
        "width": "23",
        "collapse": false,
        "className": ""
    },
    {
        "id": "b58c8f02fe80b3fc",
        "type": "ui_tab",
        "name": "Test",
        "icon": "dashboard",
        "order": 28,
        "disabled": false,
        "hidden": false
    }
]

```

---

<div class="post-metadata">

**Author:** ![dzairo](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@dzairo](https://discourse.nodered.org/u/dzairo)\
**Post date:** [5 May 2022 12:13 UTC](https://discourse.nodered.org/t/need-to-see-serial-port-data/61914/9 "2022-05-05T12:13:47Z")

</div>

Huh .. 😧 sorry.. I'm totally don't know what to do .. But stop it .  
I solve problem with Write to File node and work good .  
If you have some easy solution or make new Node .. let me know .. but now thanks  
for your time ..

best regards.

[Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)  
I test what you post .. but .. only last character see ... } .. that all ..

---

<div class="post-metadata">

**Author:** ![Jean-Luc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jean-luc/32/89996_2.png) [@Jean-Luc](https://discourse.nodered.org/u/Jean-Luc)\
**Post date:** [5 May 2022 14:03 UTC](https://discourse.nodered.org/t/need-to-see-serial-port-data/61914/10 "2022-05-05T14:03:51Z")

</div>

If your information arrives in a burst of messages, you need to bring them together with a Join node. Put this node before the template node.  
you can change the timeout or if you know the number of incoming messages, indicate this instead of the timeout  
And then you will have all your information on the web dashboard for sure.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/d/1d6f5be8beeddffa5cccb4744c76ddcc83bc577a.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/6/461ef3df7eab6cb1e4367a92a237b112253a2146.png)

---

<div class="post-metadata">

**Author:** ![dzairo](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@dzairo](https://discourse.nodered.org/u/dzairo)\
**Post date:** [5 May 2022 16:09 UTC](https://discourse.nodered.org/t/need-to-see-serial-port-data/61914/13 "2022-05-05T16:09:22Z")

</div>

After install new node

> ring-buffer

all working what I want .. remove join node , and add only ring-buffer ..

Thanks to all who help me .. now working perfect..

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [4 July 2022 16:10 UTC](https://discourse.nodered.org/t/need-to-see-serial-port-data/61914/14 "2022-07-04T16:10:16Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
