Adafruit Circuit Playground Bluefruit

../_images/cpb.jpg

The Circuit Playground Bluefruit (CPB) is a microcontroller board sold by Adafruit which includes several useful sensors, color NeoPixel LEDs, and accessible electrical contacts. We will be programming it in CircuitPython. The board also supports programming in Arduino C++.

The CPB may be used standalone or in conjunction with the Adafruit Crickit baseboard which provides motor drivers, solenoid drivers, and additional I/O.

There are many other CircuitPython microcontrollers. For an inexpensive board without I/O, please see Raspberry Pi Pico. For a complete list, please see CircuitPython Downloads.

Features

The board includes a number of onboard sensors:

  • three-axis accelerometer, useful for tilt, tap, and fall detection

  • sound level sensor

  • ambient light-level sensor

  • temperature sensor

  • two pushbuttons

  • one slide switch

The board includes several outputs and external connections:

  • ten NeoPixel RGB LEDs

  • speaker with amplifier

  • red LED

  • eight alligator-clip-compatible general input-output pads, 14 pads total

  • Bluetooth Low Energy radio for wireless data communication

  • native USB (including human interface device emulation)

  • battery connector (but no charger)

Getting Started

Please see CircuitPython Introduction for a general guide to getting started with CircuitPython. This page will address only the details specific to the Circuit Playground Bluefruit (CPB).

Tutorials and Information Online

The CPB information online is scattered over several sites, so the following notes may help guide you to information specific to this board.

  1. Adafruit Store - Circuit Playground Bluefruit.

    This is the purchasing page at Adafruit.

  2. Adafruit Circuit Playground Bluefruit - Tutorial.

    This is a step-by-step guide to the Bluefruit microcontroller. The CircuitPython Playground section has a comprehensive set of example programs.

  3. Adafruit Circuit Playground Library - Tutorial.

    This is a convenience library provided for the Bluefruit which simplifies access to the onboard hardware. This narrative tutorial walks through the examples using the specific sensors and functions.

  4. Adafruit Circuit Playground Library - API Reference.

    Technical documentation on the convenience library, useful if you need a precise specification or to inspect the source.

  5. Schematic and Datasheet Downloads.

    The circuit diagrams may be useful to answer hardware questions.

CircuitPython Installation

Please note that we install CircuitPython on the Bluefruit before handing them out in class, so students should not need the following instructions unless a software update is required.

The CPB is shipped with a demo program installed but without CircuitPython onboard. Installation of CircuitPython is as easy as copying a file to a USB stick, but there are a few steps to prepare.

  1. There are two CircuitPython downloads required for installation: the core system and the library bundle. The core system is specialized for the particular board. The library bundle version must match the core system.

    1. Download the latest stable release of CircuitPython. This will be a .uf2 file from https://circuitpython.org/board/circuitplayground_bluefruit/. Multiple language translations are available.

    2. Download the matching release of the CircuitPython library bundle from https://circuitpython.org/libraries. This will be .zip file containing a large number of .mpy library files and sample code. You’ll be unpacking this on your desktop or laptop and installing just a subset of files.

  2. The Adafruit tutorial has a detailed installation description, but the process can be summarized as follows:

    1. Plug the board into a USB port on your computer; you’ll need a USB micro-B cable.

    2. Double-click the tiny RESET button right in the center. I find it helpful to use the blunt end of a pen.

    3. If successful, a new ‘drive’ will be mounted on your computer as CPLAYBTBOOT.

    4. Copy the CircuitPython .uf2 file you downloaded to this drive; drag-and-drop works fine.

    5. After a brief delay, CPLAYBTBOOT will disappear and a new ‘drive’ called CIRCUITPY will appear.

  3. After installing the core system, you can test it using your terminal emulator to interact directly with CircuitPython.

  4. The next step is to install the essential set of libraries from the bundle. The following list of libraries is recommended. After you unpack the library bundle .zip, please locate the following folders and files and copy them into the lib/ folder on your CIRCUITPY drive:

    • adafruit_ble/

    • adafruit_bluefruit_connect/

    • adafruit_circuitplayground/

    • adafruit_hid/

    • adafruit_lis3dh.mpy

    • adafruit_motor/

    • adafruit_thermistor.mpy

    • neopixel.mpy

    • adafruit_crickit.mpy

    • adafruit_seesaw/

  5. Now you may try out any of the course-supplied sample code by copying the corresponding .py file into the CIRCUITPY drive as code.py. For online examples, you can simply cut and paste into code.py using your Python editor. The default behavior is that saving a new version of code.py on CIRCUITPY will trigger a reload and it will immediately run. Syntax errors will generate messages on the serial console.

  6. The libraries bundle also includes a comprehensive examples/ folder. Some of these will work on the Bluefruit, most will not. The examples prefixed with circuitplayground_ are a good starting point.

  7. Next steps: some of the course examples will require Python programs running on your desktop or laptop, so you may wish to proceed with installing or upgrading Python as per Python 3 Installation.