Linux Format

Further making adventures

Let's finish things off with a collection of suggestion­s for further projects.

-

Having a portable power supply for your Pi or other devices is a great idea, and there are a few options. Of course, a standard USB powerbank (and they can store a whole lotta Coulombs these days) is fine for many applicatio­ns, but there are alternativ­es. If you have a lot of batteries lying around check out the ModMyPi’s BattBorg. This enables you to power your Pi with four AA batteries. For more demanding situations eight AA or 9V battery attachment­s are available. The BattBorg defends against voltage drops, regulating power as batteries become weaker and refusing to turn it on if they’re too weak.

The Ultrasonic sensor we used earlier can also be used with the Pi, but we need to be careful because the Pi’s GPIO pins don’t take kindly to the 5V pulses from its Echo pin. We need to drop these to under 3.3V to be safe. We can do this with a potential divider: two resistors placed in series with the GPIO pin in between them. You can choose the value of one resistor and then work out the value the second needs to be. In this case a 1K and a 2K resistor will work. Alternativ­ely, check out the UltraBorg board, which makes it possible to connect up to four servos and four ultrasonic sensors straight to the i2C bus of your Pi (SDA and SCL). It can use a separate battery supply which is a good idea if you connect four servos to it. The jumper should be removed if you do this, otherwise you risk damaging your Pi

PiJuice is a crowdfunde­d battery hat for your Raspberry Pi. It comes with a 1,820mAh lithium ion (Li-Ion) battery that’s good for up to 5 hours of use, but this can be replaced with a lithium polymer (Li-Po) battery. Further, you can attach a solar panel (a large 40W one is available from ModMyPi and Pi Supply for around £116) to charge the battery, making for a completely isolated solution (unless the sun runs out). Like the PaPiRus e-Ink display it comes with the added bonus of a real-time clock, which will be useful for keeping time while offline. PiJuice's software enables battery levels to be read, and a shutdown script can be set to run when they get low. This makes for a delightful­ly simple UPS (uninterrup­tible power supply) solution.

If you can find a small-enough power supply (or a big-enough jar), then connecting it and a camera to a Pi Zero, and then sealing the whole arrangemen­t in a jar, can make for some nice nature photograph­y. The No-IR edition of the camera (which has no IR filter) can even see at night time, which makes it great for capturing badgers, owls (if you’re lucky) or other nocturnal

species. Making a rudimentar­y motion detection program in Python is straightfo­rward, so you don’t need to worry about filling up your SD card with the same photo of the eerie, still darkness.

Have we got to 10 yet? We don’t know, but we’re going to keep going because there’s no end to the fun (and because you have to fill this page–Ed ).

Unicorn HAT -HD

Pimoroni’s Unicorn HAT’s, which featured an 8x8 matrix of RGB LEDs, proved tremendous­ly popular. So they had to go one better and make an HD edition that quadruples the LED count. It also comes with a nice diffuser whose height can be adjusted to make for different blinkenlig­ht blurring effects.

A neat trick which we’re still working on is getting this to display a spectrum analyser for currently playing music. MPD can easily be configured to write to a FIFO pipe by adding a section exactly like audio_output { type “fifo” name “myfifo” path “/var/tmp/mpd.fifo” format “44100:16:1” } to /etc/mpd.conf . We can then access this buffer in Python thusly: fifo = os.open(‘/var/tmp/mpd.fifo’, os.O_RDONLY) and perform the required FFTs to get spectrum data. Or you could use the audioop package to do it for you. A good starting point would be to make a simple VU (Volume Unit) meter, and we would get the peak level from the buffer with the following: data = os.read(fifo, 4096) stereoPeak = audioop.max(data,2)

One important thing to be aware of is that you can’t use the 3.5mm headphone jack and the Unicorn HAT at the same time. This is because they both use PWM, so you'll either see glitches on the LEDs or hear interferen­ce in your audio. It works fine with HDMI and can also work on top of a DAC hat such as the IQAudio one we tested. Peak blinkenlig­hts is achieved by the LightShowP­i project ( http://lightshowp­i.org), which supports all manner of LED boards and can make them blink in all kinds of ways.

Relax with RetroPie

The RetroPie project ( https://retropie.org.uk) includes a number of emulators, including SNES and Gameboy (more can be added later). It's available for the Pis as an SD Card image (the recommende­d approach) or it can be installed manually. Separate images are available for single (Pi 1 and Zero) and multicore (2 and 3) Pis. It’s also available on Linux for PCs, which are more capable of emulating the newer platforms.

A big part of RetroPie is RetroArch, a front-end for the Libretro API (a cross-platform effort that enables different emulators (‘cores’) to be treated uniformly). Go to https://launchpad.net/~libretro/+archive/ ubuntu/stable to see the huge number of Libretro cores available on Ubuntu. Many retro-styled gamepads are available to help your ring-collecting or mushroomea­ting adventures – we favour the old PS2 style.

Gamepads and touchscree­ns and keyboards and rodents are all well and good, but sometimes you just want to control your Pi by shaking your fist at it. And now you can, courtesy of the Flick HAT gesture control interface. More accurately, you’re supposed to use swipes, taps and flicks of the wrist, but this is still pretty cool.

And that's all we have space for in this month’s maker extravagan­za. Special thanks to Jacob and Claire at ModMyPi for generously lending us so many goodies to make this possible. Also thanks to local Bath maker Luke Clifford for letting us use his workshop, its many tools and for helping us 3D print our wooden Pi case.

 ??  ?? The PiJuice battery pack has an RTC and makes your Pi truly portable. You can even add a solder panel to charge it.
The PiJuice battery pack has an RTC and makes your Pi truly portable. You can even add a solder panel to charge it.
 ??  ?? Ultraborg solves several sensor-related problems at once. You can even daisychain multiple Ultraborgs together.
Ultraborg solves several sensor-related problems at once. You can even daisychain multiple Ultraborgs together.
 ??  ?? BattBorg has three components on the PCB and is available as a soldered or an unsoldered kit.
BattBorg has three components on the PCB and is available as a soldered or an unsoldered kit.
 ??  ?? A controller like this and the RetroPie distro make for many lost hours gaming.
A controller like this and the RetroPie distro make for many lost hours gaming.
 ??  ?? The Unicorn HAT-HD includes some classic effects that hearken back to the 90s demo era. Ah, those halcyon days of computing…
The Unicorn HAT-HD includes some classic effects that hearken back to the 90s demo era. Ah, those halcyon days of computing…
 ??  ?? This GrovePi sensor measures air quality. It can detect carbon monoxide, formaldehy­de and alcohol, a typical LXF evening out.
This GrovePi sensor measures air quality. It can detect carbon monoxide, formaldehy­de and alcohol, a typical LXF evening out.

Newspapers in English

Newspapers from Australia