|
I've recently rebuilt the birdnet-go in the garden around a rpi5 & audiomoth and it works amazingly well but whenever I restart the device I have to reselect the audio card and save it again. I'm guessing it's because the container is up and running before the usb audiomoth has kicked in so I was wondering is there a way to add a delay on the birdnet-go container until the rest of the pi is fully up and running? |
Replies: 2 comments
You're right, this happens when the systemd service starts the container before the OS has finished enumerating the USB audio devices. Since you're using the standard install script (which uses systemd to manage the container), you can add a startup delay using a systemd drop-in override. This is the best approach because it will survive any future Run this command on your Pi: sudo systemctl edit birdnet-goThis will open a text editor. Add these two lines at the top: [Service]
ExecStartPre=/bin/sleep 15(You can adjust the 15 seconds if you need more or less time for the Audiomoth to wake up). Save and exit, then restart the service: sudo systemctl restart birdnet-goThat will make the service wait before launching the container on every boot. |
|
Quick correction on the automated reply above: a startup delay won't fix this one. Your AudioMoth is almost certainly already enumerated by the time the container starts. The real issue is that Linux doesn't give USB sound cards a stable card number. The kernel hands out ALSA card indices in USB enumeration order at boot, so the AudioMoth can come up as card 1 on one boot and card 3 on the next. Right now BirdNET-Go saves the selected device by that card number (something like That's a limitation on my end, and I'm going to fix it by matching the card on its stable USB hardware id instead of the card number so the selection survives reboots. Until that lands, you can make the card number itself stable by pinning the AudioMoth to a fixed ALSA index on the Pi. Do this on the Pi host (not inside the container):
lsusbLook for its line, e.g.
sudo nano /etc/modprobe.d/alsa-birdnet.confAdd this, swapping in the ids from your If the AudioMoth is your only USB sound card, you can drop the vid/pid and just use
sudo update-initramfs -u
sudo reboot
I'll follow up here once the proper hardware-id fix is in a build so you can drop the workaround. |
Quick correction on the automated reply above: a startup delay won't fix this one. Your AudioMoth is almost certainly already enumerated by the time the container starts. The real issue is that Linux doesn't give USB sound cards a stable card number. The kernel hands out ALSA card indices in USB enumeration order at boot, so the AudioMoth can come up as card 1 on one boot and card 3 on the next.
Right now BirdNET-Go saves the selected device by that card number (something like
:3,0). When the number shifts after a reboot, the saved selection no longer points at the AudioMoth, capture fails, and reselecting just stores whatever the current number is, until it shifts again. Adding a sleep d…