Posts tagged: Raspbian

Automated Raspberry Pi audio recorder

Today we’re gonna roll our very own sound recorder using a Raspberry Pi

Raspberry Pi Audio Recorder

This tutorial will show you how to build a fully automated recorder using an RPi, a USB sound card and a USB drive.

First up; install Raspbian, make sure it defaults to the command line and/or has SSH access so you can login to it from another computer. There’s plenty of tutorials out there explaining how to do this.

Second; make sure you have a compatible sound card, (I used a spare Griffin iMic, any class compatible one should work) and a USB flash drive. It should be possible to write to the SD card you’re using on the RPi, but people have had problems going that route. Besides, using a fat32 formatted usb drive will ensure you can plug it into you computer and play or copy the sound files without having to login (ssh) to the RPi.

First we’re gonna get rid of a lot of unwanted stuff! This isn’t a complete list, but I’m sure we can live without these applications installed taking up precious CPU cycles, RAM and disk space. Note: This will completely wipe the graphical user interface. You won’t be able to use the desktop anymore!

$ sudo apt-get purge galculator idle3 idle idle-python3.2 python3 midori scratch xpdf midori dillo netsurf-common netsurf-gtk leafpad penguinspuzzle pistore gpicview heirloom-mailx wpasupplicant aptitude xarchiver omxplayer aspell usbmuxd debian-reference-common debian-reference-en python-picamera cups-bsd cups-common vim-common vim-tiny desktop-base lightdm lxappearance lxde-common lxde-icon-theme lxinput lxpanel lxpolkit lxrandr lxsession-edit lxshortcut lxtask lxterminal obconf openbox raspberrypi-artwork xinit xserver-xorg xserver-xorg-video-fbdev xserver-common xserver-xorg-core xserver-xorg-video-fbturbo x11-common x11-utils x11-xkb-utils xauth xfonts-encodings xfonts-utils oracle-java7-jdk aptitude-common python python-gi python-minimal python-pifacecommon python-pifacedigitalio python-rpi.gpio python-serial python-support python2.7 python2.7-minimal python3.2 python3.2-minimal

Followed by:

$ sudo apt-get autoremove


$ sudo apt-get autoclean

That’s a lot of stuff we won’t be using! Now, we’re gonna install what we do want:

$ sudo apt-get install sox libsox-fmt-mp3

Sox is a specialized recording, processing and playback application. I won’t go into it too much, but it fits our needs perfectly. The second, libsox-fmt-mp3, is a library so we can encode to MP3 (if that’s what you want).

Now that we deleted and installed what we need, let’s set-up the soundcard. First up, let’s kill the built-in sound card:

$ sudo nano /etc/modules

And comment out:


By putting a “#” in front of it. Like so:

# snd-bcm2835

To be sure USB is first in line, we’re gonna force ALSA to pick it over the built-in one, even if we’ve just killed it.

$ sudo nano /etc/modprobe.d/alsa-base.conf

And comment out:

options snd-usb-audio index=-2

Again, with a “#” like this:

# options snd-usb-audio index=-2

Last but not least enter:

$ alsamixer

And set the recording levels of your soundcard to how you like them by pressing F4. To make sure the Raspberry Pi always boots up with these sound settings, enter this in the command line:

$ sudo alsactl store

Make a folder to mount the USB stick in:

$ sudo mkdir /mnt/USB/

Now we’re gonna make a few scripts. Don’t be afraid if you’ve never done this before, I’ve pre-fabricated them for you! In your home folder (Type “cd” and hit enter if you’re not certain), type:

$ mkdir Scripts

This’ll make a neat little folder for you to put scripts in. Change into it by typing:

$ cd Scripts/


$ nano

Copy and paste the following into it.

## Created by Son of 8-Bits
## Borrowing parts from Autostatic

## Mount the USB stick and kill unwanted services

## mount the USB stick
sudo mount -t auto /dev/sda1 /mnt/USB

## Stop the ntp service
sudo service ntp stop

## Stop the triggerhappy service
sudo service triggerhappy stop

## Stop the dbus service. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
sudo service dbus stop

## Stop the console-kit-daemon service. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
sudo killall console-kit-daemon

## Stop the polkitd service. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
sudo killall polkitd

## Kill the usespace gnome virtual filesystem daemon. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
killall gvfsd

## Kill the userspace D-Bus daemon. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
killall dbus-daemon

## Kill the userspace dbus-launch daemon. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
killall dbus-launch

## Set the CPU scaling governor to performance
echo -n performance | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor


Press “ctrl+x” to exit, “Y” to save, followed by an enter. You should now be back in the command line. This script will automatically mount your USB drive in /mnt/USB/ and kill some unwanted services clogging up RAM and CPU cycles. Most of this script was made by Autostatic, check out his original work here.

Now for the recording script:

$ nano


## Created by Son of 8-Bits
## 48000Hz stereo MP3 at 320kbps that automatically stops recording after 1 minute of silence.

