# Cannot send command to Niryo Ned2 robot

**URL:** https://discourse.nodered.org/t/cannot-send-command-to-niryo-ned2-robot/95939
**Category:** General
**Created:** [12 March 2025 09:20 UTC](https://discourse.nodered.org/t/cannot-send-command-to-niryo-ned2-robot/95939 "2025-03-12T09:20:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Safouene28](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Safouene28](https://discourse.nodered.org/u/Safouene28)
#### Post date: [12 March 2025 09:20 UTC](https://discourse.nodered.org/t/cannot-send-command-to-niryo-ned2-robot/95939/1 "2025-03-12T09:20:08Z")

</div>

Hello everyone,  
I would like to know if someone has already worked on the niryo ned2 robot, I tried something simple to send a calibration command, but nothing happens, after some time, it disconnects. I know there is something missing. can someone help me please?

this is my flow:

 ![Screenshot 2025-03-12 100731](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/3/c323c721250b1c273d1bda61feb32d2985b2ad6f.png)

code:

```auto
[
    {
        "id": "12b20a78e760d478",
        "type": "inject",
        "z": "d19d1b39aea72fe2",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 180,
        "y": 980,
        "wires": [
            [
                "dd84ff25116cbb27"
            ]
        ]
    },
    {
        "id": "968218f53a74d945",
        "type": "debug",
        "z": "d19d1b39aea72fe2",
        "name": "debug 11",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 760,
        "y": 980,
        "wires": []
    },
    {
        "id": "dd84ff25116cbb27",
        "type": "function",
        "z": "d19d1b39aea72fe2",
        "name": "function 28",
        "func": "msg.payload={};\n\nmsg.payload = {'param_list': ['AUTO'], 'command': 'CALIBRATE'}\nmsg.host ='10.10.10.10';\nmsg.port =40001;\nreturn msg;\n\n",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 370,
        "y": 980,
        "wires": [
            [
                "75c674a7cd321ceb"
            ]
        ]
    },
    {
        "id": "75c674a7cd321ceb",
        "type": "tcp request",
        "z": "d19d1b39aea72fe2",
        "name": "",
        "server": "",
        "port": "",
        "out": "time",
        "ret": "buffer",
        "splitc": "500",
        "newline": "",
        "trim": false,
        "tls": "",
        "x": 570,
        "y": 980,
        "wires": [
            [
                "968218f53a74d945"
            ]
        ]
    }
]

```

link to example command using tcp protocol:

> **[Use Ned’s TCP server — Ned ROS Documentation v4.1.1 documentation](https://archive-docs.niryo.com/dev/ros/v4.1.1/en/source/tcp_server.html#use-ned-s-tcp-server)**

---

<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: [12 March 2025 10:55 UTC](https://discourse.nodered.org/t/cannot-send-command-to-niryo-ned2-robot/95939/2 "2025-03-12T10:55:14Z")

</div>

> [@Safouene28](#):
>
> `msg.payload = {'param_list': ['AUTO'], 'command': 'CALIBRATE'}`

According to the linked doc you are missing `json_packet_size`

> Every package have this following shape: \<json\_packet\_size\>{\<json\_content\>}.
> 
> The JSON packet size is an unsigned short coded on 2 bytes.
> 
> The JSON contains command’s name & params.

try...

```auto
const payload = { param_list: ['AUTO'], command: 'CALIBRATE' }
const payloadStr = JSON.stringify(payload,null,0}
const len = payloadStr.length.toString(16).padStart(2,'0') // length as hexadecimal
if (len.length > 2) {
   throw new Error('payload length is > 0xFF')
}
msg.payload = `${len}${payloadStr}`
return msg

```

_^ Untested ^_

```auto

```

---

<div class="post-metadata">

### Author: ![Safouene28](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Safouene28](https://discourse.nodered.org/u/Safouene28)
#### Post date: [13 March 2025 09:20 UTC](https://discourse.nodered.org/t/cannot-send-command-to-niryo-ned2-robot/95939/3 "2025-03-13T09:20:32Z")

</div>

Thanks for your help, I've just tested it but it doesn't work. I think maybe I need to configure the robot to receive the command or configure something else?

---

<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: [11 June 2025 09:21 UTC](https://discourse.nodered.org/t/cannot-send-command-to-niryo-ned2-robot/95939/4 "2025-06-11T09:21:00Z")

</div>

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