Introduction: ARUPI - a Low-Cost Automated Recording Unit/Autonomous Recording Unit (ARU) for Soundscape Ecologists
Second Prize in the
Raspberry Pi Contest
This instructable was written by Anthony Turner. The project was developed with lots of help from the Shed in the School of Computing, University of Kent (Mr Daniel Knox was a great help!).
It will show you how to build an Automated Audio Recording Unit for less than £150. You can use this unit to conduct research in the field of Soundscape Ecology (which is why I built this). You could use it to monitor the birds in your garden or just to make nice recordings of the dawn chorus, without having to get up really early.
The ARUPi (Automated Recording Unit Pi) uses the Raspberry Pi computer and an Arduino-based power-control board called the Sleepy Pi. It is fully customisable and you will be able to add different environmental sensors to the units if you wish (not explained here). This instructable will give you a bare-bones unit. I will provide you with an Arch Linux operating system (OS) that is stripped down and has the recording program pre-installed on it.
You may need to do some (very simple) soldering so be prepared for this, but it is possible to build this unit without soldering if you do not own or cannot afford a soldering iron (ca. £10). I will split this instructable into several steps. The first ## steps will deal with getting the software onto your ARUPi and getting the computer side of things up and running (uploading software to Raspberry Pi and Sleepy Pi). Once you have done this, you will be able to go your own way and decide which microphones and casing you want to use. If you want to make what I have made, then continue with the instructable and it will show you how to build some cheap (but good) microphones and assemble some field-tested, fully waterproof, pretty robust ARUPi's (pictured).
If the ARUPI does not fit your needs it is worth checking out the following alternative - there may be ways of combining aspects from both units to create an optimal design for your needs:
They use the newer Creative Soundblaster Play! so I would probably do that too (the model 2 or 3).
I would add that if you are seeking longevity in terms of power, using 8xD cell batteries is probably the way forward. This can give you enough voltage to run your unit (i.e. 8 x 1.2V), and a whopping 60,000 mAh. If using 8xD batteries and the recording schedule I used (i.e. 1 minute every 15 minutes) you should get around 96 hours over 60 days. NB: you probably cannot use a portable power bank with the ARUPI - I tried it with an early RAVPower charger i bought for this purpose (I still have the charger because it is really good) but the Sleepy Pi could not "wake" the power bank up. This is why I went for batteries with the ARUPI - but that was in 2014 (and the power bank is still really good by the way) so newer power banks might be more compatible - perhaps connecting them to the sleepy pi via the DC connector/socket might work, perhaps using a USB to DC cable (I don't think I tried that). Using 4 x D cells won't work either as that only gives 4.8V to your unit so there isn't enough power to run the raspberry pi and the soundcard - it works but not very well. 8xD cell would be the best option for longevity, in my opinion.
Also - it is worth checking out the Sleepy Pi 2 (https://spellfoundry.com/product/sleepy-pi-2/) as this newer model has much more flexibility with regard to programming - it will enable you to switch the unit on and off at specific times (perfect for bat surveys, dawn chorus surveys etc etc). I have not yet played around with the Sleepy Pi 2 but will post updates if any arrive. If you get there before me please let me know as I am interested in hearing how these things develop with the ARUPI (and other units). NB: the original Sleepy Pi is still available if you want to follow this instructable as it stands.
All the best!
Step 1: Step 1 Items Needed
NB: for a more detailed list of parts, see note at end of Step 2
1. Raspberry Pi A+ (case optional) - get it from PiMoroni/Ebay/Amazon
2. Sleepy Pi - http://spellfoundry.com/products/sleepy-pi/
3. Sleepy Pi programmer - http://spellfoundry.com/products/sleepy-pi-program...
- This programmer saves a lot of hassle. However, you can build your own for less money if you buy an FTDI 3.3V USB to TTL Arduino Programmer cable/board (http://spellfoundry.com/sleepy-pi/programming-sleepy-pi-standalone-board/). If you are new to programming I recommend buying the Sleepy Pi Programmer.
4. 16GB Kingston Data Traveler Micro (pictured). You need to format the USB drive to NTFS before plugging it into your Raspberry Pi (format USB using Windows Explore - see image). If you decide to use a different make/model/capacity USB storage device, you may need to change some information in the /etc/fstab system files on the ARUPi OS I supply you with. The OS I provide you with mounts the 16GB Kingston Micro DT to sda1 (the kingston Micro DT 64gb usb drive mounts to sda5 - you need to alter these in the fstab folder, but that is included in the instructions a bit later on). Whichever USB drive you go with, make sure you use the same one each time you change it in your completed ARUPi when out in the field - the ARUPi will not automatically recognise a new USB drive.
5. USB soundcard. I chose the Creative Soundblaster Play! because it records 16bit Stereo up to 48KHz. It is also compatible with the Raspberry Pi and doesn't need any extra drivers - plug and play. However, there are cheaper USB soundcards available so it might be worth investigating.
6. USB splitter. The one pictured works well and is available on Ebay from multiple sellers. It is slightly less bulky than others that are available (but it is still rather big - but it is more bendy so fits inside my waterproof enclosure well).
Step 2: Step 2 - Collect Software
1. Download and install Win32 Disk Imager® software from http://sourceforge.net/projects/win32diskimager/
2. Install Arduino IDE software onto your computer: https://www.arduino.cc/en/Main/Software
3. Collect the operating system and other relevant files from my GoogleDrive Account by following this link:
- The link should take you to a googledrive shared folder I created.
- It contains:
- the Operating System you need (ARUPi_240415). This file is 7.32GB so may take a while to download. GoogleDrive will also state that it cannot scan the file to check it is safe as it is too large. Don't worry about that - the file is virus free (it is an image of an Arch-Linux Operating System).
- The Folder labelled "Sleepy_Pi" contains "_15min_Pi" (a program that tells the Sleepy Pi to wake the Raspberry Pi every 15 minutes) and a folder called Libraries. You need to save these files into the "Arduino" folder that should be found in the My Documents folder on your computer (assuming you have installed Arduino IDE.
- It also contains:
- A more detailed Parts List (ARUPI_PARTS_INFO.xls) with some links to where you can buy some of the parts. The first column (Step) states whether you need that item for the software side of things or not.
- PDF document that cover step 5. and Step 6 I suggest following the PDFs as they are colour-coded and easier to follow.
- A folder named "Example_ARUPI_Recs", which contains a small handful of example recordings made with these units in UK coppiced woodland sites from summer 2015 (I have ca. 35gb to get through so these are plucked randomly from the mix). I tried to include examples that cover, rainy nights, colourful dawn chorus mornings, low-power related beeping sounds (advice and ideas welcome), airplanes and moments of quiet! I think the recording quality is pretty good for a mono microphone (my how-to-build this microphone is still pending but on its way in the next couple of weeks),
and is more than adequate for my needs so far. I think you could spend a bit extra and get very high quality audio if you desire - something I might also look into when time permits.
Step 3: Step 3. Create Disk Image
1. Write the OS disk image to your micro SD card using Win32 Disk Imager.
2. When selecting Arupi_240415, you need to change file type to *.* to make it visible (see top image)
3. Select the disk drive that corresponds to your micro SD card (bottom image)
- I always make sure I only have my SD card plugged in to avoid accidentally formatting an external HDD or other USB device.
4. Now click the “Write” button
- This will write the disk image to the device.
Step 4: Step 4. Upload Program to Sleepy Pi
The Sleepy Pi is one of the most
important pieces of kit for this unit. It turns the Raspberry Pi on and off to a schedule that you choose. Therefore, you need to tell the Sleepy Pi what you want it to tell the Raspberry Pi to do.
1. The Sleepy Pi has an onboard Arduino microcontroller, on which instructions can be installed. To do this you need to have installed the Arduino IDE software.
2. Download the entire Sleepy_Pi folder from the GoogleDrive link on the previous step. Place the “_15min_Pi” file and “libraries” folder in the “Arduino” folder created in your “My Documents” folder (i.e. C:\Users\Ant\Documents\Arduino)
3. Open the script “_15min_Pi.ino” in the Arduino IDE. This script is what you need to upload to the Sleepy Pi. It tells the Sleepy Pi to turn on your Raspberry Pi every 900 seconds (i.e. 15 minutes). You can change this schedule by modifying the following line (i.e. 1800 seconds would equal 30 minutes).
int SYSTEM_SLEEP_TIME_IN_SECONDS = 900;
NB: it is possible to create a schedule based on turning the ARUPi on at set times during the day if this is your aim. To find out, consult the information on the Spell Foundry website.
4. To verify that the script works click on the tick symbol just below the 'file' tab (see image for better instructions). If the script doesn't run properly, check that you have put all the libraries from my GoogleDrive into your Arduino folder (see above).
5. Connect your Sleepy Pi to your computer and upload the _15min_Pi.ino script. If you have bought the programming unit from the Spell Foundry then follow the instructions given (install correct drivers etc etc). If you have your own FTDI programmer then use this webpage for guidance http://spellfoundry.com/sleepy-pi/programming-sle...
In a nutshell:
- connect the programmer to the GPIO pins of your Sleepy Pi and connect USB to your computer NB: Make sure you connect pins correctly (see webpage given above)!
- Plug in the power supply to your Sleepy Pi (micro USB OR via barrel jack)
- Open “_15Min_Pi” (or your modified script) in Arduino IDE.
- Select Arduino Fio as your board (see image)
- Upload your script to the Sleepy Pi by pressing the “upload” arrow next to the tick.
- If it doesn’t work then check the COM Port is correct (see image). You might have to reinstall the drivers for your FTDI serial programmer.
Step 5: Step 5: Set Up Sleepy Pi Real Time Clock and Raspberry Pi A+
- FORMAT Kingson DT Micro USB DRIVE TO NTFS FILE SYSTEM – THE ARUPI OS IS PROGRAMMED TO AUTOMATICALLY INSTALL THE NTFS USB DRIVE. IT WILL NOT WORK IF THE DRIVE IS USING ANOTHER FILE SYSTEM
To install the time on the Sleepy Pi and get it to talk with your Raspberry Pi you must follow these instructions for each unit you build.
- Insert a CR1632 battery into the Real Time Clock (RTC) slot on the Sleepy Pi (image a)
- Plug in the Sleepy Pi to the GPIO pins on the Raspberry Pi as shown in image b.
- Plug in your usb splitter and plug in the soundcard, your USB storage device and a keyboard (image c – step 1).
- If you have a network cable (ethernet), plug it into the Raspberry Pi ethernet port now. Don’t worry if you don’t have one, the instructions will explain all.
- Plug in a HDMI cable into the Raspberry Pi HDMI socket to connect to your monitor/TV .
- Now ensure the power bypass switch is set to override the Sleepy Pi program (image d)
- Plug the power supply into the micro USB power socket on the Sleepy Pi (image c – step 2).
- The Raspberry Pi should boot up (if it doesn’t boot up and go to the Username/Password command lines see notes at end of this document).
- Type in the username: root and the password: root.
o Now you are in!
Accessing the sleepy pi clock:
i2cdetect -y 1
The screen-grab image displayed above should come up after you press enter (<enter> from here)
If that doesn’t work try:
i2cdetect -y 0
(If that doesn’t work then shutdown Raspberry Pi (type: shutdown) and check you have properly installed the Sleepy Pi onto the Raspberry Pi unit)
If the RTC is detected but the entry at 0x68 is “UU” not “68” then you need to unload the drivers from that address. To do this type:
rmmod rtc-ds1374 <enter>
Now try the i2cdetect command again and you should get the same output as the image above.
The RTC will be detected with the address 0x68.
Note: Remember which i2cdetect command worked (i.e. –y 0 or –y 1) as you need to enter /i2c-0/ or /i2c-1/ depending on which one worked, in the line after next (highlighted).
2. Now type the following:
modprobe rtc-ds1374 /bin/bash -c "echo ds1374 0x68 > /sys/class/i2c-adapter/i2c-1/new_device" <enter>
If you get error messages check very carefully that you have entered exactly what is above.
3. Now check the time on the RTC by typing:
hwclock –r <enter>
It won’t be the correct date if you don’t have an Ethernet cable connected.
4. Upload the correct time to the Sleepy Pi RTC. If you have a network cable connected to your Raspberry Pi simply type:
hwclock –w <enter>
If you don’t have a network cable you have to set the time on your Raspberry Pi. To do this type the following:
date –s “dd MTH yyyy hh:mm:ss”
eg. date –s “15 MAR 2015 18:33:46”
Now type: hwclock –w <enter>
5. Now check the time on the RTC by typing
hwclock –r <enter>
If the time is incorrect. Try repeating the necessary steps carefully – it is easy to mis-type things.
Stay logged into the ARUPi and go to Step 6!
If the Raspberry Pi Didn’t boot up properly
The Raspberry Pi will not load up properly if the correct USB stick is not plugged in. This isn’t a problem but it does mean you need to alter the “fstab” file.
If you are using a different USB storage device to the one I have recommended it might affect the way the Raspberry Pi boots up. If it does, you will be taken to a command line that says type password or press D to continue as administrator (the password is “root”) – do as it asks. This is because this OS is set up to automatically mount the Kingston DT micro 16GB USB stick.
- Type blkid
- Something similar to this should appear
/dev/sda1: LABEL=”System Reserved” UUID=”36423FA6423F6A2F” TYPE=”ntfs”
/dev/sda2: UUID=”B6DA024DDA0209F7″ TYPE=”ntfs”
/dev/sda3: UUID=”ARUPi_3Kingston_DT″ TYPE=”ntfs”
/dev/sda4: UUID=”f2025d4a-ab25-41de-a530-285f5b979cd0″ TYPE=”ext4″
/dev/sdb: UUID=”6ABB-232A” TYPE=”vfat”
- Identify your USB drive from the list and make a note of the mount point i.e. if it was the highlighted line, make a note of “/dev/sda3”.
- Now type nano /etc/fstab
- Modify the line that contains /mnt/arupi so that the /dev/sda1 corresponds to the ID/mount point of your USB drive.
- Ctl X to exit and Y to save changes.
- Now type reboot and the Pi should restart and load up normally (assuming you have the soundcard plugged in).
- NOTE: you can go through the following steps without the soundcard plugged in or even the USB drive mounted properly, but it is better to make sure your Pi loads up properly with all the parts plugged in!
Step 6: Step 6 - Modifying the Recording Script and Activating the ARUPi
Download "Step_6" pdf from GoogleDrive Folder if you want colour-coded instructions.
1. Now set your desired recording lengths by typing the following:
The first few lines that are preceded with a # are some instructions/information about what is in this file – the # prevents the computer from running the information following it much like in R, if you are familiar with that language). Basically, the last two digits on the script (the line that isn’t preceded with a #) indicate recording length in seconds. The default setting is to record for 60 seconds. So if you want to make two minute recordings delete 60 and change it for 120 (for three minute recordings 180 etc).
2. Finally set the Raspberry Pi to start recording automatically when the Sleepy Pi wakes it up. Type the following:
The following lines will appear in the nano editor:
# @reboot /root/setClock.sh &
# @reboot python /root/recordPi.py &
These lines are essentially your recording program. At the moment, these lines are not active when the Raspberry Pi boots up. You need to delete the # in order to activate them.
@reboot /root/setClock.sh & sets the Raspberry Pi’s clock to be the same as the RTC on the Sleepy Pi.
@reboot python /root/recordPi.py & runs a program using python software that makes the Raspberry Pi record for 60seconds when it is booted up and then shuts the Raspberry Pi down.
NOTE: Do not delete the # from the first 6 lines on this page – these are just re-iterating the instructions you should follow. Once you have deleted the two # symbols required, your ARUPi is ready to go.
Now press x to exit nano. It will ask you if you would like to save the changes you made press:
y and for yes
n and if you want to start afresh (in case you accidentally deleted everything or made a mistake but can’t remember what it was).
NOTE: when your Raspberry Pi boots up from now on it will automatically run these two files. So if you wish to alter anything, you will need to reverse what you have just done by placing a # at the beginning of the two lines just mentioned. Save the crontab file and then type reboot at the command line. You need to do all of this before the pi shuts itself down again. Also, remember to re-activate the Pi when you intend to use it in the field. If you cannot type fast enough to do that, you can boot up you Pi without the USB stick plugged in. This will log you in as an administrator and you can modify the pi as you like, without having to rush!
3. Shutdown the Raspberry Pi by typing:
There will be a delay of around one minute whilst the Raspberry Pi initiates the shutdown so just relax. Now you are ready to go and do some automated audio recording! Alternatively, you can type poweroff to shut it down more quickly.
4. Once the Raspberry Pi has shutdown, remove the power supply from the Sleepy Pi.
5. Readjust the power bypass switch to enable the Sleepy Pi to control the power to the Raspberry Pi (image e).
If you are making multiple units and you have changed anything in this step (i.e. altered the recording length or activated the ARUPi – i.e. deleted the 2 #s in crontab) then you might want to make a disk image of your current micro SD card. To do this, use Win32 Disk Imager to read the data from the card into a new image file (eg. MYARUPi_170915). You can then write the new image to your subsequent SD cards and they should all perform identically. You can set the time on all of your Sleepy Pi units using just one Raspberry Pi.
Step 7: Step 7 Progress Update
·Now when you plug a power supply into the Sleepy Pi, the timer on the Sleepy Pi will start counting down from 900seconds (or whatever length of time you stated in step 4).
· After 900seconds, the Sleepy Pi will turn on the Raspberry Pi and the Raspberry Pi will record audio (WAV) for 60seconds (or whatever you stated). NOTE. If you don’t have a microphone plugged into the Soundcard, the audio file will be 60seconds of no sound!
· The file will be saved on your USB stick and will be labelled “ddmmyyhhmmss.wav” eg. 050715190559.WAV.
· It is always worth running the unit from your chosen battery supply to a few hours/days to check the recordings are working OK. Sometimes if the power supply is too low, there can be interferences (beeps and clicks) in the recordings. This is also worth remembering when deploying your units for long periods – find out when the power from your chosen supply method drops to a level where it affects the audio. NOTE. The beeps and clicks mentioned don’t seem to appear on any spectrograms so they are not a major problem for most purposes, but they are an indication that your power supply has dropped or is too low!
· Now you can mount your recording unit in a waterproof casing.
Step 8: Choose Power, Microphone and Casing
The instructions for how to do the following two tasks are a work in progress - I am quite busy with my PhD research at the moment and this side of developing the unit is relatively easy and it depends on how much money and time you want to spend on it. You can research your own microphones and cases if you please or keep an eye out for these instructions to be uploaded!
You now have an automated recording unit. However, you still need a power supply, microphone and waterproof enclosure. From here on you can use your creativity/research to put your stamp on the unit. But you do need the following three things!
1. Power Supply: - The Raspberry Pi requires at least 5V to function, but this unit requires more since it has several bits of kit attached to it. The Sleepy Pi can regulate a 5.5V to 17V power supply via the power jack to the Raspberry Pi. I used 8xAA (non-rechargeable-ca.2400mAh each) batteries (ca.12V total) to power my ARUPis. They could record one minute of audio, every 15 minutes for ca 7days. The barrel jack shown in the picture comes with the Sleepy Pi unit. - You will need: Battery holder (i.e. 8xAA) pp3 9v battery clip and lead In-line switch (optional - but makes life simpler in the field and reduces stress on plugs and sockets!)
2. Microphone - you need a microphone with a 3.5mm stereo jack plug. Plug this into your soundcard mic slot and you are almost there! If you wish to build your own microphone, I recommend the Primo EM172 (or Primo BT EM-172). Please see the Microphone building PDF in my GoogleDrive to learn more about building your own Primo EM172 microphone. It really is quite simple. If the pdf is not in there then please be patient. If you simply cannot wait, send me a request (it is a work in progress at the moment - 16/09/15).
3. Waterproof Enclosure - I recommend the one pictured, sold by Solent Plastics amongst other vendors on Ebay and Amazon. It is very robust and comes with modifiable foam inside and I can vouch for their performance in terms of ruggedness and waterproof-ness. I used a 25mm cable gland (IP68) from screwfix to mount my microphone (which is encased in 15mm aluminium tubing). This involved cutting a hole in the case and inserting the cable gland - I sealed the edges with Sugru adhesive. I also bought some 11mm blanking grommets to use as a plug when the microphone is not attached - keeping the RasPi and Sleepy Pi dry is rather important!. Obviously, if you decide to go with a different microphone, your method for attaching it may be different!
We have a be nice policy.
Please be positive and constructive.