0

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.

Mason.
  • 9
  • 3

1 Answers1

-1

I got the answer from Jaromanda X on my question auto start using /etc/rc.local or /etc/init.d not working you need to add sleep 10 and fix spacing

#!/bin/bash
export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/sbin:/usr/bin
sleep 10
(
  exec &>> /var/log/my_rc_local.log
  cd /home/pi/pifm && ./pifm sound.wav 90.5 
) &

exit 0

that worked for me

I used http://www.icrobotics.co.uk/wiki/index.php/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter and instructions from https://adestefawp.wordpress.com/raspberry-pi/pifm-radio/

Duffman
  • 9
  • 4