PiGlass is a DIY wearable computer!

PiGlass can be used to take HD pictures and videos, those files get automatically uploaded to Dropbox via a Wi-Fi connection.. You can stream music from your phone to PiGlass with Bluetooth as well as stream YouTube audio with mps-youtube. A bone conduction transducer can be added to be used instead of headphones. YouTube videos can be streamed to PiGlass using the RaspiCast app for Android, the camera on PiGlass can be livestreamed to YouTube.

You can control PiGlass, once assembled, via your phone via SSH over Wi-Fi.

Parts:

1 x Pi Zero Spy Cam
Mini 5 megapixel camera
1 x Pi Zero W
Raspberry Pi Zero Wireless
1 x Phat Dac
digital audio phat
1 x Bluetooth Dongle
Bluetooth adapter
1 x OTG Adapter
for attaching bluetooth dongle
1 x USB Battery Pack 5V/2A
USB battery pack
1 x Short Mini to Micro HDMI
Short cable for display
1 x Safety Goggles
Pyramex Highlander Safety Eyewear
1 x Glue Dots
Adhesive to mount camera
1 x VuFine+
Wearable Display
5 x Zip Ties 4 inch
To hold it all together

Tools:

  • Soldering Iron
  • Solder
  • Ruler
  • Scissors or Wire Cutters (to cut zip ties)

Step 1: Modify your header pins with a ruler, put the edge of the ruler on the black part and push down until you get close to one side, you will need two rows of 16 pins and 2 rows of 4 pins.

Step 2: Put your header pins in the female header from the phat dac parts.

Step 2.5: For forward compatibility with a bone conduction transducer guide, solder 2 regular pins onto the phat dac.

Step 3: Solder your modified pins onto the raspberry pi zero w. The part you are soldering is outlined in red below.

Step 4: When you are done soldering, take the female header off the pins of the pi and put the phat dac on and slide it down as far as you can then solder all the pins of the phat dac. I used blue zip ties to hold the boards together at this point.

camera_step4.jpg
This is what it will look like after you solder the phat dac on

Step 5: Attach the bluetooth adapter using the mini OTG USB adapter and attach the camera.

Step 6: Attach the PiGlass to the VuFine+ using small zip ties, making sure to go through both boards and around the Vufine+.

Step 8: Extend the VuFine screen as far as it will go, then place the gluedot on the center of the back of the screen then place the camera on the gluedot.

Step 9: Attach the short mini hdmi to micro HDMI cable from the Pi Zero to the VuFine+ and zip tie it.

All done with the assembly!

If you have not used a Raspberry Pi or a Pi Zero in a project, you may want to review the following Guides to get your Pi set up and loaded with the latest version of the Raspbian operating system:

Once you have your Pi Zero W set up and working with a display and keyboard, you will want to follow the steps below.

Step 1: Update the Pi software, install the opencv software package and download the picture/video program.

Download: file
sudo apt-get update

sudo apt-get install python-opencv python-picamera

git clone https://github.com/matt-desmarais/piglass.git

Step 2: Enable the camera and SSH remote access.

Download: file
sudo raspi-config

Go to interfacing options in the raspi-config program and turn the camera on. Also enable SSH access in the configuration program. SSH is remote log in to the Pi from another computer or your phone, this will be used later on.

Reboot the Pi or shutdown and restart.

Step 3: Setup Dropbox Integration

https://github.com/andreafabrizi/Dropbox-Uploader

Download: file
git clone https://github.com/andreafabrizi/Dropbox-Uploader.git

cd Dropbox-Uploader

chmod +x dropbox_uploader.sh

sudo ./dropbox_uploader.sh

At this point you will be asked for an access token - here is what you do:

  1. Go to: https://www.dropbox.com/developers/apps
  2. Create App and give it a name.
  3. Go to App setting and scroll down to the OAuth 2 section
  4. Look for generated access token. Click generate.
  5. Copy and paste your access token into the uploader script

Now PiGlass will be able to upload to dropbox!

Step 4: Install software support for the phat dac

https://learn.pimoroni.com/tutorial/phat/raspberry-pi-phat-dac-install

Download: file
curl https://get.pimoroni.com/phatdac | bash

Step 5: Install the Bluetooth adapter and setup streaming

First disable the internal Bluetooth of the Pi

Download: file
sudo nano /boot/config.txt

add the line

dtoverlay=pi3-disable-bt

Setup bluetooth streaming

Reboot then attach your bluetooth dongle to the mini OTG USB adapter

https://github.com/lukasjapan/bt-speaker

Download: file
sudo -i

