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.
-
Creating a CircuitPython library Bundle for Circup
Mad With Power, or just keeping it on the down-low... There's a few good reasons to want to create or use a custom bundle of libraries for circuitpython!
Perhaps you write educational guides and lesson plans and want to have all your custom requirements in once easy to use place. Maybe you've got enough private, rudely-named, or trademark-infringing libraries / drivers / helpers for CircuitPython that you won't add to the community bundle, but still want the convenience of
circup
(the package manager for CircuitPython).I love having a package manager for circuitpython (currently supports USB mass storage based devices, but theres a pull-request for web-workflow suppport).
circup install --auto --py
and I get all my dependencies in readable form, modifiable even if I so wish!So a recent pull request caught my attention, for circup-depenencies that weren't in the pypi repository (python package hosting used by `pip`) yet or at all. That's the exact state of my libraries!
I also was aware of seeing a bundle-add option for circup, used to add custom library bundles, so this weekend was time to bring it all together.
Minor Yak Shaving - Get Library Ready
I've cleaned up the library enough to have a releasable thing, but never sorted the docs. The project is a fork of a Sensirion python library, for which I actually have permission to use their name, but to avoid any issues I wanted to have a way without friction, like a custom library bundle. Anyway the docs use Sphinx, and the read-the-docs theme, but are an old form of config etc, so I cleaned up that to the point of publishing to github pages.
Then I could setup a pyproject.toml file with a
[circup]
section, and inside a field calledcircup_dependencies
with an array of strings. Similar to this: -
Guide: Build a WiFi Matrix Keypad Remote
Overview
Modern electronics are capable of incredible things. Even the simplest gadgets now have clocks, gyroscopes, radios, GPS, touch screens, literally anything you can imagine, built right in. Sometimes though, the devices that are capable of doing several things don't do all of them particularly well. Touch screens are often bolted onto things that really don't benefit from them, or even worse, detract from the experience. Anyone who has accidentally grazed the touch panel on an Apple TV remote while grasping for it in the dark knows exactly what I'm talking about. Sometimes I just want to have a remote with a few simple buttons I can press to make things happen, and that's it!
Most of the lights in my apartment are WiFi-connected, and offer MQTT capability. I took advantage of this and set up a local MQTT broker (https://mosquitto.org/) on a Raspberry Pi 4 wired to an old Apple Airport router/hub I had lying around (my internet provider makes me use their router for my internet). Now, it's easier than ever to control my lights...from a browser. Or some phone interface. Or an app. Wait a second...each of those still requires multiple steps just to get me to the point where I can actually control anything. And I probably still have to use a touch screen. Leading me back to my original point, and thus the motivation for the imaginatively named:
WiFi Matrix Keypad Remote
I've been a DIY remote control enthusiast for almost as long as I've been hacking around with microcontrollers (at least a few years now). One thing that I've found really hard to source as a hobbyist is good, pre-made button panels intended to be mounted into a small space, such as a remote control. So far, one of my favorite sources for a dense panel of decent quality, inexpensive buttons are these old-school 3x4 matrix keypads:
-
CircuitPython and ChatGPT Code Interpreter
Overview
GPT Code Interpreter allows you to run your own code on a GPT server. It's great for trying out simple functions. Did you know that you can upload your own interpreter and have GPT run it? It takes some work, but you can have GPT write code and tests, then run them on an actual CircuitPython interpreter. Not all the features are there, and you don't have access to any real hardware. This is highly experimental at this point. Difficulty level: Advanced.
Equipment
- CircuitPython interpreter binary
ports/unix
x86-64. Follow the instructions for Building CircuitPython. You need to build with the same GLIBC as Code Interpreter which is currently 2.31. I was able to build it using Debian 11 (bullseye). - The interpreter is named 'micropython' but it is CircuitPython.
- ChatGPT+ account: Code Interpreter is a plus feature.
Instructions
Follow these instructions to start a chat with access to your CircuitPython interpreter.
commands
should be entered directly into the chat.- Start a new ChatGPT 4 session.
- Attach your CircuitPython interpreter 'micropython'. Click the 'paperclip' to upload it.
- Use this command:
Please make /mnt/data/micropython executable.
- Use this code to check that the interpreter is working:
import sys print("Version:", sys.version) print("Platform:", sys.platform)
- Flex some Python skills:
Use introspection to list the features in the <os> module
How it Works
The code interpreter is like a Jupyter Notebook that GPT controls. When you ask it to run some code it writes the script and executes it as a notebook 'cell'. It adds an icon that allows you to view the script and the output.
For the CircuitPython interpreter it will embed the CircuitPython code in the cell as a string, then use the shell to execute the CircuitPython interpreter with the embedded script and capture the output. It can then interpret the output or return it to you directly.
It's pretty code-inceptiony and may take a while to figure out. Be sure to click on the icons to view the code and output for each 'cell'.
Observations
I'm still in awe that it even works. You will have to use some prompting to make sure it is running the interpreter and not just calculating the responses in some other way. It can use introspection to figure out which features are available and which are not present.
This is still very experimental at this point!
Conclusions
Building a CircuitPython interpreter that can run within GPT is an interesting and at times mind-bending exercise.
Code Interpreter could be a useful tool for testing different builds or even different versions of the CircuitPython core.
Future Work
- Figure out how to add library packages to Code Interpreter.
- Implement some hardware-in-software modules (fake temperature and humidity sensor, fake I2C and SPI peripherals, fake
board
with a few pins etc.) - Make the interaction traceable so we know if the interpreter is used or not.
- Wrap it in a GPT application.
- Figure out how to call it via the GPT API.
- CircuitPython interpreter binary
-
CB Microphone for your PC - Breaker Breaker any takers?
Part one : Where's the mic?
"Breaker breaker , any takers? This is the the one and only Delchi hunting for bear on I-95 South , keeping that double nickel and keeping the sunny side up & the greasy side down! We gone!" 1
I was looking for some new gaming frontiers when I came across truck simulators! All the skill & thrill of a big rig from your PC. As with all simulators there are button boxes and realistic cockpits to buy, but one thing I didn't see was a CB radio mic! They expect us to use desktop mics, headsets or some other hoo-haw instead of the ol jabberjaw microphone! A little deeper digging showed that you can buy adapters, but they ranged from $180 to $300! ( Granted the $300 one is an awesome button box and has a lot of realistic controls along with the mCB mic.)
Well the first thing I did was say "Belgium" to that, and pulled Rolling Thunder across the room to my workbench and got to work. This was going to be a project that would work with Truck simulators, sub simulators and more! Grab that soldering iron, the wire clippers and that drill over there! It's time to start making!
Notes :
1. CB radio jargon was around long before IRC , and was its own language designed to obfuscate communication and have a grand ol time. "Handles" were common, and yes CB radio handles are where the hacking community got the term handles for hacker aliases!
Translation? Why not ?
- "Breaker breaker , any takers?"
- In cb radio ( less formal than ham radio ) it was common to ask permission before talking on an open channel. Calling for a "break" was like requesting permission to chime in , and was normally answered with "Go ahead breaker"
- "This is the the one and only Delchi"
- Handles were a point of pride and very often unique, but when they did collide they politely adjusted to be like "The New Orleans Joker " vs "The Chicago Joker" and so on.
- "hunting for bear on I-95 South"
- Truckers took great lengths to avoid being caught by the police in speed traps. "Smokey Bear" referred to the Smokey The Bear hat most often worn by police patrolling the interstates. If you were hunting for bear that meant you were on the lookout for police, and sometimes were asking for a "Smokey report" if anyone had seen any police. You usually followed this with the interstate you were on and the direction you were traveling and sometimes the mile marker you had passed most recently.
- "keeping that double nickel"
- This referred to the speed limit of 55 miles per hour that was enforced back then. Sadly there is no clever phrase for the 65 mph speed limit.
- "keeping the sunny side up & the greasy side down!"
- Multiple meanings here, but for the most part this meant keeping your truck upright ( sunny side was the cabin, greasy side was the road ). It was like wishing someone safe travels and no accidents.
- "We gone!"
- When a conversation ended people would signal this with a number of phrases like "we gone" , or "On the side". Sometimes it also included the "10-code" messages such as "10-10 Till I see you again"
Related Links :
- Truck Simulator
- Button Box
- 10- Code & other jargon
- "Breaker breaker , any takers?"
-
Retro blinkenlights: driving 4 charlieplex LED matrices
I recently released another retrocomputer miniature that incorporates a handful of Adafruit boards so I thought that I'd share the details here.
The original Connection Machines were built in the late 80s and early 90s to provide a few thousand hyper-connected processors which at the time was rather unique. If you're interested, here's a wikipedia page about them.
My Patreon supporters vote for which miniatures I make and I was pretty happy when the Connection Machine was chosen. I was also happy to find that Adafruit sells pretty much exactly what I needed to make the blinking light panels:
Assembly requires me to solder the four matrix driver boards to the four LED matrix boards and then plugging in the Stemma QT cables between the QT Py and a chain of the driver boards.
Then I assemble these printed parts. The little C shaped parts on the lower left of this photo are what hold the two-board sandwich of the LED maxtrix board and the driver board.
Then I install CircuitPython on the QT Py and then load it with my code from Codeberg. There you'll find the default blinkenlights script but also a script that uses the network to fetch the time and then turn the Connection Machine into a clock. It took a bit of work to figure it all out so hopefully the code will be a handy starting point for similar projects.
Once everything is assembled I box it up and put it on my gumroad store.
I post pretty much every day about what I'm working on over on Mastodon at @[email protected] and for maker-y types of conversations I like that place much more than the other social media sites. Maybe I'll see you there!
-
When Black and White QRCodes don't work: Qualia Touch Example Dual QRCodes for Wifi + WebWorkflow
A quick and dirty example of something I wanted for my devices, allowing inexperienced users to setup the device themselves, and once setup they can also remotely modify the code / download data.
Also always be sure which network it's on, the IP address, and have a handy way to jump on the same network.I plan to have this run on bootup for 10seconds before the main program runs (depending on network need etc). I may also alternate between this and the sensor data screens. Long term they'd all be pages/tiles in lvgl.
The main reason for this note, was the observation that Black and White QRcodes are too bright for my phone to read, and I had to change both colours to reduce the contrast as theoretically the brightness is already at 25mA minimum.
I pondered on less blue being the most effective, as it's almost treated like white by the phone. I settled on these colours that look incredibly dark rendered as HTML, while on screen look like mid-toned blue with strong backlight and black dotted coding QRcodes, but on camera look almost white and black and work much more reliably.
qr_color=
0x121212
(HTML #121212)qr_bg_color==
0x0000aa
(html#0000AA
) -
Hello Pi: Finding the IP Address of Headless Raspberry Pis (and Other Devices)
The Problem:
A frequent problem I have when creating a new Raspberry Pi-based project is determining the IP address of the device. I am often working with Pi projects in a "headless" (no monitor) configuration using SSH to log in from a PC on the same LAN network. But to log in this way, I need the Pi's IP address, which sets up a chicken-and-egg problem that goes like this:
I want to connect (SSH) to a headless Raspberry Pi, but before I can do so, I first need to attach a monitor and keyboard to it to login locally and get its IP address (with 'ifconfig').
This is the very thing I would like to avoid since the system will ultimately be "headless". In truth, while it is only a minor inconvenience, it is one I'd like to do without. The more new RPi systems that you set up, the more tedious it is to pull out a monitor and keyboard to find the IP address of each one before you can begin remotely connecting to it over the LAN using SSH.
-
Sound for Qualia RGB666
I heard that you can do I2S audio with the Qualia RGB666 board, but I didn't find any instructions. Well, now you won't have the same problem. Let's get this thing beeping! This is a Dexter Starboard project, with assistance from ProtoEngineer
-
CircuitPython Animated GIFs on a Matrix Portal
Playing animated GIFs was added to CircuitPython in early 2023 and I had successfully had them running on TFT displays and even to a monitor via HDMI. I recently setup my MatrixPortal and two 64x32 matrices that I had been using to show animated GIFs. But the MatrixPortal was running Arduino code.
Time for an update and to take the code from Using Animated GIF Files in CircuitPython and Creating Projects with-the CircuitPython MatrixPortal Library and smush them together to play animated GIFs on a MatrixPortal with CircuitPython. Both guides do a great job of explaining the details of their own area and the code here combines them both.
The first half of the code sets up the matrix on
DisplayIO
and the second half usesOnDiskGif
from thegifio
module to display the animated GIF.The code displays all GIFs found in the /gifs/ directory on the MatrixPortal. Each animated GIF will display for 30 seconds before moving to the next animation.
-
Symbols for synthio Objects
In the process of learning to use synthio, it was a challenge to understand the myriad of possible connections between modules. As a result, project design notes and sketches became a rat's nest of entangled symbols and wiring. Although simple single-voice designs without filters or LFOs were easy to deploy and document, it became clear that there was more to discover inside the extensive versatility of synthio.
Perhaps a set of symbols with consistent notation (and color-coded arrows, of course) would be useful to further learn about synthio and to develop project conceptual diagrams.
Here's the beginning of some symbols for synthio objects with class properties and methods together with data types. Essential tools such as audiomixer and audiobusio are also included.
-
Using Android with CircuitPython
Recently there was a PR merged into CircuitPython that allows for the mounting of a CIRCUITPY drive on an Android device. Previously this was not possible, so I wanted to try it out. For my testing, I used a Samsung Galaxy A13 phone running Android version 13. The board I used was a Circuit Playground Express running CircuitPython 9.0.0-alpha.4.
-
Extending the Talking HAL-9000, literally and figuratively
Overview
I love this make of HAL-9000 from the Ruiz Bros:
-
ESP32-S3 MQTT Feather Weather
This has been my main project since 2019 which started on the Adafruit Bluefruit Sense microcontroller with Arduino. I eventually ported it to Circuit Python... and I've never used Arduino since. There are many different versions of this project on my github that are either offline only, offline with GPS, offline & online, offline & online with MQTT.
The project I'm detailing today is offline & online with MQTT to AdafruitIO. This means if for whatever reason your WiFi goes down, OpenWeatherMap.org servers go down, or AdafruitIO goes down it will still display local sensor data and function in an offline capacity waiting patiently until communication is restored.
The display sits in front of my PC monitor and has been running 24/7 for about 3 years now. I've had a lot of time to debug all of the things that might cause it to crash, error, and gracefully fail in a never ending loop. It's not perfect but it's solidly coded.
-
Accurately Calculating Coordinated Mars Time with CircuitPython
I'm currently working on a clock using a Qualia S3 board with a 4" 720x720 round display. The idea is to display an "analog" clock face on it. The clock will show your timezone on Earth and coordinated Mars time (MTC). In looking into MTC, I found the Mars24 Sunclock, which is a piece of desktop software from NASA that shows your local time, UTC time and then MTC.
-
Ultimate Omnifixo Pinecil Travel Case
After watching this Tested video on YouTube showing of the Omnifixo helping hands, I decided to pick one up. I have found it incredibly useful when soldering small electronics. After a bit of use I decided to 3d print the case recommended in the video, but wasn't happy with it. I looked around for other designs, and found some better options, but still not exactly what I was looking for. So, decided to design my own.
With the included Pinecil soldering iron, solder, and brass sponge, this design carries everything I need to solder on-the-go.