Part 4: Add some power, create the user interface and autostart at boot


Wire up the power, an LED, some buttons and a couple of RGB LEDs from an LED strip:

  1. Connect the speaker amplifier and AC-DC power converter according to the diagram shown below. Additionally, connect the Raspberry Pi and the WS2801 based LED strip to the +5VDC power supply as shown.
  2. Wiring Diagram

  3. Do not connect power to the micro USB connector, instead use a separate power supply. In my case I wasn’t able to boot up unless I used a 3A power supply. A 3A power supply may not be necessary, since I was running a full LED strip with 32 LEDs and a Raspberry Pi Model B. By using only two LED’s of a strip and a Raspberry Pi Model A you can probably use a smaller power supply with no problems. I used only 2 of the 32 available RGB LEDs. For my particular LED strip I cut off a section of the strip that’s 2 LEDs long. See the dotted cut lines on the LED strip shown in the Fritzing User Interface Schematic below. Additionally, you could use WS2801 Breakout boards(mentioned in the materials section) by connecting to SCLK/CKI and MOSI/SDI then daisy chaining CKO to the next WS2801 Breakout boards CKI and SDO to the next WS2801 Breakout boards SDI.
  4. Connect the Raspberry Pi as shown below in the Fritzing User Interface Schematic. (Click the image for a larger view.) The Raspberry Pi A and B rev 2.0 pinout is shown further below. Pin 1 is closest to the silk screened portion of the Raspberry Pi board that says ”Made in the UK”. Additionally, you will see a silkscreen P1 next to a notch that sticks out closest to pin 1. Lastly, the User Interface Schematic is shown for additional clarity with the various resistor values and pin labels that connect to the Raspberry Pi. **Note** Be sure to keep the 5V supply separate from the 3.3V supply. The 5V supply powers the board and the LEDs, while the 3.3V supply is provided by the Raspberry Pi and is used for all the pushbuttons and LEDs associated with the Raspberry Pi GPIOs.
  5. Fritzing User Interface Schematic

    Fritzing User Interface Schematic

    Button / LED PCB

    Button / LED PCB

    Raspberry Pi Pinout

    Raspberry Pi A and B rev 2.0 pinout (NOTE: this pinout is shown 180 deg off from the above schematic)

    AlertsTube-Schematic

    User Interface Schematic

  6. Once you are done, check you’re wiring to make sure you didn’t make any silly mistakes, or short anything out. Use plenty of electrical tape or heat shrink tubing as needed. Power up your Raspberry Pi, check for sparks or smoke, and make sure that all the electronic components are cool enough to touch without getting burned.
  7. Once everything seems to be working as expected, test out the GPIO functionality by typing:
    sudo ./RGB_test.py
    Take a look at the RGB LED strip. If it’s working properly then you should see a sequence of blinking LEDs. If it’s not working then go back and check your wiring.
  8. From there you can test out the GPIO functionality by typing:
    sudo ./GPIO_test.py
    You should be able to press buttons and see the state change on the screen, as well as the LED should toggle. If it’s not working then go back and check your wiring.
  9. If everything seems to be working then Connect one end of the 1/8 inch male stereo jack to the Raspberry Pi and the other end to your amplifier. Turn up the volume and type the following:
    cd AlertsTube then
    sudo ./AlertsTube.py
    If everything is working as desired then you should hear a beep whenever a button is pressed. One button is responsible for toggling visual alerts on and off, another is responsible for fetching todays weather and telling you if any weather alerts are currently in progress, and the last button plays tomorrows weather forecast.

Download the alertsboot script and run it at startup:

  1. Autostart the AlertsTube.py script by typing the following:
    cd /etc/init.d
    Then download the alertsboot script by typing:
    sudo wget https://dl.dropbox.com/u/8170542/alertsboot then
    sudo chmod 755 alertsboot
    You can test the script by typing:
    ./alertsboot start
    If you didn’t see any errors then you can proceed by typing:
    sudo update-rc.d alertsboot defaults to have the startup script run at boot time.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s