# SERIAL node stopbits problem

**URL:** <https://discourse.nodered.org/t/serial-node-stopbits-problem/10843>\
**Category:** General\
**Created:** [6 May 2019 07:07 UTC](https://discourse.nodered.org/t/serial-node-stopbits-problem/10843 "2019-05-06T07:07:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![iungo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iungo/32/8099_2.png) [@iungo](https://discourse.nodered.org/u/iungo)\
**Post date:** [6 May 2019 07:07 UTC](https://discourse.nodered.org/t/serial-node-stopbits-problem/10843/1 "2019-05-06T07:07:42Z")

</div>

I found a problem with SERIAL node (Raspberry PI Zero W hardware /dev/ttyS0). It doesn't react to stopbits value.  
I've made 2 oscillograms with 1 stopbit (top) and 2 stopbits(bottom) and it looks absolutely the same.

 ![stopbits](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/2c6e0c29ea6e85fe81fd614f8fceea4064cd9ee0.png)  
Maybe who knows, how to fix this problem.

---

<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:** [6 May 2019 08:19 UTC](https://discourse.nodered.org/t/serial-node-stopbits-problem/10843/2 "2019-05-06T08:19:22Z")

</div>

Is that the pi sending data or receiving? That may sound like a silly question but it has to be asked.

---

<div class="post-metadata">

**Author:** ![iungo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iungo/32/8099_2.png) [@iungo](https://discourse.nodered.org/u/iungo)\
**Post date:** [6 May 2019 08:41 UTC](https://discourse.nodered.org/t/serial-node-stopbits-problem/10843/3 "2019-05-06T08:41:11Z")

</div>

pi sending data.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [6 May 2019 08:58 UTC](https://discourse.nodered.org/t/serial-node-stopbits-problem/10843/4 "2019-05-06T08:58:47Z")

</div>

Most odd. we set up the serialport here - [https://github.com/node-red/node-red-nodes/blob/master/io/serialport/25-serial.js#L307](https://github.com/node-red/node-red-nodes/blob/master/io/serialport/25-serial.js#L307)  
and at that point we do pass on 1 or 2 correctly - so if there really is a problem it must be with the underlying library which I would be surprised about (given it is so widely used) but...

---

<div class="post-metadata">

**Author:** ![iungo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iungo/32/8099_2.png) [@iungo](https://discourse.nodered.org/u/iungo)\
**Post date:** [6 May 2019 09:14 UTC](https://discourse.nodered.org/t/serial-node-stopbits-problem/10843/5 "2019-05-06T09:14:54Z")

</div>

As I see you do correct setup in 25-serial.js

this.stopbits = parseInt(n.stopbits) || 1;

I tried to set it 2 directly, but haven't got any effect.

I just wondered why it doesn't work? In the .cpp library file, I see 1bit, 1.5bits, and 2bits for stopbits.

SerialPortStopBits NAN\_INLINE(ToStopBitEnum(double stopBits)) {  
if (stopBits \> 1.4 && stopBits \< 1.6) {  
return SERIALPORT\_STOPBITS\_ONE\_FIVE;  
}  
if (stopBits == 2) {  
return SERIALPORT\_STOPBITS\_TWO;  
}  
return SERIALPORT\_STOPBITS\_ONE;

---

<div class="post-metadata">

**Author:** ![iungo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iungo/32/8099_2.png) [@iungo](https://discourse.nodered.org/u/iungo)\
**Post date:** [6 May 2019 09:36 UTC](https://discourse.nodered.org/t/serial-node-stopbits-problem/10843/6 "2019-05-06T09:36:37Z")

</div>

I found how to solve it!

I use tty/AMA0 instead tty/S0.
