With the launch of iOS & iPadOS 13, iPhone and iPad now have the ability to edit code on CircuitPython USB devices. Users can connect a board such as Circuit Playground Express to their mobile device and edit & run code on the go.

For this guide, we'll be using a Circuit Playground Express, but the process should work with any of Adafruit's CircuitPython USB devices - click here for a full list.

What you'll need

• An iPhone capable of running iOS 13 or iPad capable of running iPadOS. Check your device's compatibility here.

Note that this tutorial is specific to Apple devices. It is hoped that other operating systems on other devices, such as Android, may work in the future.

iOS Lightning to USB OTG Cable

PRODUCT ID: 3940
Your iOS phone or tablet may not have a USB port on the bottom but that doesn't mean you can't use it to connect USB devices. Secretly known as a 'Camera Connector' or...
$17.50
IN STOCK

Circuit Playground Express

PRODUCT ID: 3333
Circuit Playground Express is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and...
$24.95
IN STOCK

USB cable - USB A to Micro-B

PRODUCT ID: 592
This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Metro, Feather, Raspberry Pi or other dev-board or...
$2.95
IN STOCK

If you're using an iPad Pro equipped with a USB-C port, skip the Lightning Adapter & USB A to Micro-B cable and simply use a USB-C to Micro-B cable:

USB C to Micro B Cable - 1 ft 0.3 meter

PRODUCT ID: 3879
As technology changes and adapts, so does Adafruit! Rather than the regular USB A, this cable has USB C to Micro B plugs!USB C is the latest...
$2.95
IN STOCK

First, let's check to make sure your CircuitPython & Apple devices are ready to talk to eachother.

Update CircuitPython

At the time of this writing iOS & iPadOS have been tested and confirmed to work with CircuitPython version 4.1.0.

Connect your CircuitPython compatible device to your computer (not the iOS device), and open the boot_out.txt file and check what version of CircuitPython you're running. 

If you don't see a file named boot_out.txt or you have an older (than 4.1.0) or alpha version of CircuitPython installed, update to the latest stable release using these instructions.

Update iOS/iPadOS

On your iPhone/iPad, check what version OS you're running by opening the Settings app and tapping General->About and checking the Software Version number.

If your version number is 13 or later, you’re good to go. If not, update your OS via Settings->General->Software Update

Connect CircuitPython device to iPhone/iPad

For devices with a Lightning connector – connect your Lightning to USB Adapter to iPhone/iPad and connect your CircuitPython device to the adapter via a micro USB cable.

For devices with a USB-C connector – connect your CircuitPython device directly to your iPad using a USB-C to Micro-B cable.

Copy, Edit, Paste

Screenshots below are from iPhone, but the editing process is the same for iPad

Copy code from CIRCUITPY drive

Plug your CircuitPython board, via USB, to your iDevice using the appropriate cable.

On your iDevice, open the Files app, and tap on the drive labelled CIRCUITPY. Locate the code.py file within. Tap and hold on code.py and choose Copy from the menu.

Paste code to internal storage

Next in the Files app, navigate back and tap On My iPhone/On My iPad.

Tap and hold on an empty area, and choose Paste from the menu.

Edit code

Open the App Store and search for the free app named Koder Code Editor and download/install it.

Open Koder and tap the new file icon in the lower left hand corner, tap Open Other App’s Files, then open the internal copy of code.py stored in On My iPhone/On My iPad.

Make changes to your code, then close the file – it will be saved automatically.

Overwrite original code.py on CIRCUITPY

Return to the Files app and navigate to On My iPhone/On My iPad. Tap and hold on the edited code,py file, and choose Copy from the menu.

Navigate to the CIRCUITPY drive, tap and hold in a blank area, choose Paste from the menu, and then choose Replace from the popup that appears.

Done

After a few seconds, your CircuitPython device should restart and begin running your new code. That’s all there is to it - enjoy the world of mobile embedded development!

Troubleshooting

CircuitPython device restarts intermittently

Your CircuitPython device may periodically restart while being powered by iPhone or iPad – for continuous operation, connect your board to a dedicated power source using the battery port.

Unable to replace/overwrite files on CIRCUITPY drive

Please check to ensure your running the latest 4.x stable release of CircuitPython by following these steps.

If your project requires CircuitPython 5.0.0 or later and you wish to edit your code on iOS/iPadOS follow these steps:

  1. Connect your CircuitPython device to your computer
  2. Open the CIRCUITPY drive (press CMD+Shift+period to view hidden files on macOS)
  3. Delete the file named .Trashes

You should now be able to delete and replace files on your CircuitPython device from iOS/iPadOS.

CircuitPython 5.0.0 uses a file named .Trashes which is hidden by default on macOS. This file prevents macOS from storing deleted files on the CIRCUITPY drive before the system trash is emptied – helping to conserve the limited storage space of CircuitPython devices. Currently, the iOS Files app is incompatible with this technique, and presence of the file prevents deletion of any other file on the CIRCUITPY drive.

CIRCUITPY drive does not mount on iPhone/iPad

Check to ensure your Apple device is running iOS or iPadOS 13 or later. If not, please update your device.

Can I use a USB hub?

Manufacturer designs vary, so we can't guarantee every hub will work for connecting to iPhone/iPad to your CircuitPython device. That being said, we didn't have any issues with the USB hubs we tested - so your hub will likely work as well.

This guide was first published on Sep 27, 2019. It was last updated on Sep 27, 2019.