I have Arduino IDE installed on my laptop and I'd like to program a remote Arduino (Uno) that is connected to a remote machine in the same network, say, for instance, a Raspberry Pi (to which the Arduino Uno would be plugged with the USB cable) connected to my wireless network. What would I need to set up to do that?
Note: I don't mean to use the Arduino as a SSH client. What I'd like to do is some kind of tunnelling, preferably SSH, between Arduino IDE on my laptop and the Raspberry PI, to which the Arduino board is connected with the USB cable.
Ideally what would happen when I press the Upload
button is that the firmware, compiled locally would then be sent to the remote Arduino through the tunnel. Also I would use the serial monitor to remotely connect to the /dev/ttyACM0
device node on the remote Pi.
Best Answer
Lacking a usb device proxy (usbip as of Feb 2016 does not appear to be very portable) another method is to install
avrdude
on the Arduino-connected system (REMOTE). If this is possible, then the Arduino IDE running system (CLIENT) can be instructed to call a program that connects toavrdude
on REMOTE. Downsides: requires fiddling around in the Arduino IDE configuration files, probably fragile, will require additional work to support things likearduinoOTA
and so on...The Arduino IDE should contain
programmers.txt
andplatform.txt
configuration files (located for example underArduino.app/Contents/Java/hardware/arduino/avr
on the mac version). What we need in these files is a new programmer that will make a connection to REMOTE and pass along the data to upload, and then on REMOTE to issue the actualavrdude
programmer command using the data passed from the CLIENT system.CLIENT programmer
In
Java/hardware/arduino/avr/programmers.txt
add something likeMore complicatedly, in
Java/hardware/arduino/avr/platform.txt
duplicate all thetools.avrdude.
containing lines and adjust these to instead be namedtools.avrrelay.
and where necessary instead callavrrelay-client
(most of these lines are not necessary but it's probably easier to sub all of them than to figure out which are necessary):Then in the
Java/hardware/tools/avr/bin
directory (which should be identical to theruntime.tools.avrdude.path
config option) createavrrelay-client
and make it executable:REMOTE script
The Arduino IDE has a preference option to show verbose output during the upload, which will reveal the command that is run.
This command can be copied and adapted for the code on REMOTE, though
avrdude(1)
indicates that a filename must be specified, so the copied data will need to be placed in a tmp file, and that fed toavrdude
; this is theavrrelay-remote
program called by the CLIENT; it will need to bechmod +x
and called by full path or located in a SSH-availablePATH
directory.In theory, restart the Arduino IDE and try using the new "AVR RELAY" programmer. Use your mad debugging skills to figure out where it breaks down, repeat.
remote serial monitor
For the serial monitor to work remotely, a likely option would be to forward that via
socat
:Unbuffered socat command to connect serial ports in remote machines and log the data