Using Jupyter Notebooks with arduino (CircuitPython)

The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text.

That means you can program CircuitPython in it! You can also use Jupyter Notebooks for many other programming tasks, including processingJS.

In fact, you should go through the “classic notebook” tutorial in python. It runs in your browser, so nothing to install: go try it, click on ‚ÄčTry Classic Notebook. Go through each link in the Outline of some basics.

Installation for CircuitPython is mildly tedious. But, even I could do it. If you are using linux, you probably should use the anaconda install (because it needs certain versions of python3). The adafruit tutorial has an outdated link for anaconda, use this anaconda link instead.

In the adafruit tutorial, the “CPX_Blinka” example shows off a few things about Jupyter. It mixes code and explanation, including a picture. This makes it nice to document your code. You should work through the adafruit tutorial.

blink-jupyter

That grey box is live, runnable code! You’ll want to use the keyboard shortcuts, see the Help menu, Keyboard Shortcuts.

jupyter-keyboard-shortcut

Jupyter is really just talking to the REPL. So, your program won’t be persistent. But, you can easily export the .py file and drop it into the “circuitpy” drive. Use %softreset very carefully.

“JupyterLab” is a fancier version (also at https://jupyter.org), able to mix different notebooks, and more.

Sharing Jupyter Notebooks

Adding the hooks to save a .py and .html may be useful.

github knows how to render a _static_ notebook. It will look right, but you can’t run any code. It may be possible to integrate github and jupyter using this thing.

Binder can make a notebook runnable (but not editable). For example, it can run a notebook in github. But, it can’t do CircuitPython.

Google Colab lets you put the notebook in a google-drive, and run it, edit, share. You can use normal google-drive access control. No version control. Can’t do CircuitPython

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s