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.
-
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
DisplayIOand the second half usesOnDiskGiffrom thegifiomodule 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 theprotomatterlibrary that powers the matrix display. -
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:
-
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.
-
Recreating Disabled Adafruit IO Feeds - after resubscribing/mistakes This will delete and recreate all feeds that are disabled, except those that are part of WipperSnapper devices (you can now export those and then delete the device and re-import the exported JSON file).
You'll need the adafruit-io python library, which is normally installed with this command:
pip install adafruit-ioHowever I've modified the adafruit-io library to add the enabled flag, and it's not released yet so for now you'll want the following command instead:
pip install git+https://github.com/adafruit/Adafruit_IO_Python.git#add-enabled-attributeHere's the script:
-
Generate rainbow colour/color sequence using ChatGPT Just stumbled upon this again over the weekend (I'd seen it before once, but never used it). It's the Randomizer service in Adafruit IO, which offers random words, colours, numbers, or entries from a list. See more here (if you're signed in), and you access the values via MQTT or the HTTP API (instructions on the page).
Anyway, while fantasising about data (specifically how long could my list of values be in randomizer), my mind got caught in rainbow colour sequences, and here we are...
I wanted to insert a long list of items, and thought that's the perfect use for ChatGPT, monotonous lists. It's especially good at understanding simple instructions, although I usually find I need to refine my initial request/prompt.
" generate me a rainbow sequence of colours, hash prefixed and comma separated. the sequence should effectively loop if repeated."
It failed to intuit (I never said), that I wanted a long sequence, and instead offered me the 7 colours of the rainbow in a list.
Realising my error, of implicit assumed knowledge, I added an extra phrase to clarify my desire:
"generate me a rainbow sequence of colours, hash prefixed and comma separated. the sequence should effectively loop if repeated. Give me a 100 value transition through the colour spectrum
And there we have it, a nice colour sequence, which I then increased to 256 items. Communication is key, and not easy, or at least it is easy to make grave assumptions and inadvertently mess-up.
100 Items:
Extension Project - Questionably useful things
The last thing to add is that ChatGPT fails in many places/ways, but it's always interesting to test, so I went further and tried to get it to colour-correct the values in the list, based on the human perception of some colours being better than others, along with the issue of RGB lights having different strengths in each colour, then while writing this I also remembered I'd not clarified the rgb issue enough as the individual coloured LEDs are fine at higher brightness's.
What I found most interesting was after the last clarification (but the second query mentioning RGBW LEDs) it offered me colour hex values including a fourth white component, which is actually what I'd originally questioned if I'd wanted all along...
For posterity I've included it all in collapsible sections, so I suggest you collapse them all and use the last one, but read them by all means! My questions/prompts are in bold (title of collapsible), and ChatGPT is the collapsible content:
-
The Feather Isolator: A Hardware Troubleshooting Device When troubleshooting serial bus communications like I2C, UART, or SPI, it can be handy to disconnect a chip select or data line to isolate external devices. Once isolated, the data can be viewed on a logic analyzer or oscilloscope to determine if the SPI or UART signal outputs are really connected to inputs or when examining the effects of multiple pull-up resistors on I2C. The Feather Isolator was designed to individually disconnect a Feather's pin with a switch to help with the troubleshooting effort.
-
Digital / RGB-666 Moon Clock I wanted a clock that would display the time in large yellow characters and display the week and day. For fun added a 60 RGB neo-pixel ring to tick off the seconds.
The last part was to display the phase of the moon in a fun way and found these to be entertaining.
I cut a sheet of plex-glass to 8x11 sheet. I used miniature self-tapping screws to mount the RGB neo-pixel ring. I used this same kind of screws to mount the 4-digit display and two of the Quad Alphanumerica Displays.
I drill large enough holes to plug the displays up to the Adafruit Qualia ESP32-S3 and daisy chained the rest.
I did solder 3 wires to the RGB neo-pixel ring a crimped a 3-pin connector on the other and plugged it in socket A0.
I used Photopea to create a 3x3 of the moon phases I found on the internet. For the new moon phase I copied the full moon phase and changed its color from yellow to blue. and its a seperate .bmp file.
I am not a very good coder anymore and new to python. I am sure there are better coders out there than me for sure. I hacked most of the code from other projects.
Parts Required for this project:
- Adafruit Qualia ESP32-S3 for TTL RGB-666 Displays (PI - 5800
- Round RGB TTL TFT Display -2.1" (PI - 5806)
- NeoPixel 1/4 60 Ring 5050 RGB LED w/Integrated Drivers (PI -1768)
- Quad Alphanumerica Display - Blue 0.54" Digits w/ I2C Backpack - Stemma QT / Qwiic (PI 1912)
- Assembled Adafruit 0.56: 4-Digit 7 Segment Display -w/ I2c Backpack QT - Yellow (PI 5602)
- Stemma QT JST SH 4-Pin Cable (50mm & 100mm)
-
Storing & Graphing IoT Data With PostgREST Overview
This page aims to illustrate and document how you can use PostgreSQL and PostgREST to store and access data generated by sensors connected to micro-controllers or other IoT devices. Before we dive in, I'll introduce the projects and utilities that we'll be using:
- PostgreSQL - A widely used, open source database system. It's very extensible and has many plugs and other utilities built "on top" of it. Client applications connect to it via a network port and send SQL commands to create, read, update, and delete data.
- PostgREST - A standalone web server that turns your PostgreSQL database directly into a RESTful API. The structural constraints and permissions in the database determine the API endpoints and operations. This web server allows us to create, update and access our data with HTTP requests from micro-controllers and other endpoints.
- NGINX - A widely used web server with reverse proxy, load balancing, and many other capabilities. This project will use it to host static HTML and JS files that can be viewed in a browser. It is good practice to use Apache or NGINX as a reverse proxy "in front" of other web server utilities like PostgREST.
- ApexCharts - A Javascript library for making charts and graphs. We'll use this to graph data that we read out of our database.
Setup PostgreSQL
Method 1: Docker
The official PostgREST tutorial skips the full PostgreSQL setup opting instead for a quick / easy setup running inside of a Docker container. If you already have or are familiar with Docker then this route is quite straight forward. The following command will create and launch a PSQL container:
-
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.And instead of the normal message we get from the
response.text, we get all of this: -
I turned the Raspberry Pi 400 into a Fallout-style terminal! I'm almost ashamed to admit I had a Raspberry Pi 400 that went unappreciated for the longest time. My Dad got it for me as a gift, and it was sitting in a box of spare parts for months. Once I finally got to open it up and take a good look at it, I really wanted to do something cool with it. The Pi 400 was great enough by itself, having a built-in keyboard which you would only need to add a monitor to have a complete computer setup. However, I wanted to have an "all-in-one" setup, with even less wires to plug in. And since I was in a "Fallout" kinda mood, having recently watched the TV series and played one of their games, I decided to model this all-in-one casing based off of the terminal featured in the Fallout game series.
The general idea was to build a plastic casing to house all the pieces, and extend the Pi 400's ports with panel mount cables. First things first, I needed a monitor. It took me a while to find a monitor that I liked, but in the end, the one pictured above was what I settled on. However, I realized much too late that the monitor in question turned out to be a 12V monitor, and I was trying to have all the pieces be consistently 5V. I needed to adapt my strategy if I wanted to have a system powered by only one adapter. So, I bought a power adapter that output 12V and 5A, which I would use to power the monitor first, then bring the remaining power down to 5V via a buck converter.