Once upon a time

Joran Quinten
4 min readMar 26, 2018

This post outlines the first steps I took in the world of tinkering with small computers (Raspberry Pi). As a web developer I have some coding experience, but not so much in creating physical stuff, which was fun to do! A lot of the solutions I came up with, opened up a new field of tech to me: I had little Linux experience, zero Python lines written and absolutely no soldering or manufacturing experience. This goes to show that with a decent plan and access to the internet, you can do whatever you want!

Just after Raspberry announced their good old Raspberry Zero would be upgraded to include Bluetooth and WiFi capabilities, I decided to splurge the cash on one, with visions of home automation, gathering sensory data and so on (yeah, I read the various “Top 10 Raspberry Pi projects” lists)!

On receiving I delved cautiously into the Raspbian OS, and… that was it. Cool tech, but I couldn’t come up with a feasible project for my capabilities. My Pi actually ended up serving Kodi to the bedroom TV. And honestly, the Zero isn’t well equipped to handle even that.

Speaker pHAT playing a Fairy tale!

The Problem

Fortunately, kids are a great source of inspiration, it appears! My kids love hearing stories and I love reading them. My kids also love listening to stories and we would play recorded stories from our smartphones or our computer. My oldest son sometimes wakes up really really really early and we allow him to listen to stories so we can get some shuteye. Downside is that we have to lend our phones (which I don’t like to do) or sit with him listening together. Even though the latter sounds romantic, it really isn’t at 5 am!

So. A problem.

Now let’s figure out a solution. A small device with simple operations and audio capabilities could do the trick! Enter the Raspberry Pi Zero W!

I want a device that my kid can operate and simply plays one story on starting the device.

By stories I mean fairy tales. They have the right length to occupy and interest them. I can just pick a random story, since neither of my kids have any favorites (well, that changes from time to time).

The solution

First, let’s deal with audio output. I have a dirt cheap Bluetooth speaker laying around, so see if I can hook it up (reliably) to the Pi. Hit some snags there, with the Pi not pairing or, when it did pair, I could hear nothing! Not reliable enough anyways. It also occurred to me I didn’t want to have two battery enabled devices depending on each other. Out the window with the Bluetooth route.

At this point I’ve decided on the form factor. It should be a book. An old fashioned book which, on opening, reads a random fairy tale. Just like magic! The magic lies in that it is a standalone device which you can take anywhere. The Pi is on it’s own. It doesn’t need much. A battery, a switch and audio output.

Sidestep to powering the device, because batteries are easy, I’ll just hook up a charger to the Pi and let it sit. Might want to be able to go into some power save mode, but for now: Power solved️!

For audio, I located a small shield that seems perfect for what I have in mind: a pimoroni Speaker pHAT will fit like a glove. The installation is straightforward. Hadn’t soldered before, but worked in a single go! A few youtube video’s helped. Audio solved!

Soldering the pins on the Pimoroni Speaker pHAT

Now I could actually test some stuff, so I wrote a python script that plays sounds. (First python scripts I ever wrote. Overall, happy with the result.)

Found out that it would be convenient to be able to manage the files. Installed Samba on the Pi, works like a breeze! From my home network I can drag and drop files to the designated folder.

The script I wrote was just for testing the audio output. Now I do need to hook it up to controls. I’ve ordered some parts from China and while delivery is pending, I suppose it would be nice to make some progress on the script. Instead of hooking it up to a physical switch, I’ve decided to attach a simple web interface to control the playback. I want to be able to start, pause and stop the playback. Shutting down the device as a bonus. This allows me to verify that the software, at least, is working as expected.

Powered the Raspberry Pi Zero W with a portable battery pack. Big success! 👌

Iterating the software

Cobbled up a MVP with some status indication in a small Flask application, using web sockets for direct controlling and sending updates. After some tinkering and getting my hands dirty with Python, I was able to control playback on the device via a web interface. Nice!

You can inspect the code for that implementation on my Github. Might need some minor adjustments to work on your local network maybe.

Now I’m in the process of waiting for some shipments from China to arrive, in order to wire up the hardware. I’ll do a follow up when that’s up and running.

--

--

Joran Quinten

Dad with ♡ for web, tech, science, tinkering with stuff & photography. Works as an Interaction Developer. Tweets stuff @joranquinten & writes every now and then