Remote development with Arduino + your favourite micro computer (e.g. Raspberry Pi)
🔧

Remote development with Arduino + your favourite micro computer (e.g. Raspberry Pi)

Created
Category
General
Platform
Technical setup
Arduino
Author
Description
Property

Intro

Owning one of the newer MacBooks that were designed for bad typing experience, noisy fans and port(un)availability I was facing unusual challenges. Also due to the fact I fried one of my ports once before I became rather cautious about this device and using off-brand-adapters.
Having that challenge combined with the assumption, we would work on that project in a group setting and would need to collaborate, I followed a different approach from the beginning.
"The future is wireless"
Knowing there are indeed wireless-capable Arduino's and other microchips out there which would work straight out of the box with the IDE, it was even more tempting to achieve the same with a tethered Arduino. Of course calling solutions like this (or even wireless charging) "wireless" is doubtful as we are just creating another intermediary and moving the cable away from the laptop - but hey, it is not in my way anymore and I can start the hardware prototyping in a dedicated place without restraint.

What I wanted to achieve

  • Everyone in the group work needs access and can participate to the code, without getting out of sync, without much plugging around across different computers or being dependant on internet connection in a physical place (e.g. when using GitHub).
  • It had to be wireless - I am using VS Code for pretty much everything and didn't want the dependancy on Arduino IDE and sticking the device straight to my computer, generate too much clutter on my table and eventually might damage something

Setting up VS Code server

  • Make sure, SSH is enabled (Raspbian not default, ARMbian by default)
  • SSH into your Pi by using Visual Studio Code
  • VS Code server will be installed on your current user
  • Compiling is done on the Pi, so no Arduino IDE needed on your computer
  • There are useful Arduino and Arduino-snippet addons for VS code though
 

Telling the Pi to compile

Warning! Inotool is deprecated and no longer maintained. But you can still install it - I personally still use it for the "serial" command I gotta explain later in this post.
sudo ino build && sudo ino upload && sudo ino serial
 
I started with this setup before the actual course. During the course I was realizing that the setup was not working flawlessly.
When starting to find the reason for that, I soon found that the used Arduino IDE version used for compiling was 1.0.5 and thus showed incompatibilities with different libraries, compiler errors that were related to the code in the first place, but then turned out to be compiler-related.
Although I knew, Inotool was deprecated I somehow still expected it to be using the version of Arduino I installed.

Babysteps with PlatformIO

 
For the sake of replacing the Arduino IDE (and now the Inotool CLI), I tried yet another approach a friend told me about.
After a certain amount if tinkering around however it turned out to be out of scope for now.
PlatformIO itself, although (or maybe that's why) it is advertised as the tool for everything, whatever I was trying to achieve seemed very complicated. But with more NodeMCUs and other stuff arriving in the next weeks I might get back to it very soon.

Switching to Arduino CLI

 

Compiling

arduino-cli compile --fqbn arduino:avr:uno
 

Uploading

arduino-cli compile --fqbn arduino:avr:uno
 

If you get permission errors when uploading

 
This will solve the problem for now, without the need to use "sudo" for uploading (which would not even work, as the cli is installed in your user's directory.
sudo chmod a+rw /dev/ttyUSB0

Serial communication

I did not figure out a way to get the serial communication to run with the arduino-cli, so I will stick to Ino for now
sudo ino serial
⌨️
Escape hatch from the serial display: Ctrl + A X (Keep holding Ctrl and press the buttons in a row to end the pipicom serial viewer

Running it all together

Good coders are lazy coders, we learned in the programming bootcamp back in year one.
When you are working in production mode and just want it to compile, run and output, this is the command to go for 🎉
arduino-cli compile --fqbn arduino:avr:uno && arduino-cli upload --fqbn arduino:avr:uno --port /dev/ttyUSB0 && sudo ino serial
 
 
 

Accessibility of terminal commands

When I started using a variety of

Reflection

 
Just wanted to share that - maybe interesting for some students but also less straight-forward to set it up initially than just plugging it into the local machine. In any case for me it worked better for embedded testing without the need to directly plug the computer to where the Arduino environment might be.