Hooking up the hardware

Joran Quinten
4 min readApr 25, 2018

This story is part 2 in the trilogy. Read up on the first part if you’re interested in the cool origin story.

With the speaker shield on the 40 pin connection, I needed a way to attach the activation switch. Fortunately, the shield doesn’t use all of the pins. The website pinout.xyz provided me with helpful schematics!
For now, I want to detect if the book is opened or closed. The first action will load a random file and start playing it. Closing will stop the playback. I’ve decided to try and use a light sensor, hidden in the book, which can tell whether it’s open or closed.

I had to wait a while for parts to arrive. In the meantime, I wrote/modified a script to test whether the sensor would work. When I hit the sensor with a flashlight, the script would trigger an update. Worked on the first try! Next step was modifying it so that it would trigger a one off action instead of continuous, to wait for the different states. I attached the sensor to pin 19 (GPIO 10), since it has the power (pin 17) and ground (pin 20) conveniently close.

FYI, I’ve ordered this lightsensor for a couple of cents and a bunch of cables and push buttons to tinker with. (I’ll provide a complete shopping list at the end of the series.)

I’ve published this stage as a separate branch on my github.

Since the hardware is going to be encapsulated within a book (without easy access) and I’m not sure how long the Pi will work on the battery pack, I’ve decided to add power buttons so that I can switch off the device to conserve energy.

I’ve soldered a push button to act as a power off button, soldered on pin 36 (GPIO 16) and a nearby grounded pin. Also found a helpful article which pointed me to soldering a button to connect pins 5 and 6 (GPIO3 and GND).

Soldering jumper cables is fun!

Disclaimer: before soldering, I tested the functionality directly with the jumper cables (female to female) attached to the hardware. I would recommend a breadboard for easier prototyping, but I didn’t have one on hand.

Soldered and working hardware!

Another small improvement after that was providing the startup script with a audio fragment, so that I can actually hear when my script is up and running 🎶. That turned out pretty useful!

The code for this stage is located on this version of the github repo.

The inner workings are complete!

I hid the complete jumble of wires, buttons and sensors in our bathroom and surprised my wife with a random fairy tale when visiting the bathroom. Hooray!

Preparing the layout of the components

Now that the hardware is more or less complete, I have a general idea of the dimensions, so I started looking for a book to act as a housing. Found one for a couple of euros (second hand) with some nice thick cardboard like pages. I like that is is easy to cut out, but also provides a rigid frame. I drew some rough outlines and figured I could always use stuffing if needed, but it turned out to be a snug fit in the end! I made sure to stay clear of the edges and just roughly cut out the space I needed.

Snug fit for the hardware in the cutout pages

I positioned the buttons opposite to the back of the book (is that the belly?) and hid everything underneath one of the pages at about 1/4th of the pages. The only visible part is the light sensor, through a small hole. I want to cover that part of the book with an illustration of my own.

Testing the hardware in the casing

So, I wanted to glue the pages together, but then realized that at some point, that battery will need recharging. Preferably without me having to break open the glued pages. For that, I’ve included some small powerful magnets to opposing pages as a sort of maintenance panel. I can open them, but in general the panel stays shut. Awesome! ✨

After that, I was confident enough to generously apply glue all over the pages. Used a wood glue, since I figured cardboard is kinda similar to glue and I had a bunch of it on hand (actually used more than I’d anticipated). Put some heavy stuff, wiped off excess glue and I now have a solid piece of cardboard, with space for my hardware, that resembles a book!

So for wrapping things up, I want to prettify the packaging. The complete end result can be viewed in awe in the final part of this series!

--

--

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