# How can I compile and upload a .ino sketch file with Node-RED on a Raspberry PI to an Arduino

**URL:** <https://discourse.nodered.org/t/how-can-i-compile-and-upload-a-ino-sketch-file-with-node-red-on-a-raspberry-pi-to-an-arduino/73962>\
**Category:** General\
**Created:** [20 January 2023 12:40 UTC](https://discourse.nodered.org/t/how-can-i-compile-and-upload-a-ino-sketch-file-with-node-red-on-a-raspberry-pi-to-an-arduino/73962 "2023-01-20T12:40:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![hansb001](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hansb001/32/74715_2.png) [@hansb001](https://discourse.nodered.org/u/hansb001)\
**Post date:** [20 January 2023 12:40 UTC](https://discourse.nodered.org/t/how-can-i-compile-and-upload-a-ino-sketch-file-with-node-red-on-a-raspberry-pi-to-an-arduino/73962/1 "2023-01-20T12:40:32Z")

</div>

Hi I saw this topic a few times passing by, but they are rather old and had not really a clear answer. So I am asking again and have some additions. I have an Arduino controlling a simple robot (4 servo's) connect with a cable to the USB port of a Raspberry Pi which runs Node-RED. It would really help me if I can upload sketches to the Arduino from Node-RED. I can execute this command from the command-line: `arduino-cli compile --upload Blink.ino --port /dev/ttyACM0 --fqbn arduino:avr:uno` where it compiles and uploads the blink.ino. To do this with Node-RED I was thinking of using the `exec-node`, but the problem is where/how to get the file. Maybe you know to work with this. Another solution might be uploading it via the serial port, but the file needs to be compiled first. So my question in other words: How can I compile and upload a .ino sketch file with Node-RED on a Raspberry PI to an Arduino

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [20 January 2023 12:51 UTC](https://discourse.nodered.org/t/how-can-i-compile-and-upload-a-ino-sketch-file-with-node-red-on-a-raspberry-pi-to-an-arduino/73962/2 "2023-01-20T12:51:37Z")

</div>

Hi @hansb001 !  
Welcome to this forum & to the Node-RED community.  
I don't have a straight answer to your question, but rather a proposal...

Do you need to do this via an Arduino? Ever considered to go the "all Node-RED" way?  
Anticipating that your Arduino is an ESP device: We've created a suite to program ESP devices with Node-RED (called [Node-RED MCU Edition](https://github.com/phoddie/node-red-mcu)) & integrated this fully - in the sense of: Click one button, done! - into the Node-RED editor by the [node-red-mcu-plugin](https://flows.nodered.org/node/@ralphwetzel/node-red-mcu-plugin).

Being the author of this plugin, I could offer to support you on your way to change over to Node-RED MCU Edition ... if you are interested.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 January 2023 13:02 UTC](https://discourse.nodered.org/t/how-can-i-compile-and-upload-a-ino-sketch-file-with-node-red-on-a-raspberry-pi-to-an-arduino/73962/3 "2023-01-20T13:02:33Z")

</div>

Assuming the Arduino source-code is on a local dev machine and node-red is running on a server, you will need to upload the file to the server to a location where Node-RED can access it.

There are all sorts of ways to do that, both manually and automatically depending on your dev device, your workflow and what tools you use.

If you are developing directly on a Pi, then it is easier of course (though likely slow!).

---

<div class="post-metadata">

**Author:** ![hansb001](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hansb001/32/74715_2.png) [@hansb001](https://discourse.nodered.org/u/hansb001)\
**Post date:** [20 January 2023 13:08 UTC](https://discourse.nodered.org/t/how-can-i-compile-and-upload-a-ino-sketch-file-with-node-red-on-a-raspberry-pi-to-an-arduino/73962/4 "2023-01-20T13:08:09Z")

</div>

Thanks Ralph, I will have a look!

---

<div class="post-metadata">

**Author:** ![hansb001](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hansb001/32/74715_2.png) [@hansb001](https://discourse.nodered.org/u/hansb001)\
**Post date:** [20 January 2023 13:14 UTC](https://discourse.nodered.org/t/how-can-i-compile-and-upload-a-ino-sketch-file-with-node-red-on-a-raspberry-pi-to-an-arduino/73962/5 "2023-01-20T13:14:44Z")

</div>

thanks @TotallyInformation. The node-red is on the raspberry. I can access the .ino files, but how do I upload it to the attached Arduino? Using the exec node with the command above, gives me this message `{ _msgid: '50cdaefe23b0fe5f', topic: '', payload: '', rc: { code: 127, message: 'Command failed: arduino-cli compile --upload /home/tedge-child/arduino-1.8.19/examples/01.Basics/Blink/Blink.ino --port /dev/ttyACM0 --fqbn arduino:avr:uno\n' + '/bin/bash: line 1: arduino-cli: command not found\n' } } 20 Jan 13:32:01 - [info] [debug:debug 2] { `

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 January 2023 13:17 UTC](https://discourse.nodered.org/t/how-can-i-compile-and-upload-a-ino-sketch-file-with-node-red-on-a-raspberry-pi-to-an-arduino/73962/6 "2023-01-20T13:17:43Z")

</div>

OK, so it can't find the `arduino-cli` executable. Most likely because of how you are running Node-RED. There probably isn't a `path` environment variable set.

All you need to do is run `whereis arduino-cli` on a command line on the Pi and put in the full path to the executable which you get back from that command.

---

<div class="post-metadata">

**Author:** ![hansb001](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hansb001/32/74715_2.png) [@hansb001](https://discourse.nodered.org/u/hansb001)\
**Post date:** [20 January 2023 13:38 UTC](https://discourse.nodered.org/t/how-can-i-compile-and-upload-a-ino-sketch-file-with-node-red-on-a-raspberry-pi-to-an-arduino/73962/7 "2023-01-20T13:38:08Z")

</div>

that worked! I had the path before, but I made a typo. Thanks!

---

<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:** [3 February 2023 13:38 UTC](https://discourse.nodered.org/t/how-can-i-compile-and-upload-a-ino-sketch-file-with-node-red-on-a-raspberry-pi-to-an-arduino/73962/8 "2023-02-03T13:38:46Z")

</div>

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