• Skip to main content
  • Shop
  • Learn
  • Blog
  • Forums
  • IO
  • LIVE!
  • AdaBox
Adafruit Logo
0
  • Sign In | Create Account
  • Playground
  • Shop
  • Learn
  • Blog
  • Forums
  • IO
  • LIVE!
  • AdaBox
Sign In
0
Adafruit Logo
  • Learn Categories
    • 3D Printing
    • AdaBox
    • Adafruit Products
    • Arduino Compatibles
    • Breakout Boards
    • Circuit Playground
    • CircuitPython
    • CLUE
    • Community Support
    • Components
    • Crickit
    • Customer & Partner Projects
    • Development Boards
    • Educators
    • EL Wire/Tape/Panel
    • Feather
    • Gaming
    • Hacks
    • Internet of Things - IOT
    • LCDs & Displays
    • LEDs
    • Machine Learning
    • MakeCode
    • Maker Business
    • micro:bit
    • Microcontrollers
    • Programming
    • Raspberry Pi
    • Robotics & CNC
    • Sensors
    • STEMMA
    • Tools
    • Trellis
    • Wearables
    Explore, Groups to get your gears turning
    Explore
    Groups to get your gears turning
    Explore Groups
  • New Guides
  • Playground
tyeth Notes
Image for user tyeth

tyeth

