A PirateBox is a Linux based system built using free software for the Raspberry Pi that provides private sharing of digital content. The PirateBox creates a local WiFi network, independent from the Internet, with anonymous file sharing and chatting capabilities.
I wanted to make a PirateBox and create a cool looking case for it. I used a laser cutter to cut the pieces of the case from 1/8" thick birch plywood and painted it to look as shown in photos 1 and 2. A small Python program controls custom hardware that makes the arcs above the skull glow when the PirateBox is up and running. Another small Python program controls a push button switch that illuminates when the Raspberry Pi is powered up. When the switch is pressed, the program shuts down the Raspberry Pi preventing the problems that can occur if you just unplug a running Raspberry Pi.
The "PirateBox Wiring Diagram" shows how the various components are connected to the Raspberry Pi. The second diagram and the schematic show the wiring for the LED circuit board. Since the three large LEDs draw more power than the Raspberry Pi can provide, the LED circuit board is powered separately and uses an optoisolator to keep the LED circuit isolated from the Raspberry Pi.
The PirateBox can be painted with different color schemes to create the skins shown in step 19.
This instructable assumes you have experience with setting up and running a Raspberry Pi, that you have experience soldering components to printed circuit boards, and that you have access to and experience with a laser cutter.
I made this at TechShop.
Step 1: Parts
The following parts are needed to construct the Raspberry Pi PirateBox:
Raspberry Pi Parts:
- 1 Raspberry Pi model B 512MB RAM (Available on Amazon or Adafruit ID 998) (photo 1)
- 1 16GB SDHC class 4 card (photo 2)
- 1 HK Mini USB WiFi 150Mbps wireless adapter 150M LAN 802.11n/g/b with antenna (available from Amazon) or other supported WiFi adapter for Raspberry Pi (photo 3)
- 2 1 1/4" #4-40 Machine screws and nuts (photo 4)
- 6 1/4" Round nylon spacers for #4 or #6 screws (photo 4)
LED Circuit Board Parts:
- 3 10mm Diffused blue LEDs (Jameco Part no. 2152147) (photo 5)
- 3 47 Ohm 1/4 watt resistors (photo 6)
- 1 USB female 4 position solder right angle thru-hole 4 connector (Jameco Part no. 2096181) (photo 7)
- 1 Adafruit Perma-Proto half-sized breadboard printed circuit board (Adafruit ID 571) (photo 8)
- 1 NPN Optoisolator PS2501-1 (Jameco Part no. 320653) (photo 9)
- 1 120 Ohm 1/4 watt resistor (photo 10)
- 2 12" Jumper wires (one end male, one end female) (Sparkfun Part number PRT-09385) (photo 11)
- 24 AWG solid core hookup wire (photo 12)
- 2 3/8" #4-40 Machine screws (round head) and nuts (photo 13)
- 2 Round nylon spacers for #4 screw size, 0.187" outer diameter, 0.115" inner diameter, 1/8" length (Amazon Part B000FP7TY0) (photo 13)
Shutdown Switch Parts:
- 1 16mm Illuminated push button red momentary switch (Adafruit ID 1439) (photo 14)
- Heat shrink tubing (1/16" diameter) (photo 15)
- 4 12" Jumper wires (one end male, one end female) (Sparkfun Part number PRT-09385) (photo 16)
- 1 470 Ohm 1/4 watt resistor (photo 17)
Hardware for the Faceplate:
- 6 1/2" #4-40 Machine screws (I used black nylon screws for the black faceplates and zinc screws for the silver faceplates) (photo 19)
- 6 #4-40 Machine screw nuts (photo 19)
Cables and Cable Mounting Hardware:
- 1 USB type A male to type A male cable (photo 20)
- 1 USB type A male to micro USB male cable (photo 21)
- 2 USB power adapters (5 volts @ at least 1 amp each) (photo 22)
- 3 Nylon cable clamps for 3/16" diameter cable (Jameco Part #173729) (photo 23)
- 3 3/8" #6-32 Machine screws and nuts (photo 23)
- Short cable ties (photo 24)
- 4 Self adhesive rubber/plastic feet/bumpers (height 1/4") (photo 25)
- 1 18" x 24" Sheet 1/8" (3mm) birch plywood
- 1 8" x 3" Sheet of 1/8" Sign lighting white 60% or 40% transparency acrylic (Available from TAP Plastics)
- Painter's tape (photo 26)
- Flat black spray paint (photo 27)
- Flat white spray paint (photo 27)
- Metallic silver spray paint (photo 27)
- Wood glue (photo 28)
- Small brush (photo 28)
- Adjustable band clamp for gluing (photo 29)
Tools (Not pictured):
- Laser cutter and engraver
- Soldering iron and solder
- Wire cutters / wire snips
- Wire strippers
- Needle nose pliers
- Screwdriver (small Philips head)
- Heat gun, lighter, or matches for the heat shrink tubing
Equipment for installing Raspberry Pi software (Not pictured):
- HDMI capable computer monitor
- USB keyboard
- USB mouse
- Ethernet cable
Step 2: Cut the Case Parts With a Laser Cutter
The first step is to cut the parts for the case out of a sheet of 1/8" (3mm) birch plywood. A 45 watt Epilog laser cutter at TechShop was used to cut out and engrave the parts. All of the case parts can be cut out of one 18" x 24" sheet of the plywood.
The laser cutter settings used were:
- Raster: Speed 30 Power 60
- Vector: Speed 10 Power 85
- Frequency: 500
The finished parts are:
- Faceplate with eyes (photo 1).
- Top of the case (photo 2): the faceplate will be mounted on this part.
- Bottom of the case (photo 3). The design includes engraving that shows where all the electronics will be mounted.
- Side with cutouts for the Raspberry Pi LAN and USB ports and for the shutdown switch (photo 4). There is engraving around the cutout to help make sure the switch is aligned properly (photo 5).
- Side with cutouts for the USB power power cables (photo 6).
- Two sides for the long side of the case (photo 7).
Next, the laser cutter was used to cut a panel out of 1/8" 40-60% transparent sign lighting white acrylic. This part will be mounted on the top panel and is used to diffuse the light from blue LEDs.
The laser cutter settings used for cutting the acrylic were:
- Vector: Speed 10 Power 90 Frequency: 2500
The cut acrylic part is shown in photo 8 (with the protective paper on) and photo 9 (with the paper removed).
The laser cutting design files are in the ZIP file attached to this step. The file contains CorelDraw (.cdr) and Encasulated PostScript (.eps) files for the designs.
Step 3: Assemble the Case
Gather all of the wood parts for the case and align them as shown in the photo 1. Make sure to align the two side pieces with the cutouts as shown in photos 2 and 3. If these are not aligned as shown, the cutouts will not properly match with the electronics inside the case.
Using a small brush, put wood glue on the edges of the side parts and clamp them together as shown in photos 4 and 5. Clamp just enough to the hold the pieces together but don't make it super tight or it will be difficult to fit the top and bottom panels on.
Gently, flip over the case and put glue on the edges of the bottom panel and push it into place as shown in photo 6. Place some heavy objects on the corners as shown in photo 7 and allow the case to dry over night.
The glued the case is shown in photo 8.
Step 4: Paint the Top of the Case
Paint the faceplate and top panel as follows:
- Use black spray paint to paint the faceplate as shown in photos 1 and 2.
- Using the lines engraved on the top panel as a guide (photo 3), mask off all but the center part with painter's tape (photo 4).
- Spray paint the exposed area with white (photo 5).
- Allow the paint to dry then remove the tape (photo 6). If you want to have the rest of the case be the natural wood color, skip the rest of the steps.
- Mask the part of the top panel where the faceplate will be mounted (photo 7).
- Place the faceplate on top (photo 8) and align it with the mounting holes. Make sure that none of the tape is visible around the edges and then remove the faceplate and set it aside.
- Spray paint the exposed part of the top panel making sure to paint the edges as well as the top surface.
The finished panel is shown in photo 9.
Step 5: Assemble the Top Panel
Assemble the top panel as follows:
- Using the 1/2" #4-40 machine screws and nuts (photo 3), put the machine screws in the each of the corners of the face plate (photo 1) and put the acrylic panel on the back as shown in photo 2.
- Tighten the nuts to hold everything in place.
- Use the machine screws and nuts to hold the eyes in place (photo 4).
Step 6: Paint the Case
Paint the rest of the case to match the top panel per the instructions below. If you are making a case with the natural wood color, skip this step.
- Using painter's tape, mask the inside of the case as shown in photos 1 and 2. Make sure all the mounting holes in the bottom are covered and the tape is tight against the holes (photo 3): this will ensure that paint doesn't get inside the case. Also make sure the tape is firmly pressed against the cutouts on the sides and the tape goes up to the top of the tapes on the top edge (photos 4 and 5).
- Spray paint the bottom and the sides of the case.
- After the paint has fully dried, flip over the case and spray paint the top edges (photos 6 and 7).
- Allow the paint to fully dry and then remove the painter's tape.
The painted case will look like photos 8 and 9.
Step 7: Build the LED Circuit Board
The LED circuit board sits under the faceplate acrylic panel and illuminates when the Raspberry Pi WiFi is up and running. Assemble it as follows:
- Using the diagram as a guide, solder all the components to the circuit board. Solder the parts in this order: (1) wires, (2) resistors, (3) optoisolator, (4) LEDs, and (5) the USB connector. Make sure to solder the optoisolator exactly as shown with the pin numbers in the diagram (there will be a small dot on the chip by pin 1). Also make sure to solder the LEDs with the correct polarity as shown by the "+" in the LEDs in the diagram. The longer wire coming out of the LED is the positive (+) wire. After soldering all the components, trim the wires on the bottom of the circuit board. The finished circuit board is shown in photo 1.
- Solder the male ends of two of the 12" male/female jumper wires to the circuit board as shown in photo 2. Trim the wires on the bottom of the circuit board. The fully wired board is shown in photo 3.
- The USB connector is held in place by four solder connections and needs additional support to ensure it doesn't break off if the cable gets pulled. Reinforce the connector by cutting and stripping two small pieces of wire as shown in photo 4. Put the wires around the USB connector and solder in place as shown in photos 5 to 9. Trim the ends of the wires on the bottom of the circuit board. Make sure the wires are placed parallel as shown in figure 8. If the wires are placed this way, the will not have any effect on the electronics.
The fully completed LED board is shown in photo 10.
Step 8: Prepare the Switch
Using the following parts: push button switch (photo 1), jumper wires (photo 2), 470 ohm resistor (photo 3), and heat shrink tubing (photo 4), prepare the switch:
- Cut four lengths of heat shrink tubing as shown in photo 5.
- Cut off the male ends of the jumper wires (photo 6).
- Strip the ends off the wires (photo 7).
- Slide the heat shrink tubing onto the wires (photo 8).
- Using photo 9 as a guide to the terminals on the switch, solder the resistor to the positive (+) terminal (photo 10).
- Attach and solder the red wire to the resistor (photos 11 and 12). Cutoff the excess wire on the resistor.
- Attach and solder the black wire to the negative (-) terminal (photos 13 and 14) using photo 9 as a guide.
- Attach and solder the blue wires to the remaining terminals (photo 15).
- Slide the heat shrink tubing over the resistor and over the exposed wires soldered to the terminals (photo 16).
- Use a heat gun, lighter, or match to shrink the tubing.
The completed switch is shown in photo 17.
Step 9: Mount the LED Circuit Board Inside the Case
In this step, the LED circuit board will be mounted inside the case (photo 1) using the 3/8" #4-40 machine screws, nuts, and 1/8" #4 nylon spacers (photo 2).
- Insert two machine screws from the bottom of the case into the mounting holes for the LED circuit board as shown in photo 3.
- Slide the nylon spacers onto the screws (photo 4).
- Place the LED circuit board onto the screws (photo 5).
- Secure the LED circuit board using the nuts (photo 6). Gently tighten the nuts: they should be monkey tight not gorilla tight.
Step 10: Prepare the Raspberry Pi
The first step in preparing the Raspberry Pi is to install and configure the Raspbian software.
- Load Raspbian onto the SDcard. Instructions for how to do this can be found here.
- Insert the SD card into the slot on the Raspberry Pi.
- Connect the Raspberry Pi to a display, keyboard, mouse, LAN with access to the internet, and to a 5 volt USB power adapter as shown in the "Raspberry Pi Setup" diagram.
- Boot the Raspberry Pi and perform first time configuration according to the instructions here. When configuring Raspbian, do not configure the graphical user interface to start automatically. It is a good idea to change the password for the Raspberry Pi at this time.
The second step is to install and configure the PirateBox software. Boot the Raspberry Pi and log in. Issue the following commands (note that in the list of commands below, the wget command may get split across two lines because of the formatting of this instructable in your browser - the command needs to be entered on a single line: wget and the whole URL in quotes).
sudo apt-get update sudo apt-get -y install lighttpd sudo /etc/init.d/lighttpd stop sudo update-rc.d lighttpd remove sudo apt-get -y install dnsmasq sudo /etc/init.d/dnsmasq stop sudo update-rc.d dnsmasq remove sudo apt-get -y install hostapd sudo /etc/init.d/hostapd stop sudo update-rc.d hostapd remove sudo apt-get -y install iw wget "https://s3-us-west-1.amazonaws.com/talk2bruce/instructables/piratebox/piratebox-ws_current.tar.gz" tar xzf piratebox-ws_current.tar.gz cd piratebox sudo mkdir -p /opt sudo cp -rv piratebox /opt sudo ln -s /opt/piratebox/init.d/piratebox /etc/init.d/piratebox sudo update-rc.d piratebox defaults sudo /etc/init.d/piratebox start
There will be an error message after the last command that indicates that the network interface could not be started: this error occurs because the the WiFi USB adapter is not plugged in. This error is OK at this point - it will not adversely effect the PirateBox. It will work correctly when the Raspberry Pi is rebooted with the WiFi adapter plugged in.
The third step is to install the Python program that will illuminate the LEDs when the WiFi is up and running and to install the Python program that will shutdown the Raspberry Pi when the push button is pressed.
Create the directory where the Python programs will reside by issuing the following commands at the command prompt:
cd /home/pi mkdir python_programs cd python_programs
Issue the following two commands to get the Python programs:
wget "https://s3-us-west-1.amazonaws.com/talk2bruce/instructables/piratebox/rpi_halt_btn.py" wget "https://s3-us-west-1.amazonaws.com/talk2bruce/instructables/piratebox/illuminate_leds.py"
Using a text editor, edit the "/etc/rc.local" file and add the line below to the bottom of the file before the line with "exit 0". Since "/etc/rc.local" is a system file you will need to use the sudo command when you start your editor - for example "sudo nano /etc/rc.local". The line of code you are adding will automatically start the Python program that monitors the shutdown button. Make sure to put the ampersand ("&") at the end of the line.
Lastly, use sudo and a text editor to edit "/etc/network/interfaces" to make the contents look like exactly like this:
auto lo iface lo inet loopback iface eth0 inet dhcp #allow-hotplug wlan0 iface wlan0 inet manual #wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf #iface default inet dhcp post-up python /home/pi/python_programs/illuminate_leds.py
The last line runs the Python program that illuminates the blue LEDs when the WiFi is up and running.
The Raspberry Pi is now setup!
Shutdown the Raspberry Pi using the command
and disconnect all of the cables from the Raspberry Pi.
Step 11: Mount the Raspberry Pi Inside the Case
In this step, the Raspberry Pi will be mounted inside the case (photo 1) using the 1 1/4" #4-40 machine screws, nuts, and the 1/4" #4 or #6 nylon spacers (photo 2).
- Insert the two machine screws from the bottom of the case into the mounting holes for the Raspberry Pi as shown in photo 3.
- Slide three nylon spacers onto each screw (photo 4).
- Place the Raspberry Pi onto the screws and secure it using the nuts (photo 5). Gently tighten the nuts: they should be monkey tight not gorilla tight.
Step 12: Install the USB Power Cables
As shown in photo 1:
- Insert the USB cables through the side cutout.
- Attach the USB cables to the Raspberry Pi and LED circuit board.
- Use the 3/8" #6-32 machine screws, nylon cable clamps, and nuts (photo 2) to secure the USB cables to the case. This will reduce strain on the USB connectors on the LED board and Raspberry Pi and prevent the cables from being accidentally pulled out.
Use a cable tie (photo 3) to secure the cables outside the case (photos 4 and 5).
Step 13: Attach the Rubber Feet to the Case
Flip the case over (photo 1). Using the corner holes as a guide, adhere the rubber feet (photo 2) to the bottom of the case as shown in photos 3 and 4.
Step 14: Install the Shutdown Switch
Unscrew the collar from the push button switch. Insert the wires and switch through the cutout on the side of the case. Slide the collar over the wires and screw it onto the switch to secure the switch to the case. The engraving on the case can be used as a guide to make sure the switch is straight. The installed switch is shown in photo 1.
Step 15: Wire the GPIO Pins
In this step, the LED circuit board and the shutdown switch will be connected to the GPIO pins on the Raspberry Pi that control their function. Locate the GPIO connectors in photo 2.
- Using the "Wiring the PirateBox - Step 1" diagram as a guide, connect the wires from the LED circuit board to the GPIO pins (photo 3). A Python program running on the Raspberry Pi will use these GPIO pins to illuminate the LEDs when the WiFi is up and running. Use a nylon cable clamp and a 3/8" #6-32 machine screw and nut to hold the LED wires to the board (photo 4).
- Using the "Wiring the PirateBox - Step 2" diagram as a guide, connect the red and black wires from the switch to the GPIO pins (photo 5). These wires will provide power to the LED in the push button switch. The LED illuminates when the Raspberry Pi is powered on.
- Using the "Wiring the PirateBox - Step 3" diagram as a guide, connect the blue wires from the switch to the GPIO pins (photo 6). These GPIO pins will be monitored by a Python program in the Raspberry Pi: when the button is pressed, the program will issue a "halt" command to shutdown the Raspberry Pi.
The wiring is now complete!
Step 16: Assemble the WiFi Antenna
Attach the antenna to the USB WiFi adapter as shown in the photos.
Step 17: Test the PirateBox
All of the assembly is complete and it's now time to test the PirateBox.
- Insert the USB WiFi adapter into one of the USB ports on the Raspberry Pi (photo 1). It doesn't matter which port is used - either USB port will work.
- Plug both of the USB cables into the USB power adapters and plug the adapters into a outlet strip or into wall outlets. The shutdown switch should illuminate (photo 2).
- Wait a few minutes and the LEDs should illuminate (photo 3). This indicates that the WiFi is up and running on the Raspberry Pi. Wait an additional minute or so to be sure the PirateBox software is up and running and then connect to the PirateBox software using a laptop or tablet as follows:
- Go into wireless settings on the laptop or tablet and connect to the SSID named "PirateBox - Share Freely".
- When connected, open a web browser and go to "http://192.168.77.1". You should see a page that looks the screenshot.
Testing is now complete!
If things are not working properly, first check to make your power adapters are properly plugged in to the outlet strip or wall sockets. Some outlet strips have power switches - make sure the outlet strip is on. Next check the GPIO wiring. The next thing to check would be the Raspberry Pi software - you can hook the Raspberry Pi to a monitor and keyboard to make sure it's booting properly - if not, the easiest thing to do is reinstall Raspbian and the rest of the software. If everything is working except for the LED circuit board, then check the wiring on the board.
Step 18: Viola! the Raspberry Pi PirateBox Is Complete!
Put the top on the case (photo 1) and Viola! The Raspberry Pi PirateBox is now complete!
- When the Raspberry Pi and LED circuit board are powered up, the power switch will illuminate (photo 2).
- When the WiFi is up and running the LEDs will illuminate and make the arcs above the skull glow (photos 3, 4, and 5). Wait a minute or two and then the PirateBox will be ready for users to connect.
- When finished using the PirateBox, press the glowing switch: this will cause the Raspberry Pi to shutdown.
- When the arcs above the skull stop glowing, it's safe to unplug the power to the Raspberry Pi and LED circuit board.
Step 19: PirateBox Skins
The PirateBox can be made with a variety of skins. Photos 1 and 2 show the case with the natural unpainted wood. Photos 3 and 4 use a yellow color scheme. Photos 5 and 6 use a metallic silver spray paint: when metallic silver paint is combined with the natural texture of the wood, the case looks like it's made of brushed aluminum. Photos 7, 8, and 9 show a blue color scheme with a black skull and a 16mm metal push button with blue LED ring (Adafruit ID 481).
The possibilities are endless!
Step 20: How the Python Programs Work
There are two custom Python programs used in this instructable to create the Raspberry Pi PirateBox.
The first program "rpi_halt_btn.py" is started during the boot process by the command
in the "rc.local" system file. The "&" at the end of the command makes the program run as a separate process that keeps running until the program exits.
1 import RPi.GPIO as GPIO 2 import os 3 GPIO.setmode(GPIO.BCM) 4 GPIO.setup(25, GPIO.IN, pull_up_down=GPIO.PUD_UP) 5 print "\nrpi_halt_btn: started and now waiting for GPIO halt button to be pressed." 6 try: 7 GPIO.wait_for_edge(25, GPIO.FALLING) 8 except KeyboardInterrupt: 9 GPIO.cleanup() 10 GPIO.cleanup() 11 os.system("halt")
The function of each line is as follows:
- Line 1 imports the library that allows a Python program to use the Raspberry Pi's GPIO pins.
- Line 2 imports the library that allows a Python program to issue system commands.
- Line 3 tells the subsequent GPIO functions the definition of the GPIO pin numbers that the program will use.
- Line 4 sets GPIO pin 25 to be an input pin and to enable a pull up resistor for that pin.
- Line 5 prints a message on the console indicating that the program is running. If you have a monitor hooked up to the Raspberry Pi during boot, you'll see this message on the console screen.
- Lines 6 and 7 make the program wait until the button is pressed before proceeding to line 10.
- Lines 8 and 9 make the program stop if the user hits Ctrl/C - these lines are for debugging purposes.
- Line 10 is run after the button connected to GPIO pin 25 is pressed. This line of code terminates all GPIO processing.
- Line 11 uses the system library to issue the Raspbian "halt" command. The "halt" command shuts the system down.
The second program "illuminate_leds.py" is run by the command
post-up python /home/pi/python_programs/illuminate_leds.py
in the system file "/etc/network/interfaces". The "post-up" command is run when the network interfaces are up and running. In this case, it's when the WiFi is up and running.
1 import RPi.GPIO as GPIO 2 GPIO.setmode(GPIO.BCM) 3 GPIO.setup(23, GPIO.OUT)
The function of each line is as follows:
- Line 1 imports the library that allows a Python program to use the Raspberry Pi's GPIO pins.
- Line 2 tells the subsequent GPIO functions the definition of the GPIO pin numbers that the program will use.
- Line 3 sets GPIO pin 23 to an output and sets the value to low causing the LED board to illuminate the LEDs.
Step 21: Errata and Notes
In Step 3 photo 1 and the photos in steps 6 and 9, the engraving for the cable clamps in the photos is incorrect. The labels "RPi" and "LED" are reversed. The correct correct labeling are shown in photos 1 and 2 on this step and the incorrect in photo 3. The design files for laser cutting attached to step 2 are correct.
Incorrect looking photo
In photo 6 of step 4, the painted area is slightly different than the rest of the photos for the step. I missed taking a photo of that part and used a part for an another PirateBox I constructed where I taped it slightly differently.
After I started to document this instructable, the developer of the PirateBox software changed his implementation for the Raspberry Pi to no longer use Raspbian but to use ArchLinux. The ArchLinux implementation is incompatible with the instructions and software I developed for the shutdown switch and the LED circuit board. To make sure that the Raspbian software known to work with these instructions remains available for this instructable, I preserved a copy of PirateBox software and that's what's downloaded in step 10 with the command:
For reference, the original file can be downloaded with the command:
The official PirateBox website can be found here: http://piratebox.cc/