# How do I use serialport node to write to a RS485

**URL:** <https://discourse.nodered.org/t/how-do-i-use-serialport-node-to-write-to-a-rs485/63484>\
**Category:** General\
**Created:** [5 June 2022 13:40 UTC](https://discourse.nodered.org/t/how-do-i-use-serialport-node-to-write-to-a-rs485/63484 "2022-06-05T13:40:07Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [6 June 2022 13:10 UTC](https://discourse.nodered.org/t/how-do-i-use-serialport-node-to-write-to-a-rs485/63484/4 "2022-06-06T13:10:53Z")

</div>

If you want to send `68 03 01 00 22 aa 04 9e` to the serial port then use either a SERIAL Request or SERIAL Out node.

Use an INJECT to send a buffer with `68 03 01 00 22 aa 04 9e`

As i said before...  
inject (set some data in the payload) 👉 serial request (setup the correct com settings) 👉 debug node (see if you get a reply)

> [@SP-Mushrooms](#):
>
> As javascript apparently don't have byte

They have buffers (which are byte arays)

> [@SP-Mushrooms](#):
>
> I am new to javascript I don't know how to convert the python to javascript

There is no JavaScript required for this - it is a "no code"

example...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/e/9e7b0c08ed65e18968ecc29891696cb49ab6a0ba.png)

↑ Not a bit of JavaScript in sight

Demo flow (use `CTRL-I` to import it)...

```auto
[{"id":"9d6f8adbbaf48ea1","type":"inject","z":"b1e41431717e4e05","name":"[\"0x68\",\"0x03\",\"0x01\",\"0x00\",\"0x22\",\"0xaa\",\"0x04\",\"0x9e\"]","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"0x68\",\"0x03\",\"0x01\",\"0x00\",\"0x22\",\"0xaa\",\"0x04\",\"0x9e\"]","payloadType":"bin","x":290,"y":700,"wires":[["108f6d38a4465865"]]},{"id":"6306a144b714f63a","type":"serial in","z":"b1e41431717e4e05","name":"","serial":"85ed1317.7df08","x":150,"y":820,"wires":[["b539eb2d1e88055f"]]},{"id":"108f6d38a4465865","type":"serial out","z":"b1e41431717e4e05","name":"","serial":"85ed1317.7df08","x":150,"y":760,"wires":[]},{"id":"b539eb2d1e88055f","type":"debug","z":"b1e41431717e4e05","name":"from serial port","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":420,"y":820,"wires":[]},{"id":"4291d5a4222128a3","type":"inject","z":"b1e41431717e4e05","name":"[\"0x68\",\"0x03\",\"0x01\",\"0x00\",\"0x22\",\"0xaa\",\"0x04\",\"0x9e\"]","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"0x68\",\"0x03\",\"0x01\",\"0x00\",\"0x22\",\"0xaa\",\"0x04\",\"0x9e\"]","payloadType":"bin","x":290,"y":440,"wires":[["815d91315a9adf9f"]]},{"id":"815d91315a9adf9f","type":"serial request","z":"b1e41431717e4e05","name":"","serial":"85ed1317.7df08","x":150,"y":500,"wires":[["77c7937de8058de1"]]},{"id":"77c7937de8058de1","type":"debug","z":"b1e41431717e4e05","name":"from serial port","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":420,"y":500,"wires":[]},{"id":"de62fc3ed3c6c8be","type":"comment","z":"b1e41431717e4e05","name":"Using the Request / response pattern","info":"","x":230,"y":400,"wires":[]},{"id":"aa2abd9269d72d90","type":"comment","z":"b1e41431717e4e05","name":"Using the In / Out pattern","info":"","x":190,"y":660,"wires":[]},{"id":"85ed1317.7df08","type":"serial-port","serialport":"/dev/ttyUSB5","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","waitfor":"","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"200","bin":"bin","out":"interbyte","addchar":"","responsetimeout":"2000"}]

```

---

_[View the full topic](https://discourse.nodered.org/t/how-do-i-use-serialport-node-to-write-to-a-rs485/63484)._
