Thursday 25 February 2016

Build a Raspberry Pi Glove – Part 1

The Pi Glove is our project name for a wearable, social media-controlling glove – we’re going to show you how to build it this month and how to program it next month. With the advent of Google Glass, Android and Apple smartwatches and various other disruptive technologies, the devices we’re beginning to use today point towards a future where we may well one day wear all of the gadgets that enable us to communicate with each other (before they are simply embedded into our bodies…). The more natural or ergonomic this medium becomes, the more likely we are to use it, so we’re going to use a Raspberry Pi to create a powerful yet comfortable glove. Part one of this two-part tutorial covers the hardware setup so that you can make your own version of the Pi Glove. Part two will cover the software to control music, a camera and social media using your glove’s buttons.

1. Strip and prepare the wires

Take the female-to-female jerky wires, select one end and remove the plastic coating; this can be done by applying a little pressure on the plastic cover – you can use your teeth but it’s better to use a set of pliers! The end will now consist of a small metal spike. Prepare the other wires using the same method.

2. Attach the wires to the poppers

The next part is a little fiddly, so take your time as you work through each of the wires. First, you need to connect the wire to the popper whilst pinning the other end through the finger of the glove. Once through, close the two sides of the popper together, ensuring that the wire is secured in-between. This is easier if you turn each glove finger inside-out and then push the popper through. The key part of this step is to ensure that the wire stays connected.

3. Check the wires are in place

One wire/popper combo is attached to each of the four fingers and the thumb of the glove. The thumb forms the earth, or ground, of the connection when it comes into contact with one of the other metal finger poppers.

Build a Raspberry Pi Glove – Part 1

4. Add the Pi camera

The Pi camera is mounted into the glove, which enables you to angle your wrist and take a picture in the direction that the hand is facing. Make a small hole in the top of the glove, big enough for the camera lens to push through. On the Pi camera board you will find four small holes, so use these and the tiny cable ties to secure the camera onto the fabric of the glove.

5. Attach the Pi camera cable

Flip the glove inside-out so you can access the back of the camera. Take the camera connection wire, with the blue side facing away from the camera, and attach the wire to the back of the camera. On the Raspberry Pi, slide up the black camera holder piece and secure the wire into place. You may wish to thread the wire through the side of the glove to conceal it.

6. Checkpoint

At this stage you have the five poppers attached individually to a wire and through each of the individual fingers, and also attached to the thumb. Each of these wires runs through the inside or outside of the glove to the Raspberry Pi. The Pi camera is also attached to the glove, with the lens exposed to enable pictures to be taken.

7. Mount the Raspberry Pi

You can mount the Raspberry Pi onto the top of the glove using the small cable ties and the four holes located on each corner of the Pi – this makes the overall glove more portable. Take your Pi and orientate it so that the SD card slot is facing away from your wrist. Thread the cable ties through the holes and through the glove, securing the Pi in place. Be careful not to over-tighten the cable ties.

8. Attach the wires to the GPIO pins

Now that all the hardware is attached to the glove, the next step is to connect the finger and thumb wires to the GPIO pins on the Raspberry Pi. The pin numbers we use here identify the physical pin number on the board. Take the thumb wire and connect it to physical pin number 39 – this is the ground contact for the other buttons. Now take the index finger wire and connect to physical pin number 7.

Build a Raspberry Pi Glove – Part 1

9. Connect more wires to the GPIO pins

Using the same method as described in Step 8, take the middle finger wire and connect it to pin number 11, the ring finger to pin 21 and finally the little finger wire to pin 12 – again, these numbers are the physical pin numbers on the board.

10. Boot up the Pi

The first time you boot up your Raspberry Pi you will need to set up your Wi-Fi connection. Connect the Pi to your HDMI monitor and insert the Wi-Fi dongle. If you are using the newer A+ model, which only has a single USB, you may require a USB hub to enable you to add a keyboard and mouse. You could always set up the Wi-Fi on a B+ model, which offers more ports, then transfer the card to the A+. Add the USB mouse, keyboard and power supply. Boot the Pi up. 

11. Add Wi-Fi app 

Open up the Wi-Fi Configuration tool from Menu>
Preferences. When open, select Manage Networks and then Scan – this will find and list all of the available Wi-Fi networks in your area. Select your network from the list and double-click. You will then be prompted to enter your WEP code, so enter this in the PSK text box and press Save. Return to the Current Status page and click Connect. This will connect your Pi Glove to the Wi-Fi.

12. Set up Wi-Fi in the command line, part one

If you are using SSH to access your Pi, you can set up your Wi-Fi dongle from the command line. In the terminal window, type: sudo iwlist wlan0 scan. This will scan for available Wi-Fi networks. Look out for: ESSID:“test-network” – this is the name of the Wi-Fi network.

‘IE: IEEE 802.11i/WPA2 Version 1’ is the authentication that is used; in this case it is WPA2, the newer and more secure wireless standard which replaces WPA1.

You will also need your password for your Wi-Fi network – for most home routers, this is located on a sticker on the back of the router. The ESSID (ssid) for the network in this case is ‘test-network’ and the password (psk) is ‘testingPassword’.

Build a Raspberry Pi Glove – Part 1

13. Set up Wi-Fi in the command line, part two

Now add your Wi-Fi settings to the wpa-supplicant.conf configuration file. In the terminal window, type:

  sudo nano etc/wpa_supplicant/wpa_supplicant.conf

Scroll to the bottom of the file and add the following lines:

  network={

      ssid=“The_ESSID_from_earlier”

      psk=“Your_wifi_password”

  }

Using the example network found in Step 12, you type ssid=“test-network” and psk=“testingPassword”. Now save the file by pressing Ctrl+X then Y, then press Enter.

14. Set up Wi-Fi in the command line, part three

On saving the file, wpa-supplicant will normally notice that a change has occurred and so it will try to make a  connection to the network. If it doesn’t do this, you can either manually restart the interface – just run sudo ifdown wlan0 followed by sudo ifup wlan0 – or instead reboot your Raspberry Pi with sudo reboot.

To test that the Pi is successfully connected to your Wi-Fi, type ifconfig wlan0. If the ‘inet addr’ field has an address beside it, the Pi has connected to the network. If not, check that your password and ESSID are correct.

Build a Raspberry Pi Glove – Part 1

15. Disable the Wi-Fi power management

If left idle, the Wi-Fi power management system on the Raspberry Pi may drop the Wi-Fi connection – this may, for example, occur if the glove is out of range of the router. To disable the power management, load the terminal window and type:

  sudo /etc/network/interfaces

At the end of the block of code, add the following line:

  wireless-power off

This will ensure that the Wi-Fi stays connected whilst in range.

16. A simple test program

Now you have completed the hardware section of the Pi Glove, you can use a simple program to test the connections and make sure that all of the poppers are working correctly and responding to the thumb and finger contacts. Download the test program from FileSilo.co.uk. Run sudo idle in a terminal to open the Python editor, then start a new file and insert the code. With your Pi Glove attached, save and run the program.

17. Run the code

The test program will respond to each connection of the fingers and the thumb, and display a message stating that the respective button has been pressed – like so: ‘button one has been pressed’, ‘button two has been pressed’, etc. If this fails, check for the following errors: 1) incorrect wiring on the GPIO pins, 2) loose wires not in contact with the poppers, and 3) thumb and finger not in contact. Part two will cover how to develop a program that brings control to your fingertips.   



from Linux User & Developer – the Linux and FOSS mag for a GNU generation http://ift.tt/1LeJLKf
via IFTTT

No comments:

Post a Comment

Amazon

Donate

Donate Towards More Raspberry PI's for Projects