PlugPi

WARNING: This project deals with hacking on mains AC power. Please proceed carefully.

I’ve wanted an inconspicuous wall wart style raspberry pi case / enclosure for the longest time, but there aren’t many options out there. I’ve seen the PiPlug developed by the dude that runs n-o-d-e.net, but it wasn’t quite what I was looking for. After some research; though, I think I’ve hit on the just the right ingredients to easily build out very sleek and inconspicuous cases.

These are links to the components I landed on.

CASE:
https://www.polycase.com/pm2314

USB CHARGERS:
https://www.amazon.com/gp/product/B076C6PW2V

16 AWG STRANDED WIRE:
https://www.amazon.com/gp/product/B0746HRVZP

ASSORTED HEAT SHRINK:
https://www.amazon.com/gp/product/B0771K1Z7Q

30mm HEAT SHRINK TUBING:
https://www.amazon.com/gp/product/B00MJVQP5C

REVERSIBLE RIGHT ANGLE USB CABLES:
https://www.amazon.com/gp/product/B07CBTVR8G

Here is one of the USB power supplies ripped apart next to an intact one. These things seem to be the best way to get cheap clean power in a small form factor. There are some other appealing options like the RAC05-05SK that are a bit cleaner and probably safer than cannibalizing a USB charger, but at 3x the price I decided I’d go this route.

As you can see the Raspberry Pi and this power adapter board sit nicely in this little project enclosure.

Soldering to the power adapter is quite easy. The pads for the mains AC were large, and soldering the cannibalized USB cable to the USB pads was easy enough. I secured all of these wires with hot glue as well.

Soldering to the poles inside the Polycase enclosure was tricky. I ruined the first one because I was hanging the soldering iron on the pole for too long and it melted the case causing it to become very unstable.

I then ripped off the little ground tab and hot glued the power adapter straight into the bottom of the enclosure. I would have used the 30mm heat shrink tubing to entirely wrap the power adapter entirely prior to securing it to the enclosure if I had actually thought about the size it for two second before impulsively hitting buy on Amazon and getting tubing that was 2x too large. I’ll have it for the next iterations of this project though.

Here I just used some duct tape to keep the power adapter seperated from the Raspberry Pi. The 30mm heat shrink tubing will replace this mess in the future.

And here you can see that the USB cable can simply plug into the Pi’s power port. The Pi has to sit in the enclosure at a slight angle, but it does sit in there will, and even with just a bit of wiggle room.

Finally here it is all buttoned up. Kind of boring, perfect.

Prior to enclosing everything it would probably be wise to configure the Pi for remote access as all the ports are occluded with this enclosure. This is my standard headless config that I use for a base on nearly all my headless Pi based projects.

-1: Flash Raspbian to SD card and sync
sudo dd if=~/Downloads/Raspbian_Image.img of=/dev/sdb bs=1M progress=status && sudo sync && sudo syn

-2: Remove and re-plug SD card if new partitions are not visible.

-3: Mount SD card.
sudo mkdir /mnt/piboot
sudo mkdir /mnt/piroot
sudo mount /dev/sdb1 /mnt/piboot
sudo mount /dev/sdb2 /mnt/piroot

-4: Enable SSH on boot.
sudo touch /mnt/piboot/ssh

-5: Set up interfaces file to enable WiFi roaming.
vim /mnt/piroot/etc/network/interfaces
””’
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and ‘man dhcpcd.conf’

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface WlanNetwork01 inet dhcp
iface WlanNetwork02 inet dhcp
iface WlanNetwork03 inet dhcp
””’

-6: Set up WiFi APs with priorities.
vim /mnt/piroot/etc/wpa_supplicant/wpa_supplicant.conf
””’
# proto should be: RSN (for WPA2) and WPA (for WPA1)
# key_mgmt should be: WPA-PSK or WPA-EAP (Pre-Shared or Enterprise)
# pairwise should be CCMP or TKIP (for WPA2 or WPA1)
# auth_alg should be OPEN for WPA1/WPA2 (less commonly used are SHARED and LEAP)

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid=”FBISurveilanceVan”
psk=”CorrectHorseBatteryStaple”
id_str=”WlanNetwork01″
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
priority=2
}

ssid=”BackupFBISurveilanceVan”
psk=”SuperSecretPassword”
id_str=”WlanNetwork02″
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
priority=1
}

ssid=”CoffeeHouseWiFi”
psk=”PassIsProbablyEspresso”
id_str=”WlanNetwork03″
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}
””’

-7: Create Re-Roam script to connect to preferred APs if they become available.
vim /mnt/piroot/etc/ReRoamWiFi.sh
””’
#!/bin/bash

CurrentNetwork=$(iwconfig 2>&1 | grep ESSID | cut -f2 -d”\””);
PriorityNets=”FBISurveilanceVan|BackupFBISurveilanceVan”

if (( $(echo $CurrentNetwork | egrep -c “$PriorityNets”) == 0 )); then
if (( $(iw wlan0 scan | egrep -c “$PriorityNets”) == 1 )); then
service networking restart;
fi
fi
””

-8: Set up crontab to run the Re-Roam script every minute.
vim /mnt/piroot/etc/crontab
””’
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

m h dom mon dow user command
0 * * * * root run-parts /etc/cron.hourly
10 0 * * * root run-parts /etc/cron.daily
20 0 * * 1 root run-parts /etc/cron.weekly
30 0 1 * * root run-parts /etc/cron.monthly
* * * * root /home/pi/ReRoamWiFi.sh
””’

-9: Unmount SD card.
sudo umount /mnt/piboot
sudo umount /mnt/piroo

-10: Plug SD card into Pi, power it on, SSH to it, and continue configuration as desired.

I’m working on a 3d printable chassis for all this as well to keep things cleaner, easier, and a bit safer. Its nowhere near done yet, but here are the files in case anyone better with CAD than I wants to take a crack at working on it.

Leave a Reply

Your email address will not be published. Required fields are marked *