![](/assets/playground/adafruit_playground_1200x900-699010177a4a3fd6bac6bc31deae0bfa3eb9ea777ba62aaa5cbc1225bb45bfcc.jpg)
Adafruit Playground is a wonderful place to share what you find interesting. 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.
Adafruit Playground is a safe place to share with the wonderful Adafruit community of makers and doers.
Click here to learn more about Adafruit Playground and how to get started.
-
Using multiple WiFi network credentials in Adafruit IO WipperSnapper firmware As of July 23rd 2024, we've added support into WipperSnapper for specifying backup wifi credentials, simply by adding an array of entries under the new key "alternative_networks" in your secrets file.
-
Decison Maker! An invention was patented in 1948 that has assisted millions in making decisions. Long before widespread access to computers, this device - completely mechanical gave instant answers to questions - no AI or LLM required.
I refer to ... the Magic 8 Ball.
It doesn't take much of a web search to find examples of programs to recreate the Magic 8 Ball. It's an easy exercise - for example, here's one at geeksforgeeks.org that made a fun starting point for me to adapt for some Adafruit fun.
It wasn't hard to adapt that code into CircuitPython for the NeoTrinkey. I put together Magic8.py. Load that on a NeoTrinkey - copied to code.py. When run, it will display a blinking idle pattern. Touch either touch pad and it will go to Green (yes), Yellow (maybe) or Red (no). If you are running it in an IDE like Mu or Thonny, the REPL will print an answer appropriate to the verdict. Touch the pad again to return to the idle pattern.
But, why not make a better, smarter tool - something that you can use to calculate the answer? And why not have it SPEAK the answer?
In my DecisionMaker repository you'll find all you need to do that.
Starting with MakeCode I created a two-mode DecisonMaker for Circuit Playground Express. With the switch to the right, press the "A" button and it will give you a Green/Yellow/Red verdict. In addition, IF it is plugged in to a computer with a usb cable, touching A4 will give you a verdict and TYPE the appropriate message text. (note: If the CPX is not connected to a computer, touching A4 will crash the program; also, if you copy DecisionMaker.js into MakeCode, you'll need to add the Keyboard Extension; it's already in the version at this link).
The other mode is what you get when you move the switch to the left. This lets you give more input for the program to evaluate your question. Essentially, break your question into factors (as many as you want) and give each factor a value good or bad, then ask the DecisionMaker to weigh in. With each factor press A from one to five times (for Good) and B from one to five times (for Bad). After scoring the factor, touch A1 to add it in.
For example, lets say your question is "Should I go see the new movie Super Space Blockbuster XIII?" and you break down the factors to:
- I love Super Space Blockbusters - read all the books and comics and have all the action figures
- I didn't like the last three that much
- I hear they added famous actor Kirk Handsome
- I think it will be streaming in a couple of months.
So, here's the steps in the evaluation:
-
AIO+ Weather: A Premium Alternative for Local Observations This is the second chapter in the "Finding an openweathermap Alternative," my latest choose-an-adventure saga exploring the weather API wilderness. The first chapter, weather.gov: A Truly Free Weather API, looked at the completely-free NOAA NWS API Web Service as a replacement for openweathermap.org's API. The next area in our search is the weather power-up module of the premium (not-free but affordable) Adafruit IO Plus (AIO+) service and its CircuitPython interface.
-
Tricorders! In 1968, I participated in my first Science Fair, and I saw a working Tricorder! It was another student's project, an assembly of different instruments for sensing things. I know it included radiation as well as temperature. It had a form of an electrical analog computer as well for calculations. It was all wrapped in a case modeled after the imaginary Tricorders on Star Trek. Pretty impressive for the time (the show was only in it's second season)!
Of course, that was a fun project that many have improved upon - there was an X Prize awarded for creating a mobile device that can "diagnose patients better than or equal to a panel of board certified physicians". And fans have constructed working props - even ones that can provide a variety of sensor readings. It's a great example of how the art of an SF program has inspired real-world engineering and development.
My own efforts are pretty modest, but it's fun to think about ways to craft a sort-of Tricorder device, given platforms like micro:bit or Circuit Playground Express with their multiple built in sensors. Early on I made a micro:bit version that displayed compass reading, light level and temperature, along with a small vocabulary of "alien" words; easy to do with the 5x5 LED matrix on the micro:bit (this was V1 micro:bit, so it didn't use the microphone). There was even an animated picture of the Enterprise.
Now, the Circuit Playground Express has good sensors but there is no graphic display, just the ring of ten neopixels - so how do you display readings? I wrote functions to display numbers by converting them to a string, and then, digit by digit, lighting up enough pixels to indicate the value. In addition, for the Circuit Python version I recorded the digits 0-9, and "point" and "minus" so I could have the device speak the number. I also think it's fun to use Morse code to display info, so for the Makecode version, I added the ability to display a number of sayings (maybe not too practical, but it was fun).
I've saved all this in a repository - here's the README
Tricorders
Code for Circuit Playground "tricorders"
- pycorder.py - "tricorder" program; toggle through idle/temp/light/gees with button A, get reading with B
- bach.py - provides musical notes, random music with touch A7, Star Wars Tune with A1
save .wav files in "digits/" directory 0.wav 1.wav 2.wav 3.wav 4.wav 5.wav 6.wav 7.wav 8.wav 9.wav gees.wav light.wav minus.wav point.wav temp.wav idle.wav
- Tricorder.js - Javascript version of CircuitPlayground Tricorder - toggle through idle/light/temp/gees/text modes with A+B, get reading with button A. when in "text" mode, tilt left/right to choose what phrase to display, press A to get morse code version
Tricorder.js
To use the Javascript code, open up https://makecode.adafruit.com start a new project, switch to Javascript mode and paste in the code. (You can also go directly to this link)
When you run the Makecode version, the program starts by blinking "hello" in Morse, then in "idle" mode, swirling a rainbow. Press A+B to jump to the next mode. Each mode shows a distinctive color:
- Light (yellow)
- Temperature (red) - note, switching the CPX switch left, gives Fahrenheit, right give Celsius
- Sound (green)
- Text (blue)
When in a sensing mode, you'll see a real time graphing of the current value - press "A" to read the current numeric value.
When you are in "text" mode, tilt left and right to choose the phrase:
0: spock = "live long and prosper"
1: yoda = "do or do not"
2: yoda2 = "size matters not"
3: yoda3 = "luminous beings are we"
4: kirk = "to boldly go"
5: picard = "engage"Press A to see the words displayed in Morse code.
CircuitPython version: pycorder.py
This requires you start with a Circuit Playground running Circuit Python (well, of course). Copy all the .wav files to a directory "digits/" and pycorder.py to code.py and bach.py on the CPX.
When it starts, it will flash a few colors, then announce "idle", going into swirling colors.
Advance modes by pressing "A" button. Again, a signal color announces the mode switch, along with a voiced "temp", "light", "gees", "idle". When in a sensing mode, press B to get the current reading.
- Temp (red) - note, switching the CPX switch left, gives Fahrenheit, right give Celsius
- Light (yellow)
- Gees (green) - note, "gees" willl announce THREE different values; the X, Y and the Z axis values
For fun, the A1 touch pad will render a Star Wars tune, and A7 will play a snatch of random tones.
-------------------------------------------------
So there you have it, my version of "Tricorder" - I'd love to see how others take that idea and make the imaginary real!
-
Virtual Display Over Web Serial This demo uses Web Serial to receive video frames from a Pi Pico and show them in a web GUI. It works like a virtual display. The video frames go over the normal CircuitPython USB serial port as base64 encoded text with start and end markers.
I developed this technique so I could have an easy way to monitor video from my PiCowbell Camera Breakout. But, this approach could probably be adapted for use as a virtual displayio display.
-
CamTest: PiCowbell Camera Breakout Demo A frame-capture demo with Pi Pico, OV5640 camera, and CircuitPython.
This is a simple camera demo project to capture a 240x240 px grayscale frame every 2 seconds, convert the 8-bit pixel data to 1-bit, then print pixels to the serial console with Unicode Block Element characters.
-
weather.gov: A Truly Free Weather API The weather API of
openweathermap.org
has been a trusted source of local weather, reliably feeding my projects for quite a few years. Their API design is very complete and easy to understand, not to mention that it interfaces nicely with CircuitPython.They recently changed the API service model for
openweathermap.org
. Although there is a "free" service tier, a credit card is required just in case the usage exceeds the free use threshold. My projects only need a single query response every 20 minutes, clearly falling in to the lower portion of the lowest tier, but I didn't like having to share a credit card number when no money would need to change hands. Call me old-fashioned, I guess. I started looking for better alternatives.The National Weather Service API
After reviewing many of the free-ish weather API offerings, I stumbled on the mythological metrological holy grail, the NOAA National Weather Service (NWS) API Web Service. The NWS API provides free access to alerts, observations, and forecasts without the need for a user account or API key. I was pretty excited to find that NOAA's NWS data was available to the general public since I assumed that other weather APIs use NOAA NWS as an essential data source for their services.
-
Getting Started with the Pocket 386 The Pocket 386 is the latest tiny retro PC to be available from China, joining the Book8086 and the Hand 386. I have read that the Hand 386 was discontinued due to part shortages.
The unit is small, but calling it something that fits in a pocket is stretching it.
-
Archiving Xerox 820 8" Floppies My Xerox 820 CP/M computer has a large external drive enclosure with two 8" SS/DD floppy drives in it. They have a "shugart" interface inside, brought out to a proprietary-but-documented 37-pin D-style connector. Because the data signals used by floppy drives changed very little over the decades (at least in the CP/M and PC worlds; Commodore and Apple users, don't @ me) all the signals mostly map closely enough onto IBM PC 34-pin connector.
I previously made a passive adapter board so that a "Gotek" floppy drive emulator could replace the drive enclosure, and it worked! (and is a LOT less loud than 2 8" floppy drives spinning all the time!!!)
That got me thinking: could I make a 2nd adapter board that would let me archive 8" floppies? Then, inspiration struck: I didn't even need a 2nd board design. Instead of fitting a plug ("male") connector on the board's top side, I could simply fit a socket ("female") connector on the board's bottom side.
Since I'd gotten 5 boards in my PCB order, I just had to wait for delivery of the connector and solder everything up.
Both archiving and writing worked on the first try, with greaseweazle host software and an Adafruit Floppsy prototype board; a genuine GreaseWeazle should work just the same.
-
SevenSeg: Create an Instrumentation Vibe for Displayio SevenSeg is a CircuitPython displayio -compatible collection of four ultra-compact monospaced
.bdf
fonts that mimic the look of a seven segment LED display. To keep the font file size small, only the numeric characters that a seven-segment display can represent are included in the font, including uppercase and lowercase hexadecimal. Okay -- there are a couple of other useful things in there, too.Supported characters:
+ - . 0 1 2 3 4 5 6 7 8 9 : A B C D E F _ a b c d e f °
SevenSeg Font GitHub repository
-
Raspberry Pi Pico Dice Programmed with CircuitPython Add more fun to your board games by creating an electronic die!
-
SocketPoolLogger Have you ever needed to troubleshoot why you are having issues with your MCU and the internet? Ever been curious how internet requests work? Well this might get you a little closer.
Introducing: SocketPoolLogger
What is
SocketPoolLogger
? it's a little class, that allows you to log everything that happens with a socket. -
Tiny Plaintext MIDI Sequencer for SAMD21 When playing with synthesizer patches, it helps to have a MIDI sequencer to generate note triggers for you. One option is to use a DAW on a laptop, like Ableton or whatever. But, it can also be nice to go DAWless with a hardware sequencer, because buttons and knobs and blinking lights are fun. With DIY sequencer projects in mind, I wrote a plaintext music notation sequencer module for CircuitPython, called txtseq.
The sequencer can read a song from a text file on your CIRCUITPY drive, parse the music notation into an array of MIDI note on and off events, then play the MIDI events in an event loop (allowing time to run other code). The music notation is loosely based on a subset of the abc standard. Notation for note pitch, accidentals, octave, and duration is very similar to abc. For everything else, the sequencer uses a simpler grammar and syntax that is easy to parse on a microcontroller.
-
Web API's & You - An uncomprehensive & comprehensible guide to using Adafruit Requests with web API's.
The amount of online API examples for the Adafruit_Requests library is growing. If you're interested in using an API but an example does not exist and you're unsure how to start I will help walk you through the process.
I wrote the majority of the web API examples currently in the examples directory. I'm a pretty good source on how to approach a new unknown web API and wrangle out some basic data.
JSON
Data is malleable, it can be shaped and formed in a variety of ways. The most common format currently used with REST API's is JSON. The Adafruit_Requests library is particularly good with JSON data. If you don't know how to read or write in JSON don't worry, you won't need to. The library handles all the format conversions for you. All you need to know is how to get at the data you want and I will walk you through how to do that.
Before we begin there are some glossary terms that you'll need to know in order to make sense of JSON for the web.
REST
Representational State Transfer (REST) is a software architecture that imposes conditions on how an API should work. Most web API's use the REST architecture. All a beginner needs to know about REST is it's the way a website allows you to retrieve data from an API.
Endpoint
An endpoint refers to the data to retrieve from an API. This can be part of the JSON heirarchy path or a key:value pair. For web API's typically this refers to the JSON Key:Value pair.
Key:Value
- Key:Value (always a pair separated by a colon)
A key is a unique identifier associated with data and the value is the actual data. An example would be if you're working with a weather API and might want to return current:temperature for a geographic area to display freedom units on a TFT. It would return as `current:70.0` (in Fahrenheit) or if you're living in a sensible country using the metric system it would return `current:21.1` (in Celsius).
Key Error
It's useful to know the above terms because an error that a website or Circuit Python might return is `invalid key:value pair` or simply `key error`. That error means you requested a key:value that does not exist, you spelled it incorrectly, or the request was otherwise incorrectly formatted.
-
Stuff My Dog Said (via AdafruitIO) Inspiration
This project is an extension of the original doggy buttons project where I'll be showing how to make a public dashboard that publishes everything my dog says. This project is just one example of how to extend the features of my doggy buttons and perhaps one of the silliest IOT devices ever made. If you want to know about the buttons themselves, see the original project writeup.
With a project like this, it's also important to think about privacy. I don't want my dog making it possible to tell when we're away from home, so I'll also show how to add a delay so that activity is only published once it's sufficiently stale.