# Sending an \\r to TCP devices

**URL:** <https://discourse.nodered.org/t/sending-an-r-to-tcp-devices/50544>\
**Category:** General\
**Created:** [2 September 2021 14:19 UTC](https://discourse.nodered.org/t/sending-an-r-to-tcp-devices/50544 "2021-09-02T14:19:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![om327](https://avatars.discourse-cdn.com/v4/letter/o/3ab097/32.png) [@om327](https://discourse.nodered.org/u/om327)\
**Post date:** [2 September 2021 14:19 UTC](https://discourse.nodered.org/t/sending-an-r-to-tcp-devices/50544/1 "2021-09-02T14:19:14Z")

</div>

Hello,

I'm trying to connect to an external device using the TCP/IP node. I need to send the command string ON followed by a carrage return \r. I've tried sending ON\r using the exchnage function and the inject function but this doesn't seem to work?

I can connect to the device in other programming languages such as labVIEW soi know the command is correct and the device is functioning.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/f/2f8e3d0b15f124a0dada08eb22bf2e92294e78e4.png)

The TCP node indicates that it is connected to the device and a debug node confirms the string has been past correctly but the device does not seem to accept the command - is there another way to send a carrage return so its not part of the string?

Many thanks!  
Ollie

---

<div class="post-metadata">

**Author:** ![nlecaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nlecaude/32/25_2.png) [@nlecaude](https://discourse.nodered.org/u/nlecaude)\
**Post date:** [2 September 2021 14:26 UTC](https://discourse.nodered.org/t/sending-an-r-to-tcp-devices/50544/2 "2021-09-02T14:26:25Z")

</div>

Change your inject node to the JSON type and input  
"ON\r"  
that should work.

---

<div class="post-metadata">

**Author:** ![om327](https://avatars.discourse-cdn.com/v4/letter/o/3ab097/32.png) [@om327](https://discourse.nodered.org/u/om327)\
**Post date:** [2 September 2021 14:45 UTC](https://discourse.nodered.org/t/sending-an-r-to-tcp-devices/50544/3 "2021-09-02T14:45:35Z")

</div>

Fantastic - I thought it would be something simple! I couldn't get it to work using the inject node as JSON but could using the change node - why is that?

---

<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:** [2 September 2021 15:01 UTC](https://discourse.nodered.org/t/sending-an-r-to-tcp-devices/50544/4 "2021-09-02T15:01:54Z")

</div>

Show us how you configured the Inject node (when you configured it as suggested) and what it gives if you feed that into a Debug node.

---

<div class="post-metadata">

**Author:** ![nlecaude](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nlecaude/32/25_2.png) [@nlecaude](https://discourse.nodered.org/u/nlecaude)\
**Post date:** [3 September 2021 14:12 UTC](https://discourse.nodered.org/t/sending-an-r-to-tcp-devices/50544/5 "2021-09-03T14:12:01Z")

</div>

Should work the same:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/8/b8b6f28b5c1097c9ba65d30da6d08c34c4010fe2.png)

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [8 September 2021 14:33 UTC](https://discourse.nodered.org/t/sending-an-r-to-tcp-devices/50544/6 "2021-09-08T14:33:19Z")

</div>

When building raw tcp or serial data strings, I've generally used the `inject` node set to Buffer mode...

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

Click on the three dots `...` on the right end of the input field to open the buffer editor -- then just type the string and hit the `Enter` key to add the "\r" to the end of the string:

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

You can see the trailing return 0A character in the bottom window...

---

<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:** [7 November 2021 14:34 UTC](https://discourse.nodered.org/t/sending-an-r-to-tcp-devices/50544/7 "2021-11-07T14:34:14Z")

</div>

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