Schlagwort: unicorn phat

  • Monitor your GitHub build with a Raspberry Pi pumpkin

    Monitor your GitHub build with a Raspberry Pi pumpkin

    Reading Time: 4 minutes

    GitHub’s Martin Woodward has created a spooky pumpkin that warns you about the thing programmers find scariest of all — broken builds. Here’s his guest post describing the project:

    “When you are browsing code looking for open source projects, seeing a nice green passing build badge in the ReadMe file lets you know everything is working with the latest version of that project. As a programmer you really don’t want to accidentally commit bad code, which is why we often set up continuous integration builds that constantly check the latest code in our project.”

    “I decided to create a 3D-printed pumpkin that would hold a Raspberry Pi Zero with an RGB LED pHat on top to show me the status of my build for Halloween. All the code is available on GitHub alongside the 3D printing models which are also available on Thingiverse.”

    Components

    • Raspberry Pi Zero (I went for the WH version to save me soldering on the header pins)
    • Unicorn pHat from Pimoroni
    • Panel mount micro-USB extension
    • M2.5 hardware for mounting (screws, male PCB standoffs, and threaded inserts)

    “For the 3D prints, I used a glow-in-the-dark PLA filament for the main body and Pi holder, along with a dark green PLA filament for the top plug.”

    “I’ve been using M2.5 threaded inserts quite a bit when printing parts to fit a Raspberry Pi, as it allows you to simply design a small hole in your model and then you push the brass thread into the gap with your soldering iron to melt it securely into place ready for screwing in your device.”

    Threaded insert

    “Once the inserts are in, you can screw the Raspberry Pi Zero into place using some brass PCB stand-offs, place the Unicorn pHAT onto the GPIO ports, and then screw that down.”

    pHAT install

    “Then you screw in the panel-mounted USB extension into the back of the pumpkin, connect it to the Raspberry Pi, and snap the Raspberry Pi holder into place in the bottom of your pumpkin.”

    Inserting the base

    Code along with Martin

    “Now you are ready to install the software.  You can get the latest version from my PumpkinPi project on GitHub. “

    “Format the micro SD Card and install Raspberry Pi OS Lite. Rather than plugging in a keyboard and monitor, you probably want to do a headless install, configuring SSH and WiFi by dropping an ssh file and a wpa_supplicant.conf file onto the root of the SD card after copying over the Raspbian files.”

    “You’ll need to install the Unicorn HAT software, but they have a cool one-line installer that takes care of all the dependencies including Python and Git.”

    \curl -sS https://get.pimoroni.com/unicornhat | bash

    “In addition, we’ll be using the requests module in Python which you can install with the following command:”

    sudo pip install requests

    “Next you want to clone the git repo.”

    git clone https://github.com/martinwoodward/PumpkinPi.git

    “You then need to modify the settings to point at your build badge. First of all copy the sample settings provided in the repo:”

    cp ~/PumpkinPi/src/local_settings.sample ~/PumpkinPi/src/local_settings.py

    “Then edit the BADGE_LINK variable and point at the URL of your build badge.”

    # Build Badge for the build you want to monitor

    BADGE_LINK = "https://github.com/martinwoodward/calculator/workflows/CI/badge.svg?branch=main"

    # How often to check (in seconds). Remember - be nice to the server. Once every 5 minutes is plenty.

    REFRESH_INTERVAL = 300

    “Finally you can run the script as root:”

    sudo python ~/PumpkinPi/src/pumpkinpi.py &

    “Once you are happy everything is running how you want, don’t forget you can run the script at boot time. The easiest way to do this is to use crontab. See this cool video from Estefannie to learn more. But basically you do sudo crontab -e then add the following:”

    @reboot /bin/sleep 10 ; /usr/bin/python /home/pi/PumpkinPi/src/pumpkinpi.py &

    “Note that we are pausing for 10 seconds before running the Python script. This is to allow the WiFi network to connect before we check on the state of our build.”

    “The current version of the pumpkinpi script works with all the SVG files produced by the major hosted build providers, including GitHub Actions, which is free for open source projects. But if you want to improve the code in any way, I’m definitely accepting pull requests on it.”

    “Using the same hardware you could monitor lots of different things, such as when someone posts on Twitter, what the weather will be tomorrow, or maybe just code your own unique multi-coloured display that you can leave flickering in your window.”

    “If you build this project or create your own pumpkin display, I’d love to see pictures. You can find me on Twitter @martinwoodward and on GitHub.”

    Website: LINK

  • Laser-engraved Raspberry Pi hologram

    Laser-engraved Raspberry Pi hologram

    Reading Time: 2 minutes

    Inspired by an old episode of Pimoroni’s Bilge Tank, and with easy access to the laser cutter at the Raspberry Pi Foundation office, I thought it would be fun to create a light-up multi-layered hologram using a Raspberry Pi and the Pimoroni Unicorn pHAT.

    Raspberry Pi layered light

    Read more –

    Break it to make it

    First, I broke down the Raspberry Pi logo into three separate images — the black outline, the green leaves, and the red berry.

    Fun fact: did you know that Pimoroni’s Paul Beech designed this logo as part of the ‘design us a logo’ contest we ran all the way back in August 2011?

    Once I had the three separate files, I laser-engraved them onto 4cm-wide pieces of 3mm-thick clear acrylic. As there are four lines of LEDs on the Unicorn pHAT, I cut the fourth piece to illuminate the background.

    RASPBERRY PI HOLOGRAM

    To keep the engraved acrylic pieces together, I cut out a pair of acrylic brackets (see above) with four 3mm indentations. Then, after a bit of fiddling with the Unicorn pHAT library, I was able to light the pHAT’s rows of LEDs in white, red, green, and white.

    RASPBERRY PI HOLOGRAM

    The final result looks pretty spectacular, especially in the dark, and you can build on this basic idea to create fun animations — especially if you use a HAT with more rows of LEDs.

    Iterations

    This is just a prototype. I plan on building a sturdier frame for the pieces that securely fits a Raspberry Pi Zero W and lets users replace layers easily. As with many projects, I’m sure this will grow and grow as each interaction inspires a new add-on.

    How would you build upon this basic principle?

    Oh…

    …we also laser-engraved this Cadbury’s Creme Egg.

    Website: LINK