bash <(curl -s https://raw.githubusercontent.com/lukasjapan/bt-speaker/master/install.sh)

Pair your phone to PiGlass using Bluetooth Manager (GUI) or bluetoothctl (terminal)

Test your setup by pairing your phone and playing music, the music should play from the headphones on the phat dac

Optional: Increase size of mouse for the lxde graphical user environment if you want to use a bluetooth keyboard

Download: file
sudo apt-get install chameleon-cursor-theme

sudo update-alternatives --config x-cursor-theme

select

/usr/share/icons/Chameleon-White-Large/cursor.theme

Pictures and Video Livestreaming

Here is how to take pictures and videos. Log into the Raspberry Pi Zero into PiGlass using SSH from your phone.

Download: file
cd piglass

sudo python PiGlassBeta.py

You will need an SSH client program on your phone or computer to remote access your Raspberry Pi Zero. I suggest you try JuiceSSH for Android.

You will need to know the Raspberry Pi Internet Protocol (IP) address to put in your SSH program to connect the two.

Here is a video of the setup process for JuiceSSH:

Once you have a connection, you can issue commands to the PiGlass.

Here are the keys which control PiGlassBeta.py:

Z: zoom in

X: zoom out

C: zoom in all the way/zoom out all the way

N: zoom to inital setting

P: take picture

V: start video/stop video

T: toggle text on/off

Q: quit

If you have the Dropbox app on your phone you can see pictures as soon as they are uploaded, below is a video taken with PiGlass

LiveStreaming to YouTube

Download and install ffmpeg 3.1.1

Download: file
wget https://github.com/ccrisan/motioneye/wiki/precompiled/ffmpeg_3.1.1-1_armhf.deb

dpkg -i ffmpeg_3.1.1-1_armhf.deb

Create script called stream.sh and copy the following code into it. Your YouTube key goes at the end where it says rtmp://a.rtmp.youtube.com/live2/YOUTUBE KEY GOES HERE

Download: file
raspivid -rot 270 -o - -t 0 -fps 30 -b 6000000 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/YOUR YOUTUBE KEY GOES HERE

How to get your key:

Go to https://www.youtube.com/live_dashboard

Scroll down to encoder setup and then go to Stream name/key and click reveal copy and paste the key into the script.

Run stream.sh and you should be livestreaming to youtube!

YouTube Streaming

RaspiCast Video Streaming

Download raspicast app on your phone

https://play.google.com/store/apps/details?id=at.huber.raspicast

Enter your SSH log in settings into the app

To cast YouTube videos to your Raspberry Pi just open the YouTube app and a video and choose "Share" → Raspicast.

The video will start playing on PiGlass!

MPS-YouTube audio streaming

Download: file
sudo apt-get install mpv

sudo pip3 install youtube-dl

git clone https://github.com/mps-youtube/mps-youtube.git

cd mps-youtube

sudo python3 setup.py install

Run mpsyt and then enter set player mpv

Congratulations you can now steam youtube audio!

For example, I typed in /sia then hit enter
A list of songs will come up, entering in the number of the song you want follow by enter will start the stream.

Picture and Screenshot Combo Capability

You need the following repo to make the code function
https://github.com/AndrewFromMelbourne/raspi2png

Download: file
git clone https://github.com/AndrewFromMelbourne/raspi2png.git

You need this Python library

Download: file
sudo apt-get install python-numpy

Now for the code you can get it with wget or copy and paste from below

Download: file
wget https://gist.githubusercontent.com/matt-desmarais/c56f43bd4aeb51c9a574100ac6b40941/raw/99e7475a6957083bad26fcbad9b2f2290e6c25f9/picinpic.py
Download: file
import cv2
import numpy
import subprocess
import time
import datetime

def get_file_name_pic():  # new
    return datetime.datetime.now().strftime("%Y-%m-%d_%H.%M.%S-combined.png")

subprocess.Popen("./raspi2png",  cwd='/home/pi/raspi2png')
subprocess.Popen(["raspistill", "-t", "500", "-rot", "270", "-o", "/home/pi/camera.jpg"], shell=False)

time.sleep(12)
# Load image and screenshot
img1 = cv2.imread('/home/pi/camera.jpg')
img2 = cv2.imread('/home/pi/raspi2png/snapshot.png')   
rows,cols,channels = img2.shape
#top-left corner pic in pic
img1[0:rows, 0:cols ] = img2
#save combined picture 
cv2.imwrite('/home/pi/test.png',img1)
#generate filename for dropbox file name
filename = get_file_name_pic()

photofile = "/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /home/pi/test.png /Apps/PiGlass/"+filename
#runs photofile dropbox upload
subprocess.Popen(photofile, shell=True)

When you run the program it will take a screenshot followed by a picture and combine the screenshot into the photo. Below is an example of a picture generated by the above code.

Adding a Bone Conduction Transducer

Additional Parts

100K resistors x 2
Jumper wires: female to female
Shrink wrap: 3/4 inch and 3/8 inch

1 x Amp board
Mono 2.5W Class D Audio Amplifier
1 x Bone Conduction Transducer
8 Ohm 1 Watt Bone Conduction Transducer

Wiring

Step 1: Solder the 5 pins onto amp

Step 2: Strip the black housing off of 3 jumper wires then pull off the female connectors. You will need to solder them onto the resistors.

camera_resistors.jpeg
The single ends go to the pins on the phat dac and the double end goes to A+ on the amp

Step 3: Now we are going to shrink wrap the bone conduction transducer to the frame of the glasses. Take the elastic end of the glasses off the side PiGlass is mounted to. Slide the 3/8 inch shrink wrap on the frame and then feed the wires through, the transducer should be on the inside of the frame. Now put about an inch and a half of the 3/4 inch shrink wrap around the bone conduction transducer. Make sure the transducer sits above your ear, essentially above your ear canal. When you find the right placement carefully use a heat gun or hair dryer to activate the shrink wrap. 

Step 4: Take the bone conduction transducer leads and solder them to the positive and negative speaker output.

Step 5: Attach a wire to 5v and ground on the phat dac, then attach the other sides to ground and vin on the amp. Next attach the resistors to the phat dac pins and A+ on the amp board, now you are good to go.

Tips for using PiGlass:

  • watch your power wire, don't get it caught on anything
  • Use JuiceSSH for Android to control PiGlass, you can open multiple sessions
  • The camera can only be used by one program at a time
  • Be mindful of the camera when adjusting the Vufine+

Future Features

Consider use of a linear soft potentiometer, to use as a touch/slide sensor, to control the camera program and music playback and mount to the side.

Consider a microphone for voice commands (as voice recognition software becomes better).

This guide was first published on May 17, 2018. It was last updated on May 17, 2018.