# Serial units on bus

**URL:** https://discourse.nodered.org/t/serial-units-on-bus/49715
**Category:** General
**Created:** [14 August 2021 11:06 UTC](https://discourse.nodered.org/t/serial-units-on-bus/49715 "2021-08-14T11:06:51Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![PiMo131](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pimo131/32/34978_2.png) [@PiMo131](https://discourse.nodered.org/u/PiMo131)
#### Post date: [14 August 2021 11:06 UTC](https://discourse.nodered.org/t/serial-units-on-bus/49715/1 "2021-08-14T11:06:51Z")

</div>

Hi,

I am working with several (20) virtual com ports. Each port has a few (2 to 6) units which give sensor info every second.

So from every unit I am getting info like:

TMP,01,data  
TMP,02,data  
TMP,03,data  
HUM,01,data  
HUM,02,data

I somehow want to notice when I 'loose' a unit on the serial line.

Currently I have two options:

Count the amount of messages per second, if it drops below the set amount give an alert.  
With this i have some timing issues. Since the units are not synced from time to time i get false positives.

Otheroption is to write all info to a DB, read the last update time and if it is more then 'x' seconds give an alert but this is quiet a lot of work for a simple check

Does anyone have nodes / flows that do something similar?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [14 August 2021 12:13 UTC](https://discourse.nodered.org/t/serial-units-on-bus/49715/2 "2021-08-14T12:13:24Z")

</div>

If what you need to do is to trigger an action when there is a gap in incoming messages on one of the units, you can do that with a Trigger node set to send Nothing then wait for a timeout and then send the error signal. Set the Trigger node to Extend delay if new message arrives. The result will be that the node sends nothing provided the messages keep coming in, but if there is a gap longer than the timeout then it will send a message.

---

<div class="post-metadata">

### Author: ![PiMo131](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pimo131/32/34978_2.png) [@PiMo131](https://discourse.nodered.org/u/PiMo131)
#### Post date: [14 August 2021 14:01 UTC](https://discourse.nodered.org/t/serial-units-on-bus/49715/3 "2021-08-14T14:01:46Z")

</div>

Sounds easy enough. To make my flow more simple (20x4 = 100 nodes to add) is there a way to set the trigger not on a msg.topic basis? So if the topic is HUM01 / HUM02 etc. It will act as a trigger for each topic separately?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [14 August 2021 14:21 UTC](https://discourse.nodered.org/t/serial-units-on-bus/49715/4 "2021-08-14T14:21:36Z")

</div>

> [@PiMo131](#):
>
> act as a trigger for each topic separately?

From the help text for the Trigger node:  
Optionally, the node can be configured to treat messages as if they are separate streams, using a msg property to identify each stream. Default `msg.topic` .

Possibly that is new in Node Red 2.x, I am not sure. If you don't see the "Handling" field in the node and you are not on node red 2 then you could upgrade.

---

<div class="post-metadata">

### Author: ![PiMo131](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pimo131/32/34978_2.png) [@PiMo131](https://discourse.nodered.org/u/PiMo131)
#### Post date: [14 August 2021 15:23 UTC](https://discourse.nodered.org/t/serial-units-on-bus/49715/5 "2021-08-14T15:23:31Z")

</div>

Great, thanks!!!

---

<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: [28 August 2021 15:24 UTC](https://discourse.nodered.org/t/serial-units-on-bus/49715/6 "2021-08-28T15:24:13Z")

</div>

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