Raspberry Pi Rain Box
![PICT0121.JPG](/proxy/?url=https://content.instructables.com/FP4/DRUR/HPYORXUW/FP4DRURHPYORXUW.jpg&filename=PICT0121.JPG)
I find the sound of rain really soothing, and wanted a device to just play rain sounds for me. I figured the Raspberry Pi would be perfect for this. So I wrote a Python script that selects a random number, and, based on the number, selects a rain sound to play. After that, I stuck it in a hobby project box from Radioshack, wired with some old speakers and it was done! Soothing rain sounds for me! What's great about this setup is that the Raspberry Pi is still usable even though this script runs at start up, so you can have rain running while you work with your Pi if you'd rather not have it in a box. Also, this is a pretty cheap project, so its great for a weekend project that doesn't break the bank!
Note: Important points will be in bold!
Second Note: This Instructable will be divided into two parts, software and hardware, which will cover two separate aspects of the project.
Third Note: Please look at all pictures! Many contain important image notes, though the points mentioned are stated in the steps.
Here's a video of it working!
Note: Important points will be in bold!
Second Note: This Instructable will be divided into two parts, software and hardware, which will cover two separate aspects of the project.
Third Note: Please look at all pictures! Many contain important image notes, though the points mentioned are stated in the steps.
Here's a video of it working!
Tools and Materials
Tools:
- Drill w/ assorted drill bit sizes
- Wire Cutters
- Electrical Tape and/or Heat Shrink Tubing
- Soldering Iron/Solder
- Screwdriver
- Optional: Dremel with drill bits
- Large Flip Switch
- 5V Regulator (Radioshack)
- 7x5x3" Hobby Project Box (Radioshack)
- Computer Speakers (Any cheap/old ones will do, just make sure they have an amplifier inside and an audio)
- Wire
- Raspberry Pi
- Small Computer Fan (The one I used is rated at 5V)
- Micro USB Cable
Software - Part 1
![2014-01-06-001600_1824x984_scrot.png](/proxy/?url=https://content.instructables.com/FRK/DDUM/HQ1E0SFO/FRKDDUMHQ1E0SFO.png&filename=2014-01-06-001600_1824x984_scrot.png)
![2014-01-06-001744_1824x984_scrot.png](/proxy/?url=https://content.instructables.com/FZK/VSC7/HQ1E0SFQ/FZKVSC7HQ1E0SFQ.png&filename=2014-01-06-001744_1824x984_scrot.png)
So, to begin, download the Python script rain.py included on the intro page, and place it in the /home/pi directory. Pygame was used in this project, so IDLE needs to be used instead of IDLE 3, since Pygame, as of right now, only works on Python 2, but it should be unnecessary to note unless changes to the program are needed. We also need to download some rain music files. I downloaded some long free rain mp3 files from here:
https://archive.org/details/Sounds_of_Nature_Collection
After relabeling your mp3 files as Rain1, Rain2, and Rain3, place them in the /home/pi directory also. It may be necessary to expand the file system in order to make room for the mp3 files, which can be done by modifying settings in the config menu. Do this by typing raspi-config in the terminal. Extra if/else statements and rain mp3 files can be added for more variety, or any extra sounds you like!
https://archive.org/details/Sounds_of_Nature_Collection
After relabeling your mp3 files as Rain1, Rain2, and Rain3, place them in the /home/pi directory also. It may be necessary to expand the file system in order to make room for the mp3 files, which can be done by modifying settings in the config menu. Do this by typing raspi-config in the terminal. Extra if/else statements and rain mp3 files can be added for more variety, or any extra sounds you like!
Software - Part 2
![2014-01-06-002316_1824x984_scrot.png](/proxy/?url=https://content.instructables.com/F47/BRN4/HQ1E0SGF/F47BRN4HQ1E0SGF.png&filename=2014-01-06-002316_1824x984_scrot.png)
In order to have the music play at boot up, the file rc.local needs to be changed. Its located in the /etc folder. Type in sudo nano /etc/rc.local in order to modify it. Two lines of code need to be added. amixer set PCM -- 1000, and python /home/pi/rain.py &
The '&' symbol is very important! It allows the script to run in the background, otherwise the RPi will not be able to run anything else and the SD card will need to be reflashed! That finishes the software part!
The '&' symbol is very important! It allows the script to run in the background, otherwise the RPi will not be able to run anything else and the SD card will need to be reflashed! That finishes the software part!
Hardware - Part 1
![PICT0046.JPG](/proxy/?url=https://content.instructables.com/FYH/0ZCG/HPYORYN9/FYH0ZCGHPYORYN9.jpg&filename=PICT0046.JPG)
![PICT0056.JPG](/proxy/?url=https://content.instructables.com/F6Z/OL58/HPYORYMZ/F6ZOL58HPYORYMZ.jpg&filename=PICT0056.JPG)
To start the hardware part of this project, the speakers need to be taken apart. When taking apart the speakers, wires may have to be cut, so be sure to make a note of which connections go where! Next, layout the speakers and the switch on the lid of the box (picture 2) and mark with a permanent marker. We'll have to drill some holes for these next.
Hardware - Part 2
![PICT0062.JPG](/proxy/?url=https://content.instructables.com/FH2/VJZM/HPYORYLN/FH2VJZMHPYORYLN.jpg&filename=PICT0062.JPG)
![PICT0067.JPG](/proxy/?url=https://content.instructables.com/F8Q/VTN4/HPYORYHW/F8QVTN4HPYORYHW.jpg&filename=PICT0067.JPG)
![PICT0070.JPG](/proxy/?url=https://content.instructables.com/FA5/Q846/HPYORYHU/FA5Q846HPYORYHU.jpg&filename=PICT0070.JPG)
![PICT0071.JPG](/proxy/?url=https://content.instructables.com/FGY/WLGY/HPYORYHQ/FGYWLGYHPYORYHQ.jpg&filename=PICT0071.JPG)
Next, drill a hole for the switch, double checking that the switch will stay firmly in place in the hole. If you have a washer to go over the switch, check that it holds the switch firmly. A speaker hole layout was drilled with my Dremel using small Dremel drill bits, but a drill should work fine as well. To do this, I drilled two separate crosses. One with two holes on the four sides of the center hole, and the other cross with three holes on all four sides of the center hole. Now install both the speakers and switch. Secure the switch with either hot glue or a washer, and secure the speakers with either hot glue or screws. I found hot glue to work fine for both the speakers and the switch in a pinch.
Hardware - Part 3
![PICT0101.JPG](/proxy/?url=https://content.instructables.com/FN8/NQYF/HPYORYGJ/FN8NQYFHPYORYGJ.jpg&filename=PICT0101.JPG)
![PICT0078.JPG](/proxy/?url=https://content.instructables.com/FRK/WAJB/HPYORYHF/FRKWAJBHPYORYHF.jpg&filename=PICT0078.JPG)
![PICT0098.JPG](/proxy/?url=https://content.instructables.com/FE6/UGXE/HPYORYH9/FE6UGXEHPYORYH9.jpg&filename=PICT0098.JPG)
At this point the speaker and audio jack connections can be remade, so referring to your notes made on where each connection is, solder the speakers and audio jack back to the audio amp circuit board, covering connections where necessary. Now is a good time to check that powering up your speakers and plugging in an audio source will play through the speakers. After checking that the speakers work fine, a hole in front of the box needs to be drilled for the volume control knob. Drill the hole, making sure that the knob can turn freely in the hole. Also, I recommend drilling this hole as low as possible on the box since I had a difficult time concerning room in the box with the speakers and circuit board. So, drill the hole lower and eventually the board will be glued in place in the bottom of the box to secure it.
Hardware - Part 4
![PICT0112.JPG](/proxy/?url=https://content.instructables.com/F6A/ICMQ/HPYORXZ8/F6AICMQHPYORXZ8.jpg&filename=PICT0112.JPG)
![PICT0111.JPG](/proxy/?url=https://content.instructables.com/FUZ/I7XQ/HPYORY97/FUZI7XQHPYORY97.jpg&filename=PICT0111.JPG)
![RainPiSchem.jpg](/proxy/?url=https://content.instructables.com/F9Y/MKRE/HQ1DR6WJ/F9YMKREHQ1DR6WJ.jpg&filename=RainPiSchem.jpg)
![PICT0115.JPG](/proxy/?url=https://content.instructables.com/F0Z/APYV/HPYORXYO/F0ZAPYVHPYORXYO.jpg&filename=PICT0115.JPG)
![PICT0118.JPG](/proxy/?url=https://content.instructables.com/FMX/EM41/HPYORXY5/FMXEM41HPYORXY5.jpg&filename=PICT0118.JPG)
![PICT0121.JPG](/proxy/?url=https://content.instructables.com/FP4/DRUR/HPYORXUW/FP4DRURHPYORXUW.jpg&filename=PICT0121.JPG)
Now we're ready to power up the system and install everything in the box. Before soldering everything, be sure to drill a small hole in the back of the box in order to string the power cord through, I also tied a knot in it so that no electronics are being pulled on. Follow the included schematic to solder all the power connections. The 5V regulator gets hot, so a small hole in the back of the box is needed for the fan exhaust. I put this all the way to the opposite side of the power cord hole. I also cut a snippet of metal I had laying around to act as a heat sink which I screwed the regulator on to. The fan and 5V regulator need to be glued in the box in such a way that the fan is free to blow, blows ACROSS the regulator and out the small exhaust hole in the back of the box (refer to picture). Almost done! Put everything in the box, making sure that a.) all connections are made and the audio jack is plugged in to the Raspberry Pi, b.) the fan is free to blow air, c.) the audio amplifier is glued in the bottom of the box to prevent movement d.) all connections are covered! Finally, screw the lid on with the included screws.
Well, that about wraps it up! Enjoy the rain!
Well, that about wraps it up! Enjoy the rain!