u/tyeth
Badges
7

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.

  • Image for user tyeth
    By tyeth

    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.

    I asked:

    " 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:

    Screenshot_2024-02-25_213906.png
    Save
  • Image for user tyeth
    By tyeth

    No-Code "EnSmartening" an IKEA FÖRNUFTIG Air Purifier - V1 Reuse existing PCB+Dial

    This project was a personal desire to put Adafruit IO through it's paces, and see how far I could go in recreating a project designed for ESPHome + Home Assistant. Traditionally I would have assumed it was too complex for the Actions and Dashboard of Adafruit IO if I used a Wippersnapper device, instead relying on Node-RED to string things together, but now that I work on the WipperSnapper project I was curious how far it had come / could go.

    The basic idea was to take a £60 "dumb" air purifier with a 3-speed dial (£70 with carbon filter) and add a WiFi micro-controller, so that it can be switched on and the speed controlled according to the values sent from a separate Air Quality sensor (Particulate Matter <2.5µm), and a user-adjustable control panel hosted as an Adafruit IO Dashboard.

    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)

    20231222_173849_(2).jpg
    Save
  • Image for user tyeth
    By tyeth

    How to go from a mathematically complex idea to a simple Minimum Viable Project (MVP😉)

    CircuitPython Day 2023

    My "optimistic" project for CircuitPython Day 2023 was an "Air" Theremin, specifically the smallest one in the world (as well as a larger kit version). I've never played one, and am not that musical, but they always intrigued me. The basic idea is an aerial, vertically mounted, that picks up conductive things nearby, and that picked up interference is fed into a sound generator and used to vary the sound.
      Normally a second "aerial" loop is horizontally mounted, and used for volume control, by having a horizontal loop it is sensitive in one plane (vertical plane, i.e. up+down direction) rather than all horizontal directions like the single pole vertical antenna/aerial that we use for pitch control.
      (The aerial behaves very similarly to a magnetic pickup on an electric guitar where the steel strings move back and forth in front of the guitar "pickups" also known as transducers. A pickup is a transducer that captures or senses mechanical vibrations produced by musical instruments)

    The "Air" element was meant to signify that there will be no Aerial, instead I had a Time Of Flight (ToF) sensor (VL53L5CX) spare from another project, that returns an 8x8 Grid of distances as a reasonably fast refresh rate. I had thought I could use the right hand side for pitch and volume (I now see separate volume hand is better), and the left side for playing samples and modifying the sound properties. (I imagined a drum machine or play-along-track to improve my theremin experience). Long term it would produce MIDI, but short term it would have a speaker (which turned out to be larger than the device by some margin).

    Of course I probably hadn't had enough coffee when fantasising about the idea, and if I played the theremin it would have been immediately obvious, but the Time Of Flight sensor was vertically sensitive (assuming I place it on the table facing upwards) and only has the equivalent of 8 pixels of horizontal resolution. After assembling a prototype and starting to record data and think about the maths I might need to do, it dawned on me the massive error I'd made. Fortunately I had just received another smaller sensor from Pimoroni, in addition to a second Sparkfun Mini ToF version. The smaller Pimoroni one fit so nicely on top of my Adafruit QtPy ESP32-S2 (with Audio BFF soldered on top), and the old one I was able to now mount at an angle.

    Originally I had the SD card (Audio BFF) on the bottom, and ToF sensor nestled in between the USB and StemmaQT connectors on the QTPY, which meant the buttons couldn't be easily pressed and therefore I wanted a capacitive touch button. (I thought a random wire initially would be replaced by some copper tape or something well thought out and complimentary to the shape/form/possible-case)

     To that end I stuck a 1MegaOhm resistor between ground and the TX pin (very few pins left after the I2S + I2C + SPI SD card), neatly folded over the SD slot, and protruding a little (less than the SD card) out one corner for easy touching.

    Save
  • Image for user tyeth
    By tyeth

    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/

    Save
  • Image for user tyeth
    By tyeth

    When Black and White QRCodes don't work: Qualia Touch Example Dual QRCodes for Wifi + WebWorkflow

    • Logs onto network if present, showing QRcode for the Wifi Access point for easy joining and remote configuration, also displays SSID. 

      Next to that is the Web Workflow QRcode, built from the IP address of the device and web workflow port if specified.

     

    • If the user hasn't configured SSID or fails to get an IP in 5seconds, then the help page QRcode is displayed along with a touch sensitive Circuitpython logo.

     

    • There is code to adapt the returned touch events to be rotated (the BAR 320x820 display is vertically orientated so coordinates of touch events need adjusting).

      The touch code cycles through the tilegrid and group objects looking for a callback on a tilegrid to trigger if the x + y (plus tile_width and tile_height) match the touch point.

      It works for the bitmap, but not the qrcode tilegrids, nor labels.

    Feature List:

    IMG_20231119_001742_326_(Custom).jpg
    Save
  • Image for user tyeth
    By tyeth

    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 called circup_dependencies with an array of strings. Similar to this:

    After looking at the current community bundle (which has a build script, and publishes json+zips with each release) I noticed the dependencies were only setup for a requirements.txt and not the new pyproject.toml circup_dependencies section. The build script did however include the requirements.txt and pyproject.toml for each included library in the built release assets (a zip for each mpy/circuitpython version plus a python file version).

    As a result of this I've included fake requirements in my requirements.txt (they will actually pass and install with python on a pc as the names match the official libraries. Then the two circuitpython dependencies are included in pyproject.toml as described above.

    The last thing was that there were two libraries for release, the Sensirion SEN5x device driver, and a base Sensirion I2C python driver. Both of these need to be submoduled into my bundle repo, in a similar fashion to the official community bundle repo.

    Create the bundle

    Simplest for me was to fork the community bundle, then clone it locally and git submodule deinit --all -f and delete all the submodules, then add the two of my own, and tweak the readme. I also stopped the CI script from attempting to publish to AWS S3. It's worth noting it will error if the submodules commit reference doesn't match latest tag.

    The usual git submodule add, for each library to be included, and if you update things in the driver repos then craft a new release for them and then come back to the bundle repo and enter the library submodule folder and git pull then commit and push those changes, then create a new release of the bundle. Probably equally wise to use the update script or tweak the CI script to update and release (could be scheduled).

    Use the Bundle

    circup bundle-add <github_owner>/<github_repository_name>

    e.g. for https://github.com/good-enough-technology/CircuitPython_GoodEnough_Bundle

    circup bundle-add good-enough-technology/circuitpython_goodenough_bundle

    then install newly available package:

    circup install sensirion_i2c_sen5x

    (I prefer to add the --py option to get readable python instead of .mpy module files)

     

    Screenshot_2023-11-25_222819.png
    Save
  • First
  • Previous
  • 1
  • 2
  • 3
Search

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.

    • Contact Us
    • Tech Support Forums
    • FAQs
    • Shipping & Returns
    • Freebies
    • Terms of Service
    • Privacy & Legal
    • Website Accessibility
    • LLMs.txt
    • About Us
    • Press
    • Educators
    • Distributors
    • Jobs
    • Gift Cards
    "That brain of mine is something more than merely mortal; as time will show"
    Ada Lovelace
    Adafruit Logo
    A Minority and Woman-owned Business Enterprise (M/WBE)