top of page
  • Writer's pictureNathan Thompson

Pi Day Inspired Hacking: Capture The Pi


In keeping with the theme from last year, I once again decided to spend much of February and March creating a Raspberry Pi themed project to celebrate Pi Day. This year though, I wanted to delve into much more than just the world of the Raspberry Pi. I decided I wanted to learn more about wearable technologies. These are articles of clothing with various microcontrollers sewn into the fabric to control lights or activate sensors. Many of the designers and engineers I respect have been developing their own wearables for years. Using their projects as inspiration, I devised the most outrageous use of wearable technologies I could think of: a virtual capture the flag game. I designed gloves with LilyPad USB Arduinos sewn into the back of the hand that connected with sensors in the fingertips to allow players to steal virtual flags from Raspberry Pi bases and persist the game score to a centralized server. And with that, Capture The Pi was born:

Parts List:

In addition to the hardware, if you want to duplicate this project you will need the software to power all of the components. The full repository can be found here, and is split up according to the various physical components that comprise the project. The Pi portion runs on the Raspberry Pi base stations themselves. It is responsible for outputting voltages on certain GPIO pins so that the gloves can tell which base you have touched. It is also responsible for displaying the game score to users. The game score is retrieved from a centralized scoring server powered by the Node package. This package should be deployed to a location accessible by all devices, such as an AWS or Heroku server. The glove itself is powered by the Arduino codebase which illuminates strips of colored LEDs to indicate a player's team and whether they are carrying the flag. It also registers voltages from conductive pads on the glove fingertips to determine when a player has scored, then relays that information to a Pebble Time Smartwatch on the player's wrist via a physical serial I/O connection. The Pebble Time is running a custom Pebble app that also displays the score and relays score updates to the centralized server using an Android app running on the player's smartphone.

Assembling the Hardware:

Those familiar with the blog from last year will recognize that the same Raspberry Pi base station was used in my previous project. For assembly instructions, refer to the Assembling the Raspberry Pi section in the blog linked above. The one additional note about the base station is that you must attach conductive pads to pin 26 and a ground pin to allow physical interaction between the glove and the base. I just took a jumper cable and pushed it through a scrap of conductive fabric for each pin and that worked fine for hackathon purposes. As for assembling the gloves, SparkFun offers an incredibly useful LilyPad Sewable Electronics Kit Guidebook for getting started with wearable technologies. In addition to walking you through a few sample projects, the guide offers many general tips to those new to sewing altogether. It describes the proper way to attach the conductive thread to the unique pin loops of the LilyPad Arduino. From there, you will literally sew circuits into the gloves. The actual designs for the gloves can be found in the notes section of the repo along with useful information for establishing the physical connection with the Pebble Time Smartwatch. The designs are also shown here:

The circle on the back of each hand is the LilyPad Arduino with the various pins labeled for reference. The dotted lines extending from the pins represent conductive thread stitching that runs from the Arduino to rows of LEDs on the forearms and conductive pads in the fingertips and forearms. I found that the best way to split the conductive thread lines was to attach a metal washer to the glove and run additional threads off of that. This method is depicted at the bottom of the "Right" glove diagram. The battery pack is visible on the side of each hand opposite the thumb and should be attached by sewing a pouch onto the glove using scrap, non-conductive fabric. Lastly, the Pebble Time is depicted on the wrist with lines running to the ground and data pins on the Arduino.

Interfacing with the Pebble Time:

While sewing all the necessary circuitry into the glove was incredibly tedious work, the most difficult part was definitely assembling the physical connector for the Pebble Time. Doing so is achieved using Pebble's smartstrap protocol. Pebble Time owners know that power cables attach to the back of the Pebble Time using two magnets, and that power is sent to the device through pogo pins mounted in the cable. What they may not know is that only one of the two pins on the Pebble Time actually receives power for charging. The other is a data pin intended for physical serial I/O. In fact, tutorials abound for converting Pebble Time power cables into data cables. I will also describe that method in this post as there are no commercially available smartstrap connectors on the market today. If you disassemble a Pebble Time charging cable you will find it looks like this:

With the casing removed you can see a red and a white cable attached to the battery contacts respectively. You will also see a yellow wire connected to a solder bridge across the two pogo pins. This allows the charge cable to be omnidirectional; no matter what orientation the user attaches the cable to the watch, power will be delivered to the power pin on the watch itself. If you want to be very advanced you too can create an omnidirectional connection to the Pebble Time, but it will require removing that solder bridge, which proved to be incredibly difficult. The solder itself tends to melt just moments before the plastic casing also begins to melt, and once the casing is compromised the little magnets will literally rip themselves apart due to their attraction to one another. The much more simple answer is to create a mono-directional connection by simply place a piece of non-conductive tape over the pin that would touch the power input on the Pebble Time itself.

In the photo above I've cut the wire too close to the charging head to be useful in attaching to the Arduino. You could cut the wires much longer and run them directly to the Arduino. However, if you are attempting to create an omnidirectional connector, or if you just want an easy way to swap out a connector in case it is damaged during game play, I would recommend trimming the wires off altogether and instead soldering on one of the 4-pin Male Headers from the parts list. With that attached you can easily plug the connector into the 4-pin jumper wire. I then cut the jumper wire in half and connected that to the Arduino, thus allowing me to swap out connectors at any time without rewiring the device altogether.

Some notes about creating the smartstrap connector and the codebase in general:

  • Pebble's own documentation claims you will need an open collector circuit to support serial I/O. This appears to be the case if you are using Hardware Serial I/O with two pins on the Arduino itself. However, the LilyPad USB Arduino does not support Hardware Serial I/O and so Capture The Pi relies on Software Serial I/O. My testing showed that I could wire the connector directly into the Arduino pins without the addition of a resistor when using Software Serial I/O.

  • Only Arduino pins that support the attachInterrupt() function can be used for Software Serial I/O. From my testing I found that this limits Capture The Pi to using digital pins 9, 10, and 11 on the LilyPad USB Arduino board.

  • Serial I/O between the Pebble Time and an Arduino is achieved using the ArduinoPebbleSerial library, and in fact the Arduino code in Capture The Pi is based heavily on the example code in that project. Pebble also provides extensive documentation for talking from the Pebble Time to the Arduino and vice versa.

  • The central server exposes a REST api for incrementing and resetting the game score. Once you have deployed it to a server you will need to update the Pi code and the Android code to point to the correct URL.

  • The Android code uses retrofit for sending REST calls to the server. The Pebble code of course uses PebbleKit Android to communicate with the Android companion app via Bluetooth.

And Now for the Fun Part:

Once you've assembled all the hardware it's time to play! The README files in the individual submodules of the repo contain all the information necessary to install the software on the respective devices. When you launch the base code on the Raspberry Pi you will be prompted to select a team for that particular station. After doing so it will prompt you to register players for that team. You can now start the Pebble app and watch for it to connect to the Arduino. With the connection confirmed, you can touch you fingers to the base station pads and the Arduino will automatically recognize and set your team. Once everyone is registered, boot up the companion Android apps and start playing!

21 views0 comments

Recent Posts

See All
bottom of page