https://github.com/cdzombak/pi-fm-player
Raspberry Pi FM transmitter that plays music forever from the local filesystem.
https://github.com/cdzombak/pi-fm-player
fm-transmitter mp3 music-player radio raspberry-pi
Last synced: about 2 months ago
JSON representation
Raspberry Pi FM transmitter that plays music forever from the local filesystem.
- Host: GitHub
- URL: https://github.com/cdzombak/pi-fm-player
- Owner: cdzombak
- License: unlicense
- Created: 2018-02-17T22:11:23.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2023-11-14T14:16:29.000Z (over 1 year ago)
- Last Synced: 2025-04-12T20:53:01.939Z (about 2 months ago)
- Topics: fm-transmitter, mp3, music-player, radio, raspberry-pi
- Language: C++
- Homepage:
- Size: 52.7 KB
- Stars: 49
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pi-fm-player
A Raspberry Pi-based music player + FM transmitter, originally created for my home alarm clock. `pi-fm-player` continuously transmits MP3s stored locally, in a random order, on the FM frequency of your choice.
## Hardware Setup
Connect a ~20cm/8in single-conductor wire to GPIO 4 (which is pin 7 on [header P1](http://elinux.org/RPi_Low-level_peripherals#General_Purpose_Input.2FOutput_.28GPIO.29)) to act as an antenna.
## Install & Configure
On the Raspberry Pi:
- Place the `pifm` directory from this repo at a location of your choosing.
- I placed it in `/opt` on my Raspberry Pi.
- You may wish to adjust file permissions if installing it in `/opt` or similar. I did this by running `sudo chown -R root:root /opt/pifm`.
- Put MP3 files in a directory of your choice.
- I'm using [Syncthing](https://syncthing.net) to sync music to `~/Music` on my Pi.
- Setup `pifm-player.service`, the systemd service which runs the transmitter.
- First, customize `pifm-player.service`.
- Set the environment variables `MUSIC_DIR` and `PIFM_BIN` to point to the music directory and the `pifm` binary on your system.
- Set the variable `PIFM_FREQ` to change to a different FM frequency.
- `sudo mv pifm-player.service /etc/systemd/system/`
- `sudo chmod 0644 /etc/systemd/system/pifm-player.service`
- Finally, enable and run the transmitter service:
- `sudo systemctl enable pifm-player.service`
- `sudo systemctl start pifm-player.service`## Logs
> Is it working?
```shell
sudo journalctl -f -u pifm-player.service
```> What was playing at some point in the past?
```shell
sudo journalctl -u pialarm-transmit.service --since "2019-10-21 07:30:00" --until "2019-10-21 07:50:00"
```## Monitoring
You can use [`runner`](https://github.com/cdzombak/runner) and an [Uptime Kuma](https://github.com/louislam/uptime-kuma) push monitor to get alerted if/when the pi-fm service fails. After installing `runner`, put the following in `/etc/cron.d/pifm-check`:
```text
* * * * * root runner -job-name pifm-check -retries 2 -retry-delay 15 -success-notify "https://my-uptime-kuma-host.example.com:9001/api/push/1234abcd?status=up&msg=OK&ping=" -- systemctl is-active --quiet service pifm-player.service
```## License
Released under the [Unlicense](https://choosealicense.com/licenses/unlicense/) (see `LICENSE` in this repo).
## Author
Chris Dzombak
- [github.com/cdzombak](https://www.github.com/cdzombak)
- [dzombak.com](https://www.dzombak.com)