Getting Started

Adafruit Playground is a wonderful and safe place to share your interests with Adafruit's vibrant community of makers and doers. Have a cool project you are working on? Have a bit of code that you think others will find useful? Want to show off your electronics workbench? You have come to the right place.
The goal of Adafruit Playground is to make it as simple as possible to share your work. On the Adafruit Playground users can create Notes. A note is a single-page space where you can document your topic using Adafruit's easy-to-use editor. Notes are like Guides on the Adafruit Learning System but guides are high-fidelity content curated and maintained by Adafuit. Notes are whatever you want them to be. Have fun and be kind.
Click here to learn more about Adafruit Playground and how to get started.
-
TM1814 LEDs with CircuitPython & RP2040 There are a lot of addressable LEDs out there. The chief variant is NeoPixel .. NeoPixel and Dotstar. Our two types of addressable LEDs are NeoPixel and Dotstar .. and TM1814....
(you get it right? It's like the Spanish Inquisition skit, but about LEDs?)
Long story short: TM1814 addressable LEDs can work with CircuitPython on the RP2040, but you'll have to use some custom code to talk to them. The TM1814PixelBackground class is a PixelBuf, though, so you can use it with the LED animation library no problem.
There's one big difference with TM1814 LEDs: The logic levels are inverted compared to NeoPixels. And, the first 64 bits are an overall brightness value. Two differences. The bits are inverted, and the timing is subtly different, and there's an overall brightness value. And if you don't continuously update the pixels, they enter a test mode. Four. Four main differences. And often the strips are powered from a higher voltage like 12V.
You have one last chance left to show me the source code
But first! You'll want to make sure you're using CircuitPython 9.2, at least 9.2.0-beta.0 or newer. It seems there was a teensy, tiny bug in CircuitPython that you'd encounter if you used this code. So with that out of the way
Two, I'll allow you two last chances to show me the source code
Grab the code from below (or from github) and place it on your CircuitPython device as code.py. Then, hook up your TM1814 strip to CircuitPython's GND and A0 pins. Hook up appropriate power to the TM1814 strip (mine was labeled "12V", so I used a 12V supply. 5V definitely didn't work! And definitely don't cross-connect the LED strip's supply into the RP2040's VCC or +5V!).
When the CircuitPython LED code is not running (or if it malfunctions) you get an obnoxious test pattern generated by the TM1814 LEDs themselves. Sorry, there's nothing we can do about it.
Once the code's running you'll get a comparatively soothing rainbow LED animation instead.
If you won't show us the source code I'm afraid we'll have to put you in the Comfy Chair
-
Make Code on the Go - Makecode.Adafruit, that is.... I am a big fan of "being able to code whenever/wherever I am." That's why I bought a wireless keyboard for my iPhone, when I realized I could edit CircuitPython programs using my phone. It's one of my favorite things about the Micro:Bit - the App lets you write and upload code from your phone.
But I didn't think I could do that with makecode.adafruit.com programs for the Circuit Playground. I was wrong, in fact it's pretty easy. I just needed a lightning-to-USB adapter so I could download the code!
First - load your code in your browser (like the picture above).
Next - click the download icon in the lower left.
Then, click the file link above, to "open in a new tab."
-
A PyDOS Handheld I was looking to try out my new Adafruit Feather RP2350 and I remembered I had the Solder Party Keyboard Featherwing.
The Keyboard Featherwing is a handy device: it is about the same size as a BlackBerry phone with the same alphanumeric keyboard and a 2.6" 320x240 color display. Plug in a Feather board as the "brains" and you have a portable system.
Alas, one has to program the Feather, preferably with CircuitPython, to use the keyboard, display, and other features. Solder Party has example code snippets for those features. But what about something more holistic, more like a computer with input and output?
I found two solutions that were perfect: PyDOS and Beryllium OS. Both are built on top of CircuitPython.
PyDOS emulates MS-DOS commands used on PC compatible computers. And Beryllium OS, formerly ljinux, acts as a Linux-like computer. Neither are binary compatible (they cannot run native DOS or Linux binaries) but their commands and interactions emulate those operating systems.
This Playground Note will show you how I built my PyDOS handheld in short order.
There are two videos, one from Adafruit Show and Tell and another for Tom's Hardware The PiCast.
Preparing the Feather
Solder male pin headers onto the Feather RP2350. You could use long pin stacking headers to add a FeatherWing, but that would create quite a stack on the back.
See this guide page for soldering details:
-
Home Assistant WiFi Button with CircuitPython Have you ever wanted to connect a simple button or sensor to Home Assistant using Circuit Python? This script demonstrates registering a device with Home Assistant so that it can be automatically connected to an Automation. The script triggers its event on power-on. The example uses the "trigger" type, which is better than "button" for a simple remote control. Other MQTT integrations could put a sensor reading on the dashboard, or turn your CircuitPython board into a WiFi light or fan.
Ingredients
- ESP32-C3 board running CircuitPython 9.1.4
- Home Assistant with the MQTT integration and broker, accessible to the local network
This script also demonstrates setting a BSSID, a 12-digit hexadecimal string, to connect to a specific access point.
I was not able to connect to my local
mosquitto
MQTT broker over ssl; something about how the the MQTT client and broker interact prevents CircuitPython from validating the certificate. The comments include an example of loading a custom root certificate for the connection.How It Works
Home Assistant's MQTT integration listens on the
homeassistant/device_automation/#
topic for discovery messages. When it sees a properly formatted message, it adds or updates that device underSettings > Devices and Services > MQTT > devices
. It also listens ontopic
, herecircuitpy/{unique_id}/action
, for commands from the device. For a two-way device, you can also set a topic for Home Assistant to send commands back to CircuitPython.Now, we can add our device to an automation in Home Assistant without any additional configuration.
Going Further
Can we send our configuration messages with
mqtt_client.publish(topic, msg, retain=True)
so Home Assistant will remember us, even if it restarts before we do?Can we configure our CircuitPython board as a Home Assistant temperature sensor?
Can we put the device in low power mode, wake on a pin change, and make a real battery-operated remote control?
Use nginx to proxy SSL instead of mosqitto's idiosyncratic support.
See also
-
Project Nyota Language tools for NeoTrinkey
Inspired by Star Trek's Nyota Uhura, these programs provide a way to use a NeoTrinkey to review alien (or foreign) language words or phrases. They are all contained in my github archive Project Nyota.
There are two programs, langtutor.py and langtest.py - copy the one you want to use to code.py. The helper files wise.py and prt.py are required.
The file "langs" is a list of the languages to review. Each line in "langs" should be the name of a file containing language information. In this archive the languages are: klingon, vulcan, mandoa, and Swahili (in honor of Uhura - "Nyota" means "star" in Swahili).
Language files should be in the form:
"Word-or-phrase", "target-language-translation" "Word-or-phrase", "target-language-translation" "Word-or-phrase", "target-language-translation" ....
When either program runs, you'll see:
number of languages: 4 klingon vulcan mandoa swahili Current lang: klingon
To toggle between languages, touch pad #1. When you reach the one you want to review (for the langtutor.py program) touch pad #2 and you'll see 5 random review pairs. For example from the Mando'a set:
You're right. : Gar serim. twenty : ad'eta seventy : tad'eta eighty : shehn'eta Good. : Jate.
With the langtest.py program, when you choose a language and touch pad#2, you'll get four tests where you're given a word or phrase, then a choice of two possible answers in the target language. Touch #1 or #2 to choose. A pixel will light green or red to indicate if you are right or wrong. (If wrong, the correct answer will be given). After four questions, you can touch #2 to get four more, or touch #1 to change languages.
For example:
Current lang: vulcan advise 1:lahso 2:a'Tha correct! walk (action-word) 1:imroy 2:lahso yes! 'logic', reality-truth, the way things are. 1:c'thia 2:lahso wrong: c'thia 'immanence' direc experience of the creator 1:kah-hir 2:a'Tha correct! touch #2 for another quiz, or #1 to change language.
When running the programs, you can set the variable REPL to "True" or "False" to direct the output. If REPL=True, all output is sent to the REPL. If it is False, output is directed as if typed using the HID interface. There is a delay when that is the case, to give you time to switch to an open editor window to receive the output.
Note:
Copy all these files to the neotrinkey: langtutor.py, langtest.py, wise.py, prt.py, langs, klingon, vulcan, mandoa, swahili. Then copy langtutor.py or langtest.py to code.py to run.
Language sources:
- Swahili vocab from: https://www.fluentin3months.com/swahili-words/
- Mando'a vocab from https://mandoa.org/ Note: the Mando'a language from Star Wars was developed originally by the author Karen Traviss for the Mandalorian people
- Klingon vocab from: https://kli.org and https://hol.kag.org
- Vulcan vocab from: https://tinyurl.com/VulcanArchive - archive.org of Marketa Zvelbil's original Vulcan work (note: In case archive.org is not available, I've copied the Dictionary and Lexicon to vulcdict.txt and vulcanlex.txt)
- To create your own language, you can use a tool like this: https://rollforfantasy.com/tools/language-generator.php
Nyota Uhura -
Display AIO+ Local Weather Conditions: MatrixWeather System The objective of this project is to replace the existing WeatherMatrix project's MatrixPortal M4 display with a newer version that uses weather data provided by Adafruit IO Plus (AIO+) instead of the openweathermap.org web API. The requirements include:
- Implement with CircuitPython for ease of development and prototyping.
- Duplicate the existing 64x32 LED matrix display layout including label colors and icons.
- Develop an architecture to support multiple autonomous displays and local data feed devices (new).
- Utilize a weather data source that accurately aggregates station information that closely matches local conditions.
- Weather data updated approximately 3 times per hour and is reliably available.
- Service subscription is free or reasonably priced.
- Include data elements for wind gusts and local workshop temperature (new).
- Display a progress bar to indicate data time since last update (new).
- If possible, use the existing MatrixPortal M4 hardware; upgrade to MatrixPortal S3 only if necessary.
Special Acknowledgements
Thank you to John Park for the initial weather display design concept (see Weather Display Matrix) that inspired this project. Also, the work of Trevor Beaton was instrumental in creating the updated display design with a clearer and simpler coding approach (see itsaSNAP Daily Weather Forecast Board).
Choose a Weather Observation Source
Three options for sourcing weather data were considered. Here are some pros and cons of each.
openweathermap.org:
- utilizes the existing or similar web API; minimal code changes will be needed
- weather station aggregation often doesn't always match local conditions
- data retrieval throttling is reasonable with a consistent service level
- free service was phased out; will eventually require paying for the service
weather.gov:
- a moderately well-documented web API; moderate code changes will be needed
- weather station data is not aggregated and closely matches local conditions
- single weather station data is not reliably available, sometime for hours at a stretch
- data retrieval throttling is currently reasonable, but without a guaranteed service level
- a free service
AIO+ Weather (Apple WeatherKit):
- moderately well-documented CircuitPython library approach; major code changes will be needed
- weather station data is aggregated and matches local and iPhone conditions
- data retrieval throttling is reasonable with a consistent service level
- weather data and workshop conditions can be combined and viewed on a web-based IO dashboard
- requires a paid subscription to AIO+ for access to its Weather Service
The choice to use AIO+ Weather was an easy one since my existing weather tracking and corrosion monitoring projects require a subscription to AIO+. We'll need a new system design and a major rewrite of the existing MatrixWeather project code to make this happen, providing ample opportunities to improve performance and reliability. The next step was to redesign the overarching weather system architecture.
See weather.gov: A Truly Free Weather API and AIO+ Weather: A Premium Alternative for Local Observations for a detailed discussion of each alternative.
-
Installing Python 3.13 using uv I use Debian Linux; the current stable version of Debian has Python 3.11.2. At the time I write this, Python 3.13 has just been released. So I used my desire to try out the new Python as a chance to explore uv as well. My instructions here are tested on Debian Linux, but may work with modifications on other Linux-based systems like Ubuntu or Raspberry Pi OS.
What's uv, anyway?
uv is "An extremely fast Python package and project manager, written in Rust." It's on github and pypi and is also well-documented.
Among its many features, uv is capable of managing multiple versions of Python, so I decided to use it to test drive Python 3.13.
Installing uv via pipx
First, install the pipx command using the operating system package manager. (debian package name: pipx)
Then, install uv:
pipx install uv
Once you've done this, you should have the
uv
command available. However, you may see a warning like this: -
Pumpkins vs Skeletons Game for CircuitPython This is a game about skeletons, pumpkins, and a catapult having a Spooky experience under the full moon. If you've thought about making a game in CircuitPython but aren't sure where to start, this project might be a useful source of ideas.
Charging a Pumpkin
This is how it looks when you hold the USB gamepad's A button to charge up a pumpkin.
-
Keyboard Featherwing Messenger powered by LVGL Several years ago Solder Party released the Keyboard Featherwing, a PCB that combines a Blackberry keyboard, a 320x240 TFT resistive touchscreen display, a 5-input DPAD, 4 tactile buttons, a microSD card reader, and more, all driven by an Adafruit Feather board of your choice. Eventually these were discontinued, I'm assuming because of the difficulty of sourcing the increasingly rare Blackberry keyboards. I didn't know what I wanted to do with them at the time, but I knew I was gonna want to do something with them at some point, so I ordered several of them before the stock was depleted.
One popular use for the Keyboard Featherwing has been to pair them with LoRa radio transceivers, to create a set of "Doomsday Messengers". These are devices that are able to send short text messages to each other using radio signals, sort of like walkie-talkies, but for text messaging. This makes sense: with the tactile keyboard, huge display, and instant compatibility with the Feather ecosystem (including the ability to use rechargable LiPo batteries), the Keyboard Featherwing practically seems designed for the use case!
I hacked together a quick demo a few years ago allowing for very basic communication between the devices, and then promptly lost interest. I wanted to write firmware that allowed for robust, reliable communication between the devices, but I also wanted something offering some of the affordances of a modern smartphone UI. If you've ever worked on UI for microcontrollers, you probably realize there are a lot of challenges. One of those challenges can be figuring out how to write a custom, complex UI with just the basic drawing functions provided by the commonly available drawing libraries. While possible, it can be really cumbersome once you start to want more modern UI features, such as widgets, scrolling, animation, multi-screen interfaces, and so on. Another challenge is implementing all of that in a performant way, given the limited speed and memory of most microcontrollers. At the time, I wasn't sure how I was to accomplish this without pulling my out my hair, so the project was put on the back burner.
Recently I decided to dig these up and give it another shot. I still wasn't sure exactly how I was going to do it, but I did have a concrete feature set in mind:
- The ability to send encrypted, reliable messages between two paired devices using LoRa technology
- The ability to pair each device with any other device using the same hardware and firmware, via a settings screen (i.e., no re-compilation needed to pair devices)
- The ability to modify and persist device settings and a small message history across power cycles
- Granular battery monitoring; specifically the ability to see the percentage of battery life remaining at any given time
- Heavy focus on physical controls, using the touchscreen to supplement the UI only where practical and/or necessary (if you aren't familiar with any of my previous projects, I'm a huge fan of physical controls)
Which Feather?
-
E-Ink Countdown in CircuitPython with Custom Stand Along the way I learned a few things:
- How to take an Adafruit PCB design in Eagle format and import the board outline all the way into FreeCAD for locating dimensions and features
- How to make my code robust against transient errors like network errors
- How to make my code deep sleep for the right length of time
There are also a few things this code demonstrates that are less common knowledge:
- Using fonts from the font bundle
- Using the datetime module for arithmetic on dates & times
- Increasing reliability by re-trying operations that can fail
- Reducing battery usage by deep sleeping and avoiding connecting to WiFi
This project uses FreeCAD & KiCAD, both of which are Open Source software that are free to download & use.
Parts Needed
Code & Installation
I recommend using Adafruit circup to install the needed libraries for projects. Here's what you need to do:
- Install circup on your desktop computer
- Enable the "fonts bundle" by running this command (just once, circup remembers this setting):
circup bundle-add adafruit/circuitpython-fonts
- Copy code.py to your CIRCUITPY drive (Download it via the "raw" link at https://gist.github.com/jepler/b2c020a6caa65a31297053b7216fcc15)
- Run the following command to auto-install required libraries:
circup install -a
You'll also want to configure wifi on your device using settings.toml. For lower power usage, configure WIFI_SSID and WIFI_PASSWORD options. For web workflow but higher power usage, configure CIRCUITPY_WIFI_SSID and CIRCUITPY_WIFI_PASSWORD options.
-
Creating Reduced Sized Bitmap Fonts From .ttf File ... using FontForge
Because CircuitPython uses bitmapped fonts (.bdf) as well as the binary .pcf format but many free fonts online are in .ttf format, following the Custom Fonts for CircuitPython Displays learning guide I came up with a cheatsheet to quickly take a full font, select only the limited characters I wanted and generate a small .bdf file. As I only do it once in a while if I don't write it down I wouldn't remember. Below is all covered in the above linked learning guide, but I wanted a quick and dirty cheatsheet, so here it is.
-
Open .ttf font file in FontForge
-
Select characters wanted including space before the “!” (you may need to scroll up). This is important and is missed in the learning guide example screenshot. Without selecting the ASCII 32 spot before the "!" character you won't have a way to display a space, so your display willlooklikethis. See first graphic below showing red box of missing space character you want to be sure to select.
-
Besides the basics of numbers, letters, and punctuation, be sure to select any others you want. I have noticed many .bdf fonts, including CircuitPython's built in terminalio.FONT, don't include a degree symbol (e.g. 78°F will display as 78F) even though many projects people create include temperature. So grab that symbol plus others that might be useful such as ± as another example.
-
Edit -> Select -> invert selection (selects everything you don’t want).
-
Encoding -> Detach & remove glyphs… (everything you don't want is removed)
-
Element -> Simplify -> Simplify and click OK on the warning box.
-
Element -> Bitmap Strikes Available…
-
In 3rd field, Pixel Sizes, enter size you want to create. For example if you want a 36 pixel font then type "36" (the first two fields will auto fill with values). Note that when you create a .bdf file you are only creating a file for that one pixel size.
-
File -> Generate Fonts…. Pick location to save then click Generate. Accept default of Other = 96.
To create other sizes go to step 7 and change the pixel size to the next pixel size file you want to create from the same font and characters already selected earlier. For example if you had just created a 36 pixel font, now change it to 24 in step 8 and generate the new file (step 9). Repeat for as many sizes as you need.
Finally if you really want to make the files small, following the online instructions using the web based Adafruit tool you can convert the .bdf files you just created to even smaller .pcf files. As an example, a (downloaded from Adafruit but further reduced by me) Arial-Bold-36.bdf font which was already a very compact 25kB on my disk got reduced further to a Arial-Bold-36.pcf file of only 16kB.
-
-
Set your sensor polling frequency to anything - WipperSnapper + API "testing" Adafruit IO I work on Adafruit IO, and I've had this mischievous plan for a while to adjust my WipperSnapper no-code sensor devices to poll more frequently than the 30s minimum that the web interface offers, like maybe as low as 5seconds to avoid burning my toast (having recently tried measuring the particle emissions again but found it too infrequent).
So Saturday morning I was having a prod at the firmware (you can too as it's open source code) and watching the API calls in the network monitor to see where gets prodded when the user changes a sensor to read every 30s.
-
Launching from DS9!!! Anyone who has seen the miniature 3D printed Trek and Star Wars ships hanging over my workbench (thanks, Thingiverse!) won't be surprised how many of my projects take an SF bent. But I've also got a space station!
And that inspires this Circuit Playground Express project - launching probes into the Bajoran Worhmhole!
I've got a repository for the code at DS9-game:
There are three files, two CircuitPython, and one JavaScript (or you can follow the makecode.com link)
- ds9.js - Javascript/Makecode version of game (https://makecode.com/_KhmDoYXCpVdh)
- ds9.py - CircuitPython version (rename to code.py)
- bach.py - helper code for music and sounds for ds9.py
It is a pretty simple game using the Circuit Playground circle of neopixels.
The premise is the space station Deep Space Nine (a blue neopixel) is in motion near the Bajoran Wormhole (a neopixel of shifting color). As the station shifts back and forth, the wormhole remains the same distance (five neopixels away). The station is launching automated probes to the wormhole - A sends them counter-clockwise, B sends them in a clockwise direction. You have ten probes to launch - if they successfully enter the wormhole, there will be a rainbow of neopixels across all ten. When you have sent all ten, you'll see pixels representing how many you managed to send into the wormhole (0-10). For the Makecode version, shake the CPX to restart. For the CircuitPython version press A or B.
Both versions make a sound when launching the probe, and will play a scale or musical flourish when you succeed. To turn that off, slide the switch to the left. To the right turns the game sounds on.
I found the differences in coding Makecode and CircuitPython versions interesting. With Makecode I could have multiple "forever" loops handling different actions - toggling Booleans to activate/deactivate them. With CircuitPython I used a single game loop and controlled the movement of the probe with a Boolean and a counter (it can only go 4 steps). The same Boolean prevents the A/B buttons from launching more than one probe at a time.
Give it a try - see how many you can get to land in the wormhole!
-
Create a Looping Apple Shortcut for Sending Data to itsaSnap Recently I've been experimenting with Apple Shortcuts to interface with the new itsaSnap app. This app lets you interface with Adafruit IO feeds on your phone. With Apple Shortcuts, you can get data from your phone to Adafruit IO. You can, for example, send health data, weather data, even encoded photos.
One topic that comes up in Apple Shortcuts is not being able to easily create an automated Shortcut that loops. For example, having data be sent every 30 minutes. There is a time automation, but you have to setup an automation instance for every time you need the Shortcut to run.
I wanted to figure out a way to do this and found a helpful post on the Apple Shortcuts subreddit that describes using alarms as a workaround. I normally avoid Reddit but that particular subreddit has had very helpful posts with folks sharing their Shortcuts and tips for folks to accomplish what they're looking for.
Flow Chart
I've adapted the suggested Shortcut from the subreddit post a bit. I've found that wrapping my head around the logic can be a little tricky, so here is a visual explainer before we get into building out the Shortcuts.
-
Feather TFT Clock with Gamepad Input This clock project uses USB gamepad input to control its time setting menu. The display uses TileGrid sprites that I made in Krita. The code demonstrates how to use timers and a state machine to build an event loop with gamepad input, I2C real time clock IO, and display updates.
Overview and Context
This clock is a step along the way on my quest towards learning how to build little games and apps in CircuitPython. The look for the display theme is about digital watches and alarm clocks from the 80's and 90's.
Some of the technical bits and pieces from this project that you might be able to reuse in your own projects include:
Menu system for manually setting time and date
USB gamepad input system with edge-triggered button press events and repeating timer-triggered button hold events
Data-watch style display theme with three display areas: 20 ASCII characters at the top, an eight digit 7-segment clock display in the middle, and another 20 ASCII character display at the bottom
Main event loop with gamepad button polling, real time clock polling, state machine updates and display updates