Using Jupyter Notebooks

We included some examples to get you started with using Jupyter Notebooks with the Circuit Playground Express since it has lots of inputs and outputs to play with as is. 

Mac or Linux

You can start a Jupyter notebook by running the following in a terminal

Download: file
jupyter notebook

Windows

First, ensure there are no Jupyter terminal windows open (use the Ctrl-C key in the window to close one if you have one open. We'll start a new copy of Jupyter:

Start Button -> Anaconda -> Anaconda Prompt

The Anaconda command terminal will open. we need to go where the files were unzipped:

You'll have the (base) C:\Users\yourusername> prompt.

Type the following:

cd Downloads\CPK\circuitpython_kernel-master

There type jupyter notebook

Load up the Example Folder

OK no matter what you're running, you should have a screen like the one below on your Anaconda prompt window and the same Jupyter screen below as the mac/linux users.

If you started this from the directory we were using earlier (circuitpython-kernel), you'll see an examples/ folder:

If you don't see this folder, click the upload button on the Notebook Dashboard

Navigate to the folder for circuitpython-kernel (or circuitpython-kernel-master) you cloned or downloaded earlier. Navigate to the examples folder. Then, click upload on the imported notebook on your dashboard. 

Locate the CPX_Blinka.ipynb notebook but don't click it yet!

Plug In The CircuitPython Board

At this point, you'll want to plug in your board and verify it shows up as a mountable drive called CIRCUITPY

If you don't see the CIRCUITPY drive, install CircuitPython on your board.

Ensure your board is not connected to a serial terminal somewhere else on your computer, the kernel needs to make a connection to an open port.

Launch the CPX Blinka Example

OK now we're ready.

Click on CPX_Blinka.ipynb to launch the Jupyter Notebook and the CircuitPython Kernel. 

Make sure your notebook is running the CircuitPython kernel by clicking change kernel -> CircuitPython:

When you launch notebooks using the CircuitPython-Kernel, it'll search the serial ports on your computer and connect to your Adafruit CircuitPython board. 

The CPX_Blinka notebook should open. We're going to use the notebook and learn about Jupyter in the process.

The first cell should be highlighted. Each of these cells hold media (like pictures, equations, or rich text) or code, executable by your CircuitPython board. Click run in the toolbar or press shift+enter to run the cell:

As you go use the run command to move the cells, you should see the Circuit Playground's LED turn on when the cell containing cpx_led.value = True is executed:

Congrats - you just ran your first Jupyter Notebook!

Want to try another example? Navigate to the Notebook Dashboard and navigate to the examples/ folder.

Next, we'll learn how to create our own Jupyter Notebook.

Troubleshooting

I get a "The kernel appears to have died" dialog and then it enters a reset-loop

Open your terminal to view the errors from the kernel. If the problem persists, copy the output from the terminal and file an issue on the GitHub Repository for this project.

My terminal is displaying an error: Port must be configured before it can be used.

There's an issue with your serial connection which is preventing the kernel from opening a serial connection with your board. Make sure your drivers are installed correctly and the CircuitPython board is displayed as CIRCUITPY drive in file explorer.

This guide was first published on Jul 03, 2018. It was last updated on Jul 03, 2018. This page (Using Jupyter Notebooks) was last updated on Aug 25, 2019.