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.
-
Failing with CircuitPython
How to fail with CircuitPython
All code will have errors. You might find it sooner or later, or the error might be in your code, in a library that you are using or even in CircuitPython itself!
It is also very common to write some code on your lab environment, test it a bunch of times, then take it out into the field and watch it fail in lots of ways you would never though of. Exactly the same happens when you give your device to a user or a kid who will test it in ways that will make your coding skills feel silly.
In my case this is happening for a weather station. This should be a simple project, right? Grab some data from a sensor like a Stemma QT thermometer, then send that data to Adafruit.IO and watch it get graphed in a lovely dashboard. Or at least that was my expectation for this project.
As you can see, I started getting missing data for days, and only when I went to the semi-remote location where I am testing my weather station, and manually rebooted the devices, I would get start getting data again. But now the graph is ruined, it has a large gap in the data and to all whom I showed the graphs, the first thing they mentioned is 'what happened to the missing data?'. Now what do I do?
-
Doggy Buttons!
Inspiration
This project was born from two desires. One, see if our dog could be taught to use buttons without spending piles of money. Two, to make use of an ancient Raspberry Pi.
Lots of people have done a project like this, and it isn’t necessary to use a Raspberry Pi. That just happened to be the only unused piece of electronics I had on hand with audio output. But, I will say that I definitely recommend this approach for a couple reasons. Firstly, it’s very easy to get running in Python with Adafruit’s Blinka library. Second, it leaves lots of room for growth (both in number of buttons and features like button presses sending digital messages).
Be sure to read all the way to the bottom for a cute puppy photo! -
Teach your NeoTrinkey Morse code!
C3P0 can talk. R2D2 expresses what he's thinking with beeps and boops. What can you do with a Neo Trinkey?
How about.....Morse code? It's simple, and four neopixels is more than enough to say anything! Here's how I set about doing it.
-
Spock on a Chip!
I love using the random library - it's a simple way to introduce variety into simple programs and here's one example, what I call "Spock on a Chip." Here's a link to the repository.
Copy the files to a NeoTrinkey, changing "spock.py" to "code.py" - when it runs, it occasionally blinks lights, but when you touch one of the pads, it will blink and then pick a random quote out of the "spock" file and print it. If REPL=True, you'll need to be in an editor like mu to see the text. IF you change REPL to be False, then it will use HID support to send the text as if typed on a keyboard! Just the way to jazz up your email! Edit the "spock" file to add your own favorite quotes from everyone's favorite Vulcan.
What's going on?
There are two functions that are used to deliver the quotes. len_file(filename),
def file_len(filename):
with open(filename) as f:
for i, _ in enumerate(f):
pass
return i + 1
and wisdom(file_name).
def wisdom(filename):
qs = open(filename)
for i in range(random.randrange(file_len(filename))+1):
quote = qs.readline()
quote = quote.rstrip()
cmpthink()
qs.close()
return (quote.rstrip())
Give a file name, wisdom() calls len_file() to determine how big the file is, then uses random.randrange() to select the text - that means you can add or subtract from the "spock" file without needing to update the program.
The fun thing with this code is, it can be reused for other purposes. I've already used it to put together a "story" program that uses multiple source files (aliens, suns, planets, etc.) that can be drawn from to generate story lines. It could be used for a diceware style passphrase generator. And, of course, it doesn't have to be Spock on a chip - you can fill the "spock" file with any quotes you choose.
-
Faster SD writes with ESP32 and SDIO
Better SD write performance is probably a common goal. My project uses the Adafruit SD Micro SDIO breakout, the Adafruit OV5640 Camera breakout and the Unexpected Maker ESP32S3 feather in a compact stack (with a custom PCB to connect them) that fits in a GoPro waterproof case. I want GoPro-like video recording but with BLE time synchronization and start/stop functions with multiple cameras. It's like a GoPro but it's not, it's a NoPro!
I'm programming with the Arduino IDE and using the SD_MMC library. The ESP32S3 has an SDIO interface with programmable pins, which the library supports. But for the longest time, I could only get sustainable write speeds of 150-200 kilobytes per second. I'm using a Sandisk Extreme V30 32GB which should get 30MB/s. For the frame rates and resolution I want, I need about 3MB/s.
I initially played with the file system buffer size but never got consistent results. I might occasionally get a few frames written at target speeds but never a whole video. So I set my code aside and started from scratch to explore how to get better speed.
There definitely seemed to be a dependence on file buffer size as well as on the size of data being written. So I tried lots of combinations and got the same results - usually about 150-200 kB/s but occasionally over 3MB/s.
-
RGB Matrix Word Clocks
I was looking for a clock that would tell the time in words rather than just hands (analog) or numbers (digital). I found a few for sale on places like Amazon and eBay, but none of those particularly stood out, so I decided to create a customizable one myself.
I designed and built two variants. Both use the same RGB matrix panel. Both use CircuitPython on the ESP32-S3, but one uses the Matrix Portal S3, and the other uses a standalone Feather ESP32-S3 with an Adafruit RGB Matrix Featherwing Kit. The Matrix Portal version requires no soldering; the Feather version requires some simple soldering. I will show both here.
The text is left justified, vertically centered on the display and each line is in a random color which changes every time the minute changes. Since you control the CircuitPython code, you can change this formatting any way you choose, e.g. same color lines, individually horizontally centered lines, etc.
-
No-Code "EnSmartening" an IKEA FÖRNUFTIG Air Purifier - V1 Reuse existing PCB+Dial
Is this another silly idea / tribute to insanity, by needlessly bolting the internet and a subscription service to a device, which usually degrades performance and adds built-in obsolescence (not to mention a 22second boot-time)?
Well maybe, or maybe it's just a way of providing people with alternatives, but either way it involves Adafruit IO as an alternative to Home-Assistant / Node-RED or the official IKEA smart-hub + smart devices, and Adafruit's open-source IOT firmware called WipperSnapper as an alternative to ESPHome.
It's possible to use on the free-plan on Adafruit IO (you do NOT need IO+), or offline with a little coding, so I don't feel bad about suggesting it...
Here's a demo video of it in action: (Adafruit IO Dashboard on left, WipperSnapper device page on right, Speed dial of Air Purifier + Wind Sock on Picture-in-Picture video)
-
Sound Reactive Neopixel Brass Bell Cover
I'm in a radical marching band called Brass Your Heart, and I wanted to make our instruments light up when we play them. I started this project by making one for my friend who plays a marching baritone. Below is a mostly step by step process for how I made them using: sewable neopixels, conductive thread, snaps, a Gemma M0, and an electret microphone.
-
WaveViz: Plot a synthio Wave Table or Envelope
WaveViz is a CircuitPython class to create a positionable
displayio.TileGrid
graphics widget from asynthio.waveform
wave table orsynthio.Envelope
object (or any one-dimensional list for that matter). The class also makes the underlying bitmap and palette objects available for other uses such as saving the widget to an image file. -
Building a LEGO Case for Your Projects
John Park wrote an excellent guide Lego Set Lighting. I used this guide to light up the LEGO Christmas Tree (set #40573) making the candles flicker away. My problem was how do I hide the electronics running everything.
I had the idea to design and build a LEGO model in the shape of a present, but the question was how.
It turns out there is an easily accessible CAD program and method of ordering parts (maybe too easy!).
-
IoT Wind Chimes using synthio
A CircuitPython project for indoor "windless" garden chimes that play along with the outdoor wind speed.
-
macOS: Built-In Support for USB-Serial Chips
macOS provides built-in support for some USB-to-serial converter IC's. Built-in support was added at various times for different chips. In the versions of macOS before support for a particular chip appeared, a manufacturer-supplied driver needs to be installed.
I rolled some old Macs back to their original versions, and then rolled them forward, one version at a time, to test support support for three different families of USB-to-serial chips. I tested by attempting to upload firmware to ESP32 chips using esptool.py.
Summary
FTDI FT232x chips have working built-in support starting in Mojave, macOS 10.14. Specifically, a cable using a FT232RL was tested.
Silicon Labs (Silabs) CP210x chips have working built-in support starting in Catalina, macOS 10.15. Specifically, support for CP2104 was tested on an Adafruit Feather HUZZAH32.
WCH CH9102F chips have working built-in support starting in Ventura, macOS 13. Specifically, an Adafruit Feather ESP32 V2 with the CH9102F was tested.
Tested macOS Versions
Not every combination was tested, since I knew which versions did not have support and did not re-test old versions.
High Sierra - macOS 10.13
Only Python 2 is available in the original installation, so Python 3.11 was manually installed from python.org.
NO - FTDI did not work properly, though it appeared as
/dev/cu.usbserial-AL0157X9
.NO - CP2104 does not appear at all.
NO - CH9102F appears as
/dev/cu.usbmodemNNN
, but does not work properly with esptool.py.Mojave - macOS 10.14
Only Python 2 is available in the original installation, so Python 3.11 was manually installed from python.org.
YES - FTDI with esptool.py works. It appeared as
/dev/cu.usbserial-AL0157X9
.NO - CP2104 did not work, I believe (my notes are incomplete).
NO - CH9102F
Catalina - macOS 10.15
Has Python 3.8.
YES - FTDI works.
YES - CP2104 starts working in this version, appearing as
/devcu.usbserial-NNNNNNNN
.NO - CH9102F does not work properly. Only
esptool.py chip_id
works.Big Sur - macOS 11
Same as Catalina.
Monterey - macOS 12
Python 3.9.6
Same as Catalina.
Ventura - macOS 13
YES - FTDI works.
YES- CP2104 works.
YES - CH9102F starts working in this version. It appears as
/dev/cu.usbserial-NNNNNNNN
. Note the change fromusbmodem
tousbserial
from Montery to Ventura.Sonoma - macOS 14
Same as Ventura. All work.
References
-
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?"
-
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:
-
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!