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.
-
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.
My Solution:
I would like to be able to find the IP address of a headless RPi without having to connect a monitor and keyboard to it. Ideally, I would be able to connect my new RPi to my network, and know the IP address that is it assigned. Then, I could simply connect directly to it using SSH from my PC on the same network.
As is the case for many others, my minor annoyance at "the problem" turned into a full-blown project to solve it. I created a program I called Hello Pi that can be run on a Linux or Windows computer to identify the IP address of a Pi (or other device) connected to the same network segment.
-
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
Description
This project explores the implementation of digital audio output using the MAX98357 I2S Class-D Mono Amplifier in conjunction with the Qualia ESP32-S3 RGB666 board. The goal is to produce a sine wave tone through a speaker connected to the amplifier.
Equipment
- Qualia ESP32-S3 RGB666 board - A versatile microcontroller board based on the ESP32-S3 chip, ideal for projects requiring WiFi and Bluetooth connectivity along with powerful processing capabilities.
- MAX98357 I2S Class-D Mono Amplifier Breakout - An easy-to-use digital amplifier perfect for adding high-quality sound to your projects.
- Speakers compatible with the amplifier.
- Connecting wires. I used 6" female jumper wires.
- Header pins for the Qualia board and the MAX98357 breakout. Go ahead and attach the headers now.
- Personal computer with CircuitPython installed.
::closeup of the Qualia board showing pins::
::closeup of the MAX89357 showing pins:: -
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.
One major difference from the Animated GIF guide: for speed, the code in the guide sends the raw bitmap data directly to an attached display. In theory that is possible to do on the MatrixPortal but it is more complicated and likely would be slower then using
DisplayIO
. This is because the matrices have fewer pixels then most screens and the speed of theprotomatter
library that powers the matrix display. -
Symbols for synthio Objects In the process of learning to use CircuitPython 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.
Attribution: Patch Symbols from PATCH & TWEAK by Kim Bjørn and Chris Meyer, published by Bjooks, are licensed under Creative Commons CC BY-ND 4.0. Some Patch Symbols were modified to create the synthio symbols BlockInput, MixerVoice, Note, Synthesizer, sample, and voice.
-
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.
The REPL
I asked our resident Android expert FoamyGuy for some advice on where to start to access the REPL. He suggested the Serial USB Terminal app (Google Play Store). The key feature for CircuitPython that this app has is the ability to create macros. With macros, you can setup CTRL+C and CTRL+D shortcuts that otherwise are impossible to do with the default Android keyboard.
To create the macros, you'll long press on the macro button. Select HEX as the edit mode and value 03 for CTRL+C. On a second macro, follow the same procedure and value 04 for CTRL+D.
-
Extending the Talking HAL-9000, literally and figuratively 3D files and (lack of) code
You can find the 3D files for the modified HAL parts, as well as the case for the QT Py on Printables. The wiring is pretty basic; in addition to the wiring from the learn guide, I wired one of the RP2040 Feather's UARTs to the headphone (TX, RX, GND) jack, and the other to a 4-pin JST connector (5V, GND, TX, RX) with a few inches of wire. A corresponding JST connector is soldered on to the QT Py, with the 5V and GND wires connected to the battery power pads on the bottom of the board, and the TX/RX wires connected to the corresponding RX/TX pins.
I did not post any code for this as it is highly specific to my situation, however, to be honest, none of the code is particularly special. I used the CircuitPython MQTT learn guide to figure out how to get connected to my local MQTT network, and the CircuitPython essentials guide to work out how to use the UART (for communication) and PWM (for animating the LED).
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.
This is the Feather Weather GUI. It incorporates API data from OpenWeatherMap.org (labels in blue) and real-time sensor data from an Adafruit BME280 module (labels in orange). It then collates the data from the BME280 sensor and whisks it away to my AdafruitIO dashboard using MQTT.
It has some additional features like showing the battery voltage and severe weather warnings. This project was designed as a battery powered weather station during hurricanes and storm related power outages.
Skill Level: Advanced: 600 lines of code
- This is not a beginner friendly project. This one is targeted at advanced Circuit Python users that have experience with JSON parsing, MQTT broker, and GUI design. There are potentially a lot of errors that might crop up during the course of this project that could get you stuck without prior experience. Help is always available in the Adafruit Discord if you want to tackle this project anyway.
- If this project seems too daunting and you'd like to try an easier version aimed more at beginners (because i was a beginner when I wrote it) then check out my Offline Feather Weather. It's only 200 lines of code.
Requirements:
- TFT display of your choosing (I'm using a 3.5" TFT Featherwing)
- OpenWeatherMap.org (free) account & API token
- AdafruitIO (free) account & API token (key)
Optional:
- Temperature/Pressure/Humidity Sensor (BME280)
- Display with built-in SDCard or SDCard module used for screenshots of your GUI.
- Adafruit LiPo battery (I'm using a 10,000 mah)
-
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.
The algorithm for calculating MTC was published by NASA researcher Michael Allison in 1997 and then updated in 2000 by Michael Allison and Megan McEwen. It is nicely summarized on the Timekeeping on Mars Wikipedia page:
The Mars Sol Date (MSD) can be computed from the Julian date referred to Terrestrial Time (TT), as[46]
MSD = (JDTT − 2405522.0028779) / 1.0274912517...This leads to the following formula giving MSD from the UTC-referred Julian date:
MSD = (JDUTC + (TAI−UTC)/86400 − 2405522.0025054) / 1.0274912517where the difference TAI−UTC is in seconds. JDUTC can in turn be computed from any epoch-based time stamp, by adding the Julian date of the epoch to the time stamp in days. For example, if t is a Unix timestamp in seconds, then
JDUTC = t / 86400 + 2440587.5It follows, by a simple substitution:
MSD = (t + (TAI−UTC)) / 88775.244147 + 34127.2954262MTC is the fractional part of MSD, in hours, minutes and seconds:[3]
MTC = (MSD mod 1) × 24 hI wish I could tell you that I can read through that and understand it and as a result write a block of Python code that performs that calculation without a lot of trial and error. Unfortunately, I really struggle with math so I turned to ChatGPT-4. I was incredibly reticent about using ChatGPT or any other LLM but I have to say that I've found ChatGPT-4 to be a very helpful tool when writing code that saves a lot of time for tasks like this. I entered that algorithm into ChatGPT-4 and asked it to convert it to CPython and it popped out a script that worked perfectly when compared to the Mars24 clock. You can see my full chat log here.
-
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.
This version will require 4x 10mm ball bearings. These ball bearings are the same diameter as the balls at the end of the Omnifixo clamps. So I embed the ball bearings into the printed case and the Omnifixo magnet mounts snap to these bearings nicely to hold everything together. No other magnets are required.
The metal tin I used for the brass sponge is a ½ oz round tin I purchased off of Amazon.com here. It is a 4cm round tin, and I cut off a bit of brass sponge to fit inside. Also, this is the solder that fits perfectly in the case, but you could just bundle up any solder and throw it in that slot.
I printed this with a .4mm nozzle at .2 layer height using carbon fiber PLA (though PETG is probably a better choice). You can print the entire thing then using some force push the ball bearings into the print in the corners. They should kind of snap into place.
Note: if you stick the yellow Omnifixo magnets to the embedded ball bearings with the flat side they will stay stuck to the Omnifixo base plate when it is removed.
-
MIDI Samplerbox (RaspberryPi) SamplerBox is an electronic musical instrument. Drop audio samples onto it, hook up a MIDI keyboard, and you'll be able to play with realistic piano, organ, drums, etc. sounds!
The Samplerbox is a small device that plays pre-recorded instrumental sounds when it receives MIDI commands. Vintage products that do this include: ASR-10/EPS/Mirage samplers. Here are other similar products: Sound Modules
It's sample player. It's a MIDI sound module. It is a ROMpler. It stores the sounds of instruments and plays notes from those instruments when it receives MIDI note commands. Those sounds can be any WAV files. You can freely download sound files (samples and sample-sets) over the Internet, or you can record them yourself and copy the sound files into SampleBox. It can then receive MIDI from a MIDI keyboard controller, or any other MIDI device and play the sounds out an ordinary line-out jack.
The original Samplerbox project is described at this website:. https://www.samplerbox.org/ However that's outdated now. We're providing current (May 2023), much easier build instructions at http://chromakinetics.com/samplerbox/.
Extensive, detailed information on the latest Samplerbox development is at: https://homspace.nl/samplerbox/ Note: this website may be offline. Use the Wayback Machine to view the archived version of that website if necessary. There are a whole lot of pro-level features documented there that you can access, depending on how much complexity you want to deal with.
Good article on using a Samplerbox as a Mellotron replacement SamplerboxMellotronArticle.pdf
Full build instructions are at http://chromakinetics.com/samplerbox/
Required Parts
- Raspberry Pi 3B+ $35 or Raspberry Pi 4 (any memory size) (also should work on a Pi Zero 2, but these directions do not cover that model.
- Pimoroni Pirate Audio LineOut $25 Pimoroni website
- Power supply for Raspberry Pi (5V 2.5A with correct connector for the Pi model)
- MicroSD card at least 2GB (I'm using 16GB)
- a microSD card reader or microSD adapter (if your computer has a full-size SDcard slot built-in)
- a MIDI keyboard (either a USB keyboard or a 5-Pin DIN MIDI keyboard connected to a USB MIDI adapter)
-
MIDI Commander (PyGamer) MIDI SysEx Patch Loader / MIDI snippet player
MidiCommander is a CircuitPython app running on a PyGamer with a MIDI Featherwing plugged in and with an SDcard. It enables a user to "play" syx and .mic files containing snippets of MIDI commands, stored in folders of "playlists" on the SDcard, out to connected MIDI devices. It may be used to send MIDI data to several devices to configure a MIDI setup for each song during a gig.
- Files containing MIDI command bytes are to be stored on the SDcard in the /syx folder and its subfolders. The joystick UI enables navigation to subfolders.
- Filenames and folder names that start with a period are ignored.
- Only files with a .syx or .mic extension are seen by this program
- You can put any MIDI command bytes into a .mic or .syx file and this will send whatever is in the file, so you can send Program Change, CC and other - you are not limited to SYSEX commands. You can put all the MIDI commands needed to configure your rig for a song in one file.
- Arrange the files in a folder in the order of your setlist and then during a gig, simply choose the file and press a button to send it -- and all your MIDI instruments are configured for the song.
- Press the B button for Help
Full details on this website: http://chromakinetics.com/midicommander/
Open source CircuitPython & Python on Github at https://github.com/gmeader/pybadge/tree/master/MidiCommander
This is a derivative work of the original SysEx “Librarian” by: kevin@diyelectromusic
https://diyelectromusic.wordpress.com/2022/05/28/raspberry-pi-pico-sysex-librarian/Modified for Adafruit PyGamer with MIDI Featherwing by Glenn Meader
You can get the required hardware: a PyGamer and a MIDI Featherwing for about $50 at adafruit.com The MIDI Featherwing plugs into the back of the PyGamer to provide DIN-5 MIDI jacks.
-
Comparing libgpiod and gpiozero speeds on the Raspberry Pi 5 With the new Raspberry Pi 5 coming out, it is time to add support to Blinka, our CircuitPython library compatibility layer. One of the biggest changes to the Raspberry Pi 5 is the addition of a new southbridge chip, called the RP1, which now handles the GPIOs. Like many other projects, we have been the RPi.GPIO library to handle the General Purpose Input/Outputs. The only issue is that RPi.GPIO does not work on the Raspberry Pi 5 due to a changed memory mapping. Whereas everything was handled by the
/dev/gpiomem
device before, now everything is dynamically split into multiple gpiomem devices. The 40-pin GPIO header happens to fall into/dev/gpiomem4
.So this means it's time to look at a couple of new options that do work on the Raspberry Pi 5. The two biggest contenders are libgpiod and gpiozero, though there does appear to be a pure python version of libgpiod called gpiod. RPi.GPIO was written in c, so it should run faster than a pure python implementation, however as mentioned before, that no longer appears to be an option. So the replacement should be able to run as fast as possible.
On the surface, libgpiod appears to be the better option because of several different factors:
- The python bindings use the libgpiod library underneath, which itself is written in c
- We already have multiple other libraries using libgpiod, so adding it is much simpler
- Looking at the source, gpiozero appears to be a pure python implementation
On the other hand, Raspberry Pi is recommending gpiozero as the replacement to use on the the Raspberry Pi 5. So it's time to compare them head to head on speed alone. In order to test the speed, each library will turn a GPIO on and off as rapidly as possible and the results will be measured with a logic analyzer. The environment will be a fresh install of the 64-bit lite version or Raspberry Pi OS Bookworm since that is the minimum that the Raspberry Pi 5 requires. The scripts will be running inside of a virtual environment as is recommended now.
First up will be libgpiod. The script that will be used is:
Next up is gpiozero. The script that will be used is:
-
HAL9000 Sample Code Tweaks I've been working on building the updated HAL9000 using the Propmaker Feather, and tweaked the code a bit to add a couple of features. Mainly:
- Animate the LED using a slow pulse animation when HAL9000 is "idle" (in other words, not playing a sound)
- Shuffle the list of wave files, and keep track as we play our way through them; then, once we've reached the end, re-shuffle the list and start over. This prevents the same sound repeating over and over, which the current approach is prone to. It also ensures you'll hear every sound if you keep pressing the button (until the list eventually has to repeat).
I ordered a decal to use instead of 3D printing the "HAL9000" label, so I'm waiting on that before I post the photos of my build, but in the meantime, here's my updated code if anyone is interested (you'll need to add the
adafruit_ticks.mpy
library to yourlib
folder in order to use this). -
12-Panel Matrix Portal Display How many matrix panels can you use with the Matrix Portal S3? Theoretically, around 50, however the more panels you add the greater the travel distance and signal degradation. Degraded signals can have effects of pixel artifacts/glitching and visible scan lines that are very hard on the eyes.
The bit depth (amount of possible colors) is also very important. 12 panels cannot stream more than a bit depth of 4 without significant artifacts. Normally with Circuit Python, images are 8-bit indexed BMP's but matrix panels can only display a maximum of 6-bit color. A TFT can support up to 24-bit so do not make the mistake of treating a matrix display like a TFT. It will still process 8-bit indexed BMP's with some image quality loss due to the nature of RGB LED's in a matrix panel.
For this project I'm using 12x 5mm pitch matrix panels. The pitch denotes the physical distance between pixels. A 3mm pitch panel will be much smaller physically than a 6mm pitch for example.
Panel Arrangement
The serpentine arrangement of the panels matters. If you get it wrong you'll end up re-arranging the entire matrix until you get it right. The RGB Matrix library expects the controller (Matrix Portal S3) to be in the top right of any arrangement regardless of post-processing rotation in the code. The library expects each 2nd row to have the panels flipped 180 degrees as shown below. You can have each row or column with as many panels as you want so long as the rules of the serpentine arrangement are adhered to.
-
DIY Bubble Machine Using Raspberry Pi Pico The project aims to create a soap bubble machine using a perforated plastic disc attached to a DC motor and a fan.
🫧 Introduction:
The project aims to create a soap bubble machine using a perforated plastic disc attached to a DC motor and a fan. These components are connected to an L298 driver circuit and controlled by a Raspberry Pi Pico microcontroller. This simple and enjoyable project is designed for children to learn about electronics and programming.
Soap bubbles have always fascinated children and adults alike. They bring joy and excitement, creating beautiful floating spheres that reflect light in mesmerizing colors. With this project, children can explore the science behind soap bubbles while having fun building their own machine.
The heart of the machine is the perforated plastic disc, which acts as a bubble wand. When the disc rotates, it dips into a soap solution, creating a film of soap on its surface. As the disc spins, air from the fan blows through the holes, forming bubbles that detach from the disc and float away.
To control the rotation of the disc and fan speed, we use a DC motor connected to an L298 driver circuit. The L298 driver allows us to control the direction and speed of the motor using signals from the Raspberry Pi Pico microcontroller.
We control the speed of the perforated circular bubbles disc through a potentiometer connected to an ADC pin at the Raspberry Pi Pico.
The Raspberry Pi Pico serves as the brain of our project. It runs a program that controls when to start and stop the motor, as well as adjusting its speed. By programming the Raspberry Pi Pico, children can learn about coding concepts such as loops, conditionals, and functions.
This project not only introduces children to basic electronics but also encourages their creativity by allowing them to customize their bubble machine. They can design and decorate their own plastic discs or experiment with different fan sizes for varying bubble sizes.
In conclusion, this DIY project offers an exciting opportunity for children to learn about electronics, programming, and physics while having fun creating their own soap bubble machine. It combines science with creativity in an engaging way that will captivate young minds. So let's dive into this project together and explore the fascinating world of soap bubbles!
The following picture shows the Raspberry Pi Pico pinout (which functions are supported by each pin).
🫧 How to Initialize PWM in MicroPython for Raspberry Pi Pico?
We are going to follow the steps stated below in order to configure PWM in our Raspberry Pi Pico.
- Firstly, we have to choose the PWM pin.
- Next, we set a particular frequency for our digital signal. 50Hz is a good value to start off with to work with an LED and L298.
- Raspberry Pi Pico has 12 bit resolution but in MicroPython it is scaled to 16 bits. Hence the duty cycle will be set from 0-65535 which corresponds to 0-100%
You can read this article on Raspberry Pi Pico ADC:
Inside the infinite loop we are reading the analog pin through the method read_u16() from the potentiometer variable and storing it in potentiometer_value. This value will vary from 0-65536 because we have 16 bit resolution. You will be able to see the values getting printed on the screen. This value is given as a parameter inside the duty_u16() method which is being accessed through the led and motor speed.
When you run this code on your Raspberry Pi Pico and rotate the potentiometer knob, you will get the value of ADC after every 1 seconds.
Increasing input values from the potentiometer act as increasing duty cycle hence the brightness of the led increases and the speed of motor of bubbles disk..
The blower fan and Raspberry Pi Pico were powered by a power bank. The drive module L298 is powered by an external battery.
Note:
- The smaller the disc area, the greater the possibility of bubbles sticking to each other, so it is preferable to use a larger disc with proper spacing of the holes.
- You should also use a powerful fan to blow bubbles, such as fans that rely on a Brushless motor.
- Using a variable resistor (potentiometer) we calibrate the disk speed to obtain the desired performance.
🫧 Test The Machine 🫧😊🫧
1 - Wokwi Simulation Test:
https://wokwi.com/projects/374559373412279297
2 - Real Test :
https://www.hackster.io/aula-jazmati/diy-bubble-machine-using-raspberry-pi-pico-9f2a54