FILENAME=$(date +”%Y%m%d_%H%M”)

sudo rec -c 2 -r 48000 -C 320.99 –buffer 262144 /mnt/USB/${FILENAME}.mp3 silence 1 0.1 1% 1 1:00 1%

[ $? -eq 0 ] || exit $?

sleep 10

sudo shutdown now


ctrl+X, Y, enter

To make these scripts work as planned enter:

$ sudo chmod 755

But these scripts won’t start by themselves just by being there! To make them start at boot type:

$ sudo nano /etc/rc.local

On the empty line after “# By default this script does nothing.” add:

sudo /home/pi/Scripts/
sudo /home/pi/Scripts/

ctrl+X, Y, enter

BAM! You’re done!

Try it out by hooking up a sound source to the line-in of your soundcard, booting the Pi, and recording a part of whatever it is you want to record. Note that after one minute of silence the RasPi will shut itself down. Listen back what you’ve just recorded by unplugging the USB flash drive and plugging it in you computer. Here are some tips if things are not to your liking.

Volume too low or high? Check the part about Alsamixer. (And don’t forget to check the level coming out of your audio source as well!)
Like to stop sooner (or later) after silence sets in, edit the recording script. See the part that says “1:00”? This is 1 minute, edit it to your liking. For instance ‘0:30’ for 30 seconds or ‘2:00’ for 2 minutes.
Pi not getting enough power? Use a 2 ampere powerplug or put a powered USB-hub between the RasPi and the soundcard/USB stick.



Ethercalc on Raspberry Pi with node.js

Multiplayer spreadsheets for your Raspbian installation


Whether you need to work on spreadsheets with multiple people or you just want an online/mobile server to host your spreadsheets, Ethercalc has got you covered. And as far as I know it’s the only to do it in multiplayer. That is, until I can finally get Apache Wave to run on the RasPi..

So let’s get this show on the road, we start off by making sure everything is up to date with a:

$ sudo apt-get update

Followed by a:

$ sudo apt-get upgrade

Now we’ll install node.js on the Raspberry Pi. Since I couldn’t have made it any easier or explained any better, I’ll redirect you to this tutorial for that. It’s okay, I’ll wait here until you’re done…

All installed and ready to go? Good! Let’s continue where we left off. Now that node is up and running, we need to install Ethercalc itself. This doesn’t work via the usual apt-get command, but instead it’s installed via NPM. Luckily, this software comes bundled with node.js nowadays, so that’s one less thing to worry about. So we can skip straight to installing Ethercalc:

$ sudo npm i -g ethercalc

For a while you’ll see “things” happen in the command line. Don’t be scared, these are nice, happy, and exciting “things”. But they do take a while. After the installation is finished you can congratulate yourself on a job well done and grab a coffee. However, you do want to actually use Ethercalc right? So when you’re back with your coffee we’ll do the following: Install Forever, and run Ethercalc via Forever.

$ sudo npm install forever -g

Again, happy, fantastic little things should be happening in the terminal. When it’s done installing you can run Ethercalc with the following command. Keep in mind that you will need to run this command everytime you boot up your Raspberry Pi.

$ forever -s start node-v0.10.2-linux-arm-pi/bin/node_modules/ethercalc/bin/ethercalc

And hey presto, it runs and is accessible through http://YOUR.RASPI.ADDRESS:8000



Getting Things Done with My Tiny Todo on Raspberry Pi

After iGTD was abandoned my GTD workflow was in disarray for a while. I wasn’t planning on paying a subscription for or buying software which used to be free..

My Tiny Todo - Open source list manager

So I quickly snapped up Evernote and Google Tasks, but, I was missing a quick way to empty my head and review what I needed to get done ASAP. Everything became dependent on notes and my own memory. And if you’re like me (or human for that matter) the latter isn’t a great way to manage a long and never ending list of tasks. After a few years the lists of things to do just stacked up. I kept forgetting things, missed opportunities, and all-in-all my life became messy again. Enter the Raspberry Pi and My Tiny Todo. (Edit: This’ll work on basically any linux server under your control, not just the RasPi.) Don’t know what Getting Things Done is? I recommend reading the book by David Allen.

The installation couldn’t be any easier in my opinion. Note: This tutorial assumes you have Apache or Nginx already installed and configured. There are numerous tutorials and resources on the web if you don’t. You have Apache or Nginx running? Great! Fire up your command line application, SSH into the RasPi if needed, and enter the following commands:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install php5 sqlite php5-sqlite

This’ll update the repository lists on your RasPi, upgrade any packages you might have installed, and will download and install PHP5, SQLite and a plugin so the 2 applications can work together. Next we grab the My Tiny Todo files, unzip em and remove the downloaded zipfile again:

$ wget
$ unzip
$ rm

Rename the folder if you like, by default it’ll be called ‘mytinytodo’, you can go with anything you like though. For this tutorial we’ll be using ‘gtd’ as an example:

$ mv mytinytodo gtd

And then we move the folders and files into the right place, and give them the correct privileges so Apache/Nginx, the PHP files and SQLite can talk to each other without any issues.

$ sudo mv gtd/ /var/www/
$ cd /var/www/gtd/
$ sudo chown -R www-data:www-data ./*

That last command changes ownership of every file and folder in the current directory to user www-data in group www-data, the default user and group for an Apache webserver. You can check if everything went well by issuing the following command:

$ ls -la

This should show you all the files in the current directory and who owns them. Now we repeat this step once again, as the folder itself also needs to be owned by www-data.

$ cd ..
$ sudo chown www-data:www-data gtd/

And you’re done with the terminal for now! Keep it open though, as we need to do 1 more tiny thing after the configuration screen. Fire up your favorite webbrowser and point it to the IP of your RasPi, followed by /gtd/setup.php. If you’re browsing on the Raspberry Pi itself, just go here: (Change the IP to that of your Raspberry Pi if you’re on another machine on the same local network.) This’ll give you an initial setup needed to configure and start My Tiny Todo. Choose SQLite and let it do it’s install-magic. We’re almost there now!

Now return to the command line and enter this.

$ sudo rm /var/www/gtd/setup.php

This’ll remove the setup.php file so other people can’t reconfigure your installation, safety first! And you’re done! You can now enter tasks, make lists and review your work. If your server is open to the internet and/or you don’t want family members, other people at work, people living in your house snooping on your projects, there’s one more thing you’ll definitely need to do. Go to ‘settings’ on the top-right of the My Tiny Todo screen (in your browser, remember). Go to ‘Password protection’ and click the ‘Enabled’ button. Next, enter a password of your choice. and hit the ‘Submit changes’ button. Now you’re safe from people snooping on you.

I hope this tutorial’ll help you get things done. If your webserver is open to the internet it might be wise to checkout how to enable SLL (https) so the password won’t go over the web unencrypted. Enjoy!

Edit: If you open up your server to the internet, you can access you tasks via any computer and smartphone (iOS, Android, Windows Phone) by surfing to your IP. Setting up a dynamic DNS service will really make your life a lot easier then.


Raspberry Pi powered sub-site

A Raspberry Pi powered sub-site hosting a DIY music store

RasPiBoard V2

…and that includes a Ðogecoin music store, coming soon!

Check for more.


Automatically mount a NAS, at boot, on a Raspberry Pi

Cyborg by Son of 8-Bits, on FlickrNow that I am able to control the Raspberry Pi with Synergy, as well as via SSH from another computer on the network, I’d like my multimedia files (music, movies, etcetera) to be readily available to me on the machine. XBMC/OpenElec has neat little GUI’s and even an on screen keyboard to configure your local shares, but Raspbian does not. So we’re gonna mount a NAS via CIFS (or any other CIFS compatible share, like SMB, known as Samba) so I can get to my files.

We’re starting at your home folder (YOUR_USER, pi by default)

$ cd /home/YOUR_USER/

Again, the default username is pi.

$ mkdir NAS

Or any other name you’d like the Folder containing your shares to have. You can use this new folder to mount the NAS, meaning the shared files’ll appear right here. But I made sub-folders because my NAS has multiple shares. If you’d like to make multiple mounts as well, enter:

$ cd NAS

Or the name you picked in the step before this one. and enter:

$ mkdir FOLDER

Name this new subfolder whatever you like, I went with the same name as the shared folder on the NAS so it’ll be easy to recognize. The name of the shared folder on the NAS is the same as SHARED_FOLDER in the text you’ll have to enter below, but first enter:

$ sudo nano /etc/fstab

This file we’ve opened and are about to edit is the file which tells the OS (Raspbian) to mount these shares as soon as you boot/login. (Sidenote: I’m not sure at which point this happens, as I’ve set my Raspberry to boot straight into the Desktop environment, LXDE.)

Go past whatever text is already there and enter the string of data below, don’t forget to edit the CAPITALIZED text to match your info. (Olawd, that rhymed!)


For IP_OF_NAS you can also set the name of the computer, which is also it’s domain name. If you don’t know what this is, ignore it and make sure the local IP of the NAS is correct. The SHARED_FOLDER is the shared folder we’re trying to mount.

Satellite dish by Son of 8-Bits, on FlickrIf you have your NAS set to accept any connection (shared folder-wise) without authentication, you can enter “guest” as the username and leave the password empty. This should work, but is however untested as I’ve secured my own NAS. You can always enter the admin username and password of the device, if you the credentials.

If you’ve entered this correctly it should automatically mount the shared folder(s) on the next login/boot. When you enter the folder(s) we’ve made earlier the files (and folders) contained in the share will appear as if they’re right there on your Raspberry Pi! But in fact it’s still just the NAS. Now you should be able to use these files in your applications. Please note: I can’t delete or edit files unless I use a sudo command, this might be different for you depending on your NAS and it’s configuration. Anyway, if you’re ready to try this auto-mount thing out, reboot the Raspberry Pi by entering:

$ sudo reboot