Search This Blog

Friday, July 7, 2017

Pi Tote-- a sewing & circuitry project with the Raspberry Pi Zero W

Heads up... it's a bit of a lengthy reflection on the process I went through making my first Raspberry Pi "wearable". If you just want the final code and bag pattern, skip to the end :)

A couple of months ago, playing around with my new Raspberry Pi Zero W and thinking about some of my upcoming summer ed tech events, I decided that I wanted to make something that would fully take advantage of the compact size of the Pi Zero, that was somewhat useful, and that I could take with me and share with my maker friends during my summer tech travels.
Me & grandma celebrating!

I loved the idea of making something wearable and blinky, and also wanted to figure out a way to incorporate the use of my grandmother's hi-tech embroidery machine. Right away I thought it would be fun to embroider the Raspberry Pi logo and from there I realized that a tote bag would be the way to go for my first wearable project.

Now, I know some readers are going to chime in and suggest that I should have used something other than my Pi Zero to create my "wearable", and at first I did look around at some of my other options, but realized that the point wasn't to buy new toys-- rather, I wanted to see what I could create with the materials that I already had available to me.

Here are the materials that I used and the process that I went through to create my first Raspberry Pi "wearable"-- the Pi Tote.

Materials Used:

  • Raspberry Pi Zero W
  • 8" female to female jumper cables
  • 5 mm clear white LEDs
  • 1 yard of heavy cotton fabric for main outer pieces of bag
  • 3/4 yard of patterned cotton fabric for inside pieces of bag
  • 1/3 yard of solid cotton fabric for bottom of bag
  • Embroidery thread and Brother "Dream Machine 2" embroidery/sewing machine 

My Process:

Step 1
Grandma researching
My 1st step was learning how to use my grandmother's embroidery machine to upload a custom design & embroider it in the desired size. Although my grandmother uses the machine regularly, she had yet to create her own designs, and so we did a little reading to see how we might upload our own image and convert it into a pattern for embroidering.

After some playing, we had our image uploaded to the machine and converted into a line drawing. I embroidered my first design and, happy with the outcome, I took it home to start experimenting with the electronics, while I set my grandmother with the task of finding a simple tote bag pattern that we could use to sew our own bag which would include a pocket that I could use to conceal the computer and cords.

Step 2
Embroidered Raspberry Pi logo prototype in hand, I started exploring the different ways that I might be able to make my raspberry light up.

The first iteration involved programming random pulsing LEDs on the Sense HAT's LED matrix, but the square shape of the matrix didn't allow for much flexibility in where the LEDs would be placed and trying to shine the matrix through the embroidery only provided a dull glow from the fabric.

Picademy inspiration
I started thinking about how I could use individual LEDs to light up my design, but wasn't sure at first how I'd secure the LEDs to the bag while connected to the computer. Then I remembered the day 2 project that my team created at the Picademy that I'd attended in April 2016-- Babbage the teddy bear with light up eyes & ears. We'd connected LEDs directly to chained jumper cables, with resistors linked in the chain, and strung the LEDs from our Pi and through the teddy bear. I could do something similar with my bag!

I cut a couple of holes around the edges of the embroidered logo, popped a couple of LEDs through the holes from behind the embroidered patch, and connected the cables to the Pi. I ran a simple blinking program to test the lights and decided this design was a winner!

Step 3
Next I focused on coding the LEDs to blink. I wasn't sure at first how exactly I wanted the LEDs to look, so I started by just making sure I could get them all to blink one at a time. After some consultations with my very creative family, I decided that what I really wanted was for the LEDs to pulse randomly inside the raspberry (which also meant a couple of changes to the embroidery design later).

I'd never used a pulse command, but hoped something existed and went to the gpiozero documentation to see if there was something there that I could use. Indeed, I quickly found information on how to pulse an LED. I tested one and had no problem getting it to pulse-- woohoo! Off the top of my head I didn't know how to make an action happen randomly, so I started off by coding my LEDs to pulse one after the other. This looked okay, but program was getting long and messy and it still wasn't exactly what I wanted.

I started googling for the Python commands that would help me pulse my LEDs randomly and wasn't finding what I wanted. Luckily, it didn't take long for me to remember that Ben Nuttall included tutorials on the 'random' commands in his PiCamera worksheets, so I headed to the Raspberry Pi website to look back at the "Getting Started with PiCamera" lesson. I ended up creating a list of my own for the very first time (called 'lights' and which included each of the LEDs I had connected to the Pi) and programming my Pi to randomly pulse an LED from the list in a forever loop. This program ended up doing exactly what I wanted and was, thankfully, a much neater bit of code than I'd started off with!

Step 4
With my code ready to go, I needed to get moving on the bag itself. My grandmother found a pattern we thought might work for a couple of beginners (my grandmother is a very skilled seamstress, and was a great resource for helping someone like me, with a only a couple of sewing projects under her belt, but she'd never done a bag so we wanted to start with something simple). I picked out some fabric I liked and we started working our way through the pattern. Several days into the cutting, pinning and sewing, as we were working through the steps, we realized that the pattern we'd chosen was not as intuitive as we'd hoped and when we hit a wall that we were struggling to get over, I scrapped the half of the bag we had done and started searching out an  easier pattern... on YouTube.

The first video that popped up looked super simple (a pattern from DIYer Loepsie), so, with just a week before ISTE (the first event at which I wanted to be able to use my new blinking bag) I went back to the fabric store and we started again. I had to do a few calculations in order figure out how much material to buy (a good math test for myself!), especially after making one small adjustment to the measurements provided in the video (I used three fabrics instead of two), but otherwise the instructions in the video were super simple to follow (much more so than the original pattern we bought) and in about 3 hours, we had a tote bag made!

Step 5
Several iterations of raspberry
I decided during my electronics tests that rather than place the LEDs around the outside of the embroidered raspberry, I wanted to insert the LEDs inside the raspberry, so I needed to make a couple of adjustments to my embroidery design. I went back into my digital file and erased out some holes in the design where LEDs could be placed. It took a few tries and test runs to get the holes the right size-- not too big, not too small-- and a thread ripper to jab through the material to open up the holes.

Step 6
Once my design was ready, I embroidered the final Raspberry Pi logo onto a swatch of outer fabric to make into pocket for the bag. The size of the swatch was measured with the intention of having enough room to house my Pi Zero W and the jumper cables needed to attach the LEDs onto the pocket.

Adding the pocket onto the bag design turned out to be a pretty simple endeavor. We sewed lining onto the back of the pocket, hemmed the edges and then sewed three sides onto the center of the bag.

Step 7
The final step was to string the LEDs through holes & test the final product. I ended up sliding the LEDs through the holes on the front of the bag and then attaching the cables from the back side of the pocket. This kept the LEDs securely in place and prevented a lot of sliding around.

The first time I connecting everything, I used a 4" female/female cable attached to an 8" male/female cable attached to the LED (mainly because that's what I had in my tool box). With this setup, the cables proved to be too long and took up too much space in the pocket for me to be able to hide everything as neatly as I wanted. With the pocket so tightly packed with equipment, it also made it difficult to maneuver my hand around and get the LEDs secured. So I did have to do a little more shopping; I purchased 8" female to female cables so that all I needed was two jumper cables per LED, rather than four. This proved to be a much cleaner setup, and left enough room for me to squeeze my hand into the pocket and get all of the LEDs connected to the Raspberry Pi.

Step 8
Editing rc.local file
Initially I planned to use VNC viewer and a portable cell battery to run program headless. The cell
battery worked fine, but while at ISTE I tried connecting to VNC viewer to no avail. Not sure if it was the spotty wi-fi network, but this kink in my plans led me to researching how to program my Pi to run a specific program on boot up. This was something I'd tried learning several months back with no luck. Somehow, this time around, and on a time crunch, I was finally able to find the directions in the Raspberry Pi documentation that allowed me to set up my Pi to run my pulsing light program on boot up by adding just one line of additional text to the rc.local file.

Just a couple of hours before the Raspberry Pi Jam at ISTE, I had my blinking tote bag running beautifully!



  1. Thank you for sharing a great project, Amanda. I have been looking for wearable art projects to teach and engage at-risk students (grade 9). How expensive was the entire project, including all materials and approximately how much time did it take you to complete, including figuring out the embroidery feature, programming, trouble-shooting, and assembly? If you are able to share that information with me, it would be helpful. Also, thanks for a great blog example. I opened an account, but have not attempted my first blog yet.

    1. Hi there! Cost wasn't terrible-- about $20 for whole thing. The fabric was the costliest part of project-- I tried to only purchase fabric off the clearance rack at the yardage store, but it was definitely tricky to find fabric at a good price. I've been told that is a good resource with good prices if you're planning ahead. The Zero W is only $10 and since reusable for a plethora of projects, a great price I think. And I lucked out when it came to the embroidery-- grandma has a huge collection, so no cost there for me :)

      As far as time, it only took me about 3 hours to cut fabric and sew together the bag. Embroidering time with our machine was a few hours, but that includes trying out various iterations of the design. And coding, once I figured out what commands to use, only took about an hour, including wiring up the bag.

      If you're interested in wearables, Packt recently published a book on wearable with Raspberry Pi by Jon Witts. You might want to check it out!

      I hope you share whatever cool wearables you create with the 9th graders!

  2. Great project and very resourceful! My wife recently obtained an embroidery machine and we're trying to learn to use it and find projects. I will share this with her. Thanks for sharing.

    VNC can be spotty and quirky. If you aren't familiar with using ssh, let me know and I'll be glad to help get you started. You can do a lot with it, including managing your vnc connection, and I do a huge amount of my work using ssh, sftp and scp.

    1. Thanks, David! I haven't done much with ssh so once I'll be sure to reach out once I get to playing more with it.