Setting Up CircuitPython

CircuitPython is a programming language based on Python, one of the fastest growing programming languages in the world. It is specifically designed to simplify experimenting and learning to code on low-cost microcontroller boards. Here is a guide which covers the basics:

Plug your board into your computer via a USB cable. Please be sure the cable is a good power+data cable so the computer can talk to the board.

A new disk should appear in your computer's file explorer/finder called CIRCUITPY. This is the place we'll copy the code and code library. If you can only get a drive named PORTALBOOT, load CircuitPython per the guide mentioned above.

Be sure you have the latest CircuitPython for your board loaded onto your board, as described here. You will need at least version 4.1. You can tell the version of CircuitPython you have on the board by opening the file boot_out.txt on the CIRCUITPY drive which should show up when you plug your PyPortal into your computer USB port.

This project was written with CircuitPython 4.1 or greater in mind.

CircuitPython is easiest to use within the Mu Editor. If you haven't previously used Mu, this guide will get you started.

Libraries

Create a new directory on the CIRCUITPY drive named lib.

Download the latest CircuitPython driver package to your computer using the green button below. Match the library you get to the version of CircuitPython you are using. Save to your computer's hard drive where you can find it.

Download the adafruit-circuitpython-bundle-4.x-mpy-*.zip bundle zip file (replace 4.x with 5.x, etc. for later versions of CircuitPython if necessary), and unzip a folder of the same name. Inside you'll find a lib folder. You have two options:

  • You can add the lib folder to your CIRCUITPY drive. This will ensure you have all the drivers. But it will take a bunch of space on the 8 MB disk
  • Add each library as you need it, this will reduce the space usage but you'll need to put in a little more effort.

You need the following libraries for the UV Index display. So grab them and copy them into CIRCUITPY/lib now. The other libraries required are part of CircuitPython.

  • adafruit_bitmap_font
  • adafruit_bus_device
  • adafruit_display_shapes
  • adafruit_display_text
  • adafruit_esp32spi
  • adafruit_io
  • adafruit_pyportal.mpy
  • adafruit_requests.mpy
  • adafruit_sdcard.mpy
  • adafruit_touchscreen.mpy
  • neopixel.mpy

Some of these are used directly in our code, but many are used by the PyPortal support library.

Your CIRCUITPY/lib directory should look like:

This guide was first published on Aug 14, 2019. It was last updated on Aug 14, 2019. This page (Setting Up CircuitPython) was last updated on Sep 14, 2019.