# Modbus Serial sequence

**URL:** <https://discourse.nodered.org/t/modbus-serial-sequence/12668>\
**Category:** General\
**Created:** [27 June 2019 16:34 UTC](https://discourse.nodered.org/t/modbus-serial-sequence/12668 "2019-06-27T16:34:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pautorras](https://avatars.discourse-cdn.com/v4/letter/p/c57346/32.png) [@pautorras](https://discourse.nodered.org/u/pautorras)\
**Post date:** [27 June 2019 16:34 UTC](https://discourse.nodered.org/t/modbus-serial-sequence/12668/1 "2019-06-27T16:34:23Z")

</div>

Hi,

I'm newbie in node red.  
For me it's an excellent tool with a high potential.

In a RPI3B+ I have made a sqlite DB write, dashboard and openweathermap get, and it's working ok, but I need to solve two problems that I don't know how to do it.

1- In the modbus Serial I need to sequence the polling. I've made a function to do this, but I think that work in boolean outputs it's not right.

Code function I've made:  
var now= new Date();  
var seg= now.getUTCSeconds();  
var msg1,msg2,msg3,msg4;

if (0\>seg\<10) {msg1=true;}  
else{msg1=false;}  
if (10\>seg\<20) {msg2=true;}  
else{msg2=false;}

return [msg1,msg2];

In debug window message me: "Function tried to send a message of type boolean"

How can I do this sequence work fine?

1. 

The variables I read in modbus, I want to save in a global to use this values in other flows. How can I do it?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [27 June 2019 17:30 UTC](https://discourse.nodered.org/t/modbus-serial-sequence/12668/2 "2019-06-27T17:30:51Z")

</div>

You can't send a Boolean. The msg must be an object.

---

<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:** [27 June 2019 19:30 UTC](https://discourse.nodered.org/t/modbus-serial-sequence/12668/3 "2019-06-27T19:30:51Z")

</div>

Just to amplify that a bit you probably want something like

```auto
else msg1 = {payload: false}

```

which creates a message with the payload set to false.

---

<div class="post-metadata">

**Author:** ![thatcadguy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thatcadguy/32/5273_2.png) [@thatcadguy](https://discourse.nodered.org/u/thatcadguy)\
**Post date:** [28 June 2019 00:42 UTC](https://discourse.nodered.org/t/modbus-serial-sequence/12668/4 "2019-06-28T00:42:52Z")

</div>

What Modbus library / node(s)? node-red-contrib-modbus?

---

<div class="post-metadata">

**Author:** ![pautorras](https://avatars.discourse-cdn.com/v4/letter/p/c57346/32.png) [@pautorras](https://discourse.nodered.org/u/pautorras)\
**Post date:** [28 June 2019 08:35 UTC](https://discourse.nodered.org/t/modbus-serial-sequence/12668/5 "2019-06-28T08:35:04Z")

</div>

Hi,

Thank you all.  
I've solved this problem, a flow example helped me.

@thatcadguy, yes I'm using node-red-contrib-modbus
