It all started when my partner and I were planning a roadtrip. We had the map slung out across the dining room table looking at all the national parks we could go and have a wander through. We looked up opening times and realised that by the time we got to most of these spots, the parks would be closing for the evening.
Talking further we started to imagine what it might be like to listen to a big ole tree in a national park from our dinky motel room every night. This got me thinking about grabbing a 3g dongle, a raspberry pi, a mic and some form of battery to see if we could literally stick a raspberry pi in a tree overnight, connect it to the internet and push an internet radio stream out. And behold! Project ThatGreenThing was born. Whilst the project is by no means finished and the scope has changed a little (does anyone every really completely finish a raspberry pi project?) it works and we’ve used it with great success broadcasting from empty rooms. Check out what we did here: broadcasts
That Green Thing Parts List
- 1 x raspberry pi model B (I’ve not tested with a model A but reduced power consumption of the device makes me want to)
- 1 x 8 gig SD card
- 1 x micro USB => USB cable
- 1 x power inverter. (you can use a number of different ones. I found a 10 amp el cheapo from my local electronics store with a DC power outlet and a USB outlet that works just fine. )
- 1 x sound card (I’ve used the soundblaster USB SB1140 and more successfully, the XENYX 302USB USB mixer)
- 1 x Sony ZOOM H6 sound recorder .
- 2 x microphones with xlr jacks (I used mics that draw power from the Zoom)
- 1 x wireless adapter. I got mine here. http://www.makershed.com/WiFi80211bgnModuleForRaspberryPiMorep/mkad55.htm
- 1 x (unlocked from the telstra network) Netgear Aircard 785S 4G wifi dongle .
- 2 x Alligator clips for the battery, (I hard wired these into the power inverter.
- 1 x VRLA 12 volt 18 ampere hour battery
- 1 x remote server running icecast to receive and broadcast the stream .
That Green Thing install
Download the latest raspbian raw image from here: http://www.raspberrypi.org/downloads Follow the instructions on the site, format an SD card and copy the image across to the card. Insert the card into the pi, power the pi up, plug the sound card and the wifi dongle in and perform a basic install.
Ensure you expand the file system in the initial boot menu. I also like to add a hostname but it’s up to you. After you’re done, reboot. I’d suggest you might want to enable a root password
’’’ sudo passwd root ‘’’
We’re trying to conserve as much power as possible on the pi to keep a battery running as long as possible. There are some simple procedures to underclock the device. The only one I’ve been brave enough to try is this: As root sudo user, you can edit the /boot/config.txt file the arm_freq default is 800. I’ll aim to develop this section as I find more acceptable underclocking techniques.
’’’ vi /boot/config.txt arm_freq=400 ‘’’
Then reboot. Make sure ALSA is installed and that your usb soundcard is working. At a terminal prompt type:
you should then see this screen:
Install darkice by following this most excellent guide: darkice install You will find that the source version of darkice has updated so you will need to update the file names and references appropriately. Configure wifi. I used this guide: wifi setup Then setup your hotspot of choice to connect the pi to. (keep in mind that if you use a modem with ethernet ports you won’t even need wifi). If you’re using a 3g connection to connect your device to, you’ll doubtless be assigned a dynamic ip address. Some mobile data providers even place you behind a private / NAT range. You might want to setup via a 3g network with a fixed IP or use a reverse ssh tunnel. I’d suggest investigating and choosing the best option for your circumstance and budget. Install init scripts Now, I have an init script to automatically start darkice on boot. For the darkice auto start, I actually call darkice from cron. As root type
Then cut and paste the below:
’’’ ## Run this every 2 minutes, which will check PID in /usr/local/bin, and only start darkice if it’s set to “0” */2 * * * * /usr/local/bin/darkice_start_on_boot.sh ‘’’
The script /usr/local/bin/darkice)startonboot.sh is below:
The following entries are not used, but good practice CURRENT_DATE=date +%Y%m%d
Checking startup status for darkice
if [ $X = 0 ]; then echo “SUCCESS: We can now start darkice after boot” echo 1 > /usr/local/bin/darkice_boot_pid /usr/local/bin/alsa_force-reload.sh /usr/bin/darkice -v 10 -c /etc/darkice.cfg else echo “ERROR: PID does not equal 0, so we can’t start” exit 1 fi ‘’’
Now we need to install and configure icecast on the remote server. Depending on the linux dist you’re using on your servicer this will differ. I run debian so the following works just fine:
’'’sudo apt-get install icecast2’’’
Now you need to edit your configuration file.
’'’sudo vi /etc/icecast2/icecast.xml’’’
Make sure you have entered your hostname and entered a source password for the mount:
`<!-- Admin logs in with the username given below -->` `<admin-user>admin</admin-user>` `<admin-password>YOURPASSWORD</admin-password>` `</authentication>`
<!-- This is the hostname other people will use to connect to your server.
It affects mainly the urls generated by Icecast for playlists and yp
You see whether your stream is up and whether icecast is running by typing http://YOURHOSTNAME:8000 into a browser.
Creating a reverse SSH tunnel to the pi.
On the raspberry pi, Create a public ssh key useradd USER log in as the user then type:
ssh-keygen -t rsa
Now you need to cd into the .ssh folder and copy the key over to your remote monitoring server .
scp id_rsa.pub user@remoteserverhostname:.ssh/authorized_keys
Finally, add shell script and cronjob to auto start
- login to pi as the user vi reverse.sh #!/bin/sh ssh -N -R 2322:localhost:22 email@example.com
change permissions on file
chmod 755 reverse.sh
@reboot /home/username/reverse.sh &
Go and find a decent battery. For our project we wanted the pi to be powered for at least 24 hours. This meant a decently large and unfortunately heavy battery. I went to my local hackerspace and got advice, then went to a caravan battery specialist and got more advice. I ended up with a lead acid, VRLA battery. Pi’s have a 5 volt 2 amp requirement. You’ll need to regulate your battery and make sure it pushes out the right current and voltage. The easy way round this is to buy a cigarette lighter charger, strip it then connect it to your battery directly.
Here’s a picture of the battery in all it’s glory. I specifically chose a VRLA battery as it seems to suit a constant drain from a low voltage device. You’ll note the multimeter next to the battery. Whatever battery you use, I strongly recommend grabbing it’s specs and the first few times you use the device, keep a log of how fast the battery is losing charge. That way you’ll know how long you can safely leave the device powered up. If you let the battery drain entirely in one go you’ll kill your battery. I’m getting around 22 hours out of my battery. Now with regard to the cable, for test purposes I just connected alligator clips to the battery and the regulator. Once you’ve proved everything works I’d suggest you go and make your own, more robust cable.