In the last weeks I’ve spent quite sometime tweaking a Raspberry Pi 3 to be used as a  travel photo backup device. It has now become a travel access point, media sharing device and a time-lapse controller for my Sony A7II. It’s really a wonderful and versatile little device.

One thing that all these projects have in common is the Python programming language. In the last years, I’ve become a huge fan of it and have learned to use it to automate several tasks both at home and at work. However, programming in Python on the Raspberry Pi can be a less than enjoyable experience: the included IDE feels dated and moving around the OS GUI can be a bit frustrating when trying to multi-task. Additionally, all peripherals (monitor, keyboard and mouse) would need to be connected to the Raspberry Pi in advance, which is not really convenient if the device is being used as a travel computer.

I decided to try a different method for interacting with the Raspberry Pi and I can say it has worked wonderfully for me. Instead of working on the device itself, I just build the scripts on a different platform (Mac OS X, for example) and transfer/sync them through ssh to to be run on the Raspberry Pi. This allows me to continuing using the tools I would normally use on each platform and there is no need to connect any peripherals to the device.

The Setup

In order for this workflow to work seamlessly, you’ll have be able to connect to the Raspberry Pi through SSH. There are many guides online to do so (here is an excellent one). For a streamlined process, I have also setup passwordless SSH access.

A similar setup is needed for the iOS device that will be used to connect to the Raspberry Pi.

The Tools

Mac OS On MacOS X, the stars of the show are Sublime Text 3 and its excellent Sublime SFTP plugin. Granted, neither of these tools is cheap, but they are the best in their class, in my opinion. If you want a free and reliable option, the Atom text editor is a close second when it comes to power text editors. It’s Open Source, in active development and, just like Sublime Text; there is a plethora of plugins available. It’s easier to configure than Sublime Text, but that comes at a relatively small performance hit.

Just like most plugins for Sublime Text, the SFTP plugin is configured through JSON files (one per server). I created the one shown below and placed it in the same folder containing all files that will be sent to the Raspberry Pi.

Sublime Text 3 Window showing SFTP Plugin’s JSON configuration file.

The plugin has two main working modes:

  1. Server: Working off of a server
  2. Remote: Mapping a local folder to a remote folder

Certain operations are only allowed on a certain mode. For more info, visit the plugin’s site. I have mine setup as Remote, which is the workflow that works best for me. In this mode, all SFTP operations are handled from the file/folder context menu on the side bar.

The local folder can be synced with the remote folder on the Raspberry Pi or each file can be uploaded by hitting CMD+CTRL+U, CMD+CTRL+F. When Syncing all files in a folder, beware that the Raspberry Pi has no Real Time Clock (RTC) and gets it’s time/date when it’s connected to internet. This can potentially result in syncing errors. The plugin does a great job letting you know what’s going to change before syncing and I didn’t have any problems, but it’s something to keep in mind.

On iOS

I’m a fan of Panic. Every App they produce for both Mac and iOS is tastefully designed, fast and reliable. Coda is their text editor for iOS aimed at web development, but can also be used to program on languages like Perl, PHP, Python, Ruby among others. It supports both local and remote file management, SSH connections, SFTP, WebDAV and even Amazon S3.

Coda for iOS syntax highlighting for Python.

Files can be downloaded/uploaded to servers using any of the previously mentioned protocols, but the main strength in my opinion, is that it supports creating and editing files directly on the Raspberry Pi. Files will be saved every time the user taps on the check mark icon in the upper right hand corner

Connection to the Raspberry Pi is rock solid and fast, always returning to the same folder you were last in. For a moment, I thought the connection was somehow kept alive when changing sites or switching from remote to local folders. It’s that fast.

Another great feature is that a terminal window can be opened in a separate tab, so that the script a user is working on can quickly be run on the server (i.e. Raspberry Pi).

Coda iOS. Python script and SSH connection tabs.

Syntax highlighting for Python works great and the App auto indents the next line when tapping on enter. Also, there are features like autocompletion, Super Loupe (tapping and holding on text provides extra magnification to precisely set the cursor) and Clips (lightweight snippets of text that can be quickly inserted into the document editor).

All in all, Coda allows for a great edit-test-revise workflow. For quick and dirty tests and small scripts, it’s even faster than doing it in the computer.