I was tasked with building a device that emits bird noises at specific times of the day, with the intent of attracting real birds of that species to nests that had been built for them.
The problem was that these nests are in the middle of nowhere, so no power or internet – hence the solar bit.
There are commercially available devices to achieve this, but for some reason they are like 10 times as expensive as doing it yourself. I’m sure an electronics person could have done it cheaper still, but I’m a software person, so I spent just north of 100 bucks on:
- Raspberry Pi Zero (with Raspbian)
- Waveshare WM8960 Hi-Fi Sound Card & Speakers
(official driver did not work, seeed-voicecard did) - Waveshare Solar Power Manager with a built-in LiPo Battery (10000mAh)
- Polysilicon Solar Panel (18V 10W)
In order to minimize power draw, edit the /boot/config.txt to change (or add) the following:
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
# Automatically load overlays for detected cameras
camera_auto_detect=0
# Automatically load overlays for detected DSI displays
display_auto_detect=0
# Enable DRM VC4 V3D driver
#dtoverlay=vc4-kms-v3d
max_framebuffers=2
# Disable compensation for displays with overscan
disable_overscan=1
# Disable the ACT LED on the Pi Zero.
dtparam=act_led_trigger=none
dtparam=act_led_activelow=on
# Disable Bluetooth
dtoverlay=disable-bt
I’m leaving WiFi on for the moment, in case I need to adjust stuff in the field. But we don’t need it at night, and we certainly don’t need HDMI after a bit, so just crontab -e:
# m h dom mon dow command
# 10 minutes after reboot, turn off HDMI to save power:
@reboot sleep 600 && /usr/bin/tvservice -o
# disable WiFi over night:
00 21 * * * rfkill block wifi
00 07 * * * rfkill unblock wifi
# acoustic systems check:
@reboot aplay /opt/swift/audio/4.wav
And now for the thing we’re actually here for – the noise part. Let’s bash this out as:
sleep $((RANDOM \% 30)); cd /opt/audio; ls *.wav | shuf -n 1 | xargs aplay
So after a random amount of time, pick a random file from our collection and send it to aplay (apt install aplay). Chuck it into crontab as 5-8,12,18-21 * * * and presto, solar freakin’ bird noises! (I’m aware that there will be clock drift, but we only need to run it for a few months, and the birds probably don’t care either)