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.
-
IKEA Förnufig Air Purifier V2 - Custom fan speed controller + Blinkenlights
Basic premise:
Add lights (speed / noise / air-purity indicators, or needless dotstar+neopixel love), use small board to receive tachometer input and drive 24V fan PWM signal from particle sensor, along with new inputs for noise level. Plus show off Blockly based programming on Adafruit IO, and update as and when the new maths functions become available, but for now write a quick CircuitPython version that illustrates all the desired functionality (to port to Adafruit IO). -
Memento: Flicking USB ReadOnly/Write@Boot + Setting WiFi using QRCode
So you want your friends/family/strangers to enjoy the luxury of modern technology, scanning a QR-code to join a wifi network, but wait...you want to save that in
settings.toml
too? Sheeesh, a tall order, lets get on with it then!We'll need to check a button at boot to decide if the Memento camera has write access to the flash drive, or the PC. Then we can update the
settings.toml
file if it's writable, and either way we can offer to join the network listed in the QRcode. -
commands for the future
more of a personal note to remember some commands that were useful. I figure this is more likely to survive or be found compared to a gist/repo/onenote/whatever.
-
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:
-
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
) -
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: -
Recreating Disabled Adafruit IO Feeds - after resubscribing/mistakes
Best answer is: email Adafruit support, the team will get your feeds reenabled as soon as possible.
If you're aware that you're data is not worth anything and are happy to lose it all, then proceed to follow this guide to just recreate all the feed names.
Short answer is if there are only a couple then do it by hand, otherwise this script will save you a bit of time. I had nearly a hundred, and was curious on the state of the adafruit-io python library, so this happened :shrug:
-
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)
-
Using CIRCUP with Web-Workflow
Thanks to some hard work by Vladimir Kotal (@vladak)❤️, an open-source community contributor on GitHub who added this pull request, and thanks to our own CircuitPython wizard Tim (@foamyguy), there is now the ability to use
circup
with the web-workflow.I had a play by pulling from github last month as I was desperate. I had a device that was going to be left plugged into the mains, which was running out-of-date code and libraries (but otherwise functional), and so along the way fixed a couple of issues for Windows users or anyone needing libraries with nested folders.
-
Wippersnapper - Sensirion SEN55 Particulate/VOC/NOx sensor - Plus an educational saga in the quest for a case...
Wippersnapper
For those not in the know, WipperSnapper is Adafruit's plug-and-play firmware, which runs on their IO (think IOT) platform, offering free* data history(feeds) with graphs, dashboards, and automatic actions/triggers (along with integrating with other platforms like IFTTT). There is a paid upgrade for longer history, unlimited devices, SMS alerts, etc.
I love it because it's super quick and easy to test a sensor works, and to just get some data recording quickly.
Goto a web-page, flash over usb, add sensors via control panel (feeds + graphs are automatic), done.
Under the hood it's an arduino sketch, so adding additional sensors via github pull requests is surprisingly easy (I've added a few because it makes my future tasks easier).
-
Keyboard Scanning remix in Circuitpython
Remake this with kb2040.
Should be possible to ask for expected key sequence beforehand, then do really fast pin testing as each key is held down for a second or so. Might have to have the first key held of longer until a mapping match is found, similarly with rows if key not detected, follow onscreen prompts.
Accept key sequence as tuple of tuples or string, to allow basic keys or also row/col for more gamepad/midi/accessibility/unthinkable inputs.
Have config mode with usb storage disabled if after reset the onboard button is held at 2s, suggest to user after counting 1 long second (it checks at 2). Save keymap in toml or JSON or both, with a name or next available Id. Include number of pins and check files for possible matches of unknown future keypads, prioritizing those mapping attempts over other sequences.
https://hackaday.com/2023/10/12/keypad-interface-module-reverse-engineers-pinouts-so-you-dont-have-to/
-
How to go from a mathematically complex idea to a simple Minimum Viable Project (MVP😉)
So you've had a cunning plan in the middle of the night, and awoken to find it scrawled on some paper for fear of forgetting.
Now in the cool light of day you realise you have a great idea in front of you, all the pieces are there (maybe you jot a couple more points down), but very little idea of how to achieve the detail.