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!
Step 1: Tools and Materials
- Drill w/ assorted drill bit sizes
- Wire Cutters
- Electrical Tape and/or Heat Shrink Tubing
- Soldering Iron/Solder
- 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)
- Raspberry Pi
- Small Computer Fan (The one I used is rated at 5V)
- Micro USB Cable
That’s it! Only a few parts to assemble! Total cost excluding the Raspberry Pi should be around 20-30 dollars, USD, depending on certain varying parts and where they are obtained.
Step 2: Software – Part 1
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:
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!
Step 3: Software – Part 2
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!
For more detail: Raspberry Pi Rain Box