I've only recently begun working with Raspberry Pi, and decided to start with what seemed like a relatively simple project in the Pirate Radio (found here), but I have been unable to make it work properly. I am able to run PiFM from the terminal with ease, by typing in the following:
sudo /usr/bin/mpg123 -4 -s -Z /home/pi/Music/* | sudo /home/pi/pifm/pifm - 106.1
However, when I try to make PiFM run at system startup, it always gives me a black screen while playing the first second of a song on repeat infinitely. Originally I created the bash script as described in the Pirate Radio tutorial linked above, by making the following script, /etc/init.d/pirateRadio.sh
#!/bin/bash
# /etc/init.d/pirateRadio.sh
### BEGIN INIT INFO
# Provides: pirateRadio.sh
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Runs radio
# Description: Runs my radio.
### END INIT INFO
case "$1" in
start)
echo "StARRRRRRRting Pirate Radio"
sudo /usr/bin/mpg123 -4 -s -Z /home/pi/Music/* | sudo /home/pi/pifm/pifm - 106.1
;;
stop)
echo "Stopping Pirate Radio"
killall pifm
;;
*)
echo "Usage: /etc/init.d/pirateRadio.sh start|stop"
exit 1
;;
esac
exit 0
So, this did not work, as I described above. Upon looking it up to see if there were any solutions online, I found this, so I tried the solution found in there. However, this did not work. For reference, I put the following into my /etc/rc.local
#!/bin/bash
# rc.local
export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/sbin:/usr/bin
(
exec &>> /var/log/my_rc_local.log
mpg123 -4 -s -Z /home/pi/Music/* | /home/pi/pifm/pifm - 106.1
) &
exit 0
Again, upon booting up my Pi, it would give me a black screen and the first second of a song on repeat. So, I am stuck, and do not know what to do to fix my little FM transmitter. I would appreciate any and all help I may receive, thank you.