I've been using my iPad Pro as my daily driver at home for a bit. It's a great little computer and I find that it covers many of my needs. But one area where it doesn't quite match what I do is hardware hacking. The iPad doesn't really have the right hardware or software for working with stuff like Arduinos and other microcontrollers. But I've worked around that to that I can still do a lot of my coding on the iPad, while still being able to work with hardware.
The answer to the question "how can I use the iPad to work with hardware development" is simple: all I needed was a helper! In this case, it's a Raspberry Pi 3B+ running Raspbian Lite (sans desktop) and the great PlatformIO. This little single board computer has a few things going for it. It's cheap, small, had 4 USB ports via its onboard hub, and is pretty fast for a system the size of a pack of cards.
My workflow for something like Arduino dev these days looks more or less like this:
- I write code on my iPad using Working Copy
- I push that code to a local repo on my Raspberry Pi
- I SSH into the Raspberry Pi from the iPad
- I checkout the new code to a local working copy, and compile it with PlatformIO – If everything compiles, I use PlatformIO to flash the new code to a device – At some point, once I'm happy with where things are I push the code to Github
- Rinse and repeat!
I use a few different compnents to make all of this work:
- my iPad Pro
- Working Copy - this is a great app. It combines a decent (for iPad, at least) code-oriented text editor with a full featured Git client
- Github - where I keep my public repos
- PlatformIO - cross platform framework, board, and library/dependency management tools.
- A Raspberry Pi 3B+
In this setup, I have two working copies and two remotes. The "remote of record" is Github. That's where I made my code public and it's a reliable place for me to keep code. I normally start a project locally, then set up a Github remote and push to it to kick things off. I use my local working copy as normal.
I also have a second remote set up locally on my Raspberry Pi, which I set up Working Copy (the app) to use as a second remote for my working copy (the git thing). I restrict this remote to push-only, as I want all of the code to flow one way: from my dev working copy into the local remote.
In addition to hosting the local git repos, the Raspberry Pi has local working copies, cloned from the local repo. I typically only fetch/pull into this working copy, since it's not really something I'm working in. It just exists so I can locally execute build and uploads with PlatformIO. Because that's the case and based on the fact that what I often do after a push in run the build, I'm considering adding a local CI server to the Pi to run the build after each push. That way I can automate a step and get notification when a build fails without having to SSH into the Pi.
A couple of quick notes on how I do this.
- On the Raspberry Pi, I create a new bare repo with a name that matches the Github remote.
$ mkdir ~/repos/srv/some-repo-name.git && cd ~/repos/srv/some-repo-name.git
$ git init --bare
Once that's done, I configure working copy on my iPad to use the local server as a remote, which means
pointing to something like [email protected]:repos/srv/some-repo-name.git
. I configure the remote as
push only. Note that I use SSH to get to my repos.
A quick aside: I use an IP address to refer to my Raspberry Pi for various reasons, but I could also have
used its hostname thanks to MDNS advertising, in which case I'd point to me@rpi:repos/srv/some-repo-name.git
when setting up the new remote.
Once that's set, I create a local working copy on the Raspberry Pi, too.
$ cd ~/repos/wc/
$ git clone ../srv/some-repo-name.git
One area where this setup falls apart a bit is in kicking off new project. For example, I use PlatformIO for my hardware projects. It's really simple to get a new project set up with platformio init
on the command line, or from a PlatformIO IDE integration. Unfortunately Working Copy doesn't have the former, and the iPad doesn't have a command line or any way to install the PlatformIO tools (hence this whole setup!).
This means that I have to start on something like the Raspberry Pi if I want to let the tools do the work for me. So I do the following when starting a project new:
- On the Raspberry Pi, create a new directory, use
platformio init
(with whatever options I need) - Create a new, bare repo on Github
git init
in the new project folder- Add Github repo as a new remote
- Do enough work for an initial commit on the PI (usually just the README and a scaffold in
src/main.cpp
) then commit and push upstream to Github - Confirm Github got the push, then delete the repo on the RPi
- Check out the Github repo to iPad with Working Copy
At this point, this are pretty much ready to go. I follow the steps above to create a new bare repo/working copy on the Raspberry Pi, and set that up as a remote for the iPad.
Not the most elegant solution, but it doesn't take that long to do.