0

It’s now possible to open, edit, and save Python code on iOS for embedded electronics plugged in, CircuitPython USB devices! @apple #ios @circuitpython

Ipadyay-1

OK! Big news- It’s now possible to edit and save Python code on iOS to embedded electronics, CircuitPython USB devices!

This is a follow up to our post about Apple’s iOS 13 beta, which is now up to beta 5.

The upcoming iOS 13 allows iPads (and iPhones) to be more like computers, which means you’ll be able to do computer-like things such as plugging in a USB drive, opening up the Files app in iOS 13 and browsing the files. This is going to be fantastic for folks who want to use an iPad as their full-time desktop replacement, and if you’re a coder it looks like you’ll be able to do things like opening up Python .py files, use IDEs for coding, etc. A lot of schools use iPads, so this means any iPad will be able to be used to code for electronics: if the app can open a text file, it can be used to write Python.

iOS 13 beta 1 had some troubles: it deleted files off some devices that act like USB drives, for example, all the CircuitPython boards. But now the GOOD NEWS: we filed a bug report, and since iOS beta 5 IT IS ALL WORKING! This means any code editor for iOS can be used as a code editor for CircuitPython and you’ll be able to open, edit, and save your code to the device(s) plugged in to the iOS device!

Here’s a quick summary of how to edit a CircuitPython file now on an iPad running iOS 13 beta 5: plug in a CircuitPython board, such as a Circuit Playground Express, select a file on CIRCUITPY, drag or copy/paste the file to “On My iPad”, use an editor to change the file, then delete the original file on CIRCUITPY, copy/paste, share, or drag the file back to CIRCUITPY, giving it a new name, rename and it all saves and runs automatically. It’s awesome. The code editing apps are not aware of this new “USB storage” in iOS 13 yet; when they are (soon), it will be even easier. For now, just use the iOS Files app to move the files around.

Also, iOS 13 beta 5 clearly still has some bugs: you can’t save the file with its original name, so you need to to save with a new name, delete the old file, and rename the new file.

Version-1

We are currently using iOS 13 beta 5, released on July 29, 2019.

After loading the latest iOS 13 beta, we plugged in the Circuit Playground Express via USB to the iPad using the “Lightning to USB Camera Adapter.” For my demo, I have a code.py file on the device that runs the rainbow pattern. Once plugged in to the iPad, the Circuit Playground Express powers up and runs the program that is on the device (code.py).

Files

On the iPad tap the FILES app icon.

Listoflocations

Then, tap Locations > Browse and tap CIRCUITPY, that is the “USB Drive” that has the python code.

Press Hold

These are all the files on my Circuit Playground Express as viewed via the iPad.

Press and hold the code.py (displayed as code since it does not show the file extension at this time and/or I do not know the setting to change that). Tap COPY.

Copy On Local

Browse to the local file system (“On My iPad”) and paste the code.py file. Alternatively, you can drag code.py to “On My iPad”, though the dragging doesn’t seem to work all the time.

Koder

Now pick an app that can edit code. For the app to test out opening, editing, and saving the Python code that is on the Circuit Playground Express, we are using Koder. What is Koder?

Koder is a code editor for iPad and iPhone. It does have many features including syntax highlighting, snippet manager, tabbed editing, find and replace code, editor theme, remote and local files connections, and many more.

With Koder you can code anytime and anywhere, no matter if you’re at your desk or while on the go.

There are other apps for code editing on iOS (post your suggestions in the comments), this is one that I happen to use. We have also tried Textastic, and it also works.

01Open

01Open02

Open up code.py, in Koder I tapped Files, and then tapped the pad of paper with pencil icon.

02Open

03Open

Click “Open Other Apps’ File” and open code.py

04 Code Editing

Edit the code!

Listwithpresshold

Next up, after editing, go back to the FILES app, copy the saved code.py on the local iPad storage, then browse to CIRCUITPY and paste the file. iOS at this time will name it code 2 and does not overwrite it, so rename the current code.py (I used _code) and then rename the one that was just pasted to the CIRCUITPY drive. With CircuitPython, saving the code, and/or saving a file to the USB “drive” automatically starts the device and will run the code, again – automatically.

If you’re trying this with Textastic, the work flow is a little different. You can share the file from “On My iPad” to Textastic. Then edit the file. Then touch the Share icon in Textastic (in the three dots menu in the upper right), choose “Save to Files”, and save the file with a new name. Then go back to CIRCUITPY in the Files app, delete the old file, and rename the new one to the old name.

iOS 13 beta 5 clearly still has some bugs: you can’t save the file with its original name, so you need to to save with a new name, delete the old file, and rename the new file.

That’s it, it “just works” and it is really a great experience to code on my iPad with CircuitPython running on Circuit Playground! I’ll make a little video later, going to code on the couch with my iPad and CPX now 🙂


Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.

Join 14,000+ makers on Adafruit’s Discord channels and be part of the community! http://adafru.it/discord

CircuitPython 2019!

Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7:30pm ET! To join, head over to YouTube and check out the show’s live chat – we’ll post the link there.

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Follow Adafruit on Instagram for top secret new products, behinds the scenes and more https://www.instagram.com/adafruit/


Maker Business — A list of companies owned by Amazon. It’s big.

Wearables — Raid the kitchen

Electronics — Capacitor ESR

Biohacking — Vitamin-C + Gelatin for Accelerated Recovery

Python for Microcontrollers — Python snakes its way to the STM32, Serpente, and more!

Adafruit IoT Monthly — Adafruit IO Updates, RGB Stream Deck Message Panel, and more

Microsoft MakeCode — Welcome to the MakeCode Newsletter!

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at AdafruitDaily.com !



1 Comment

  1. This is really good news!!! I’ve been writing python on my iPad for years now (using Pythonista). I’ve built a number of small robots and I’m looking forward to being able to take my kit anywhere to work. Thanks for filing the bug and keeping on top.

    Now, we just need a IDE mechanism (app) to read the serial line while programming! : )

Sorry, the comment form is closed at this time.