A daily news radio player. Using a raspberry pi as hardware and the Swedish Radio as news source.
For audio playback, both vlc and mpg321 are used.
brew install vlc
brew install mpg321
N.B. brew may not work on Raspberry Pi.
This project uses vlc as a media player, so you need to be able to run vlc from command line to make this project work as expected.
In your .zshrc add:
alias vlc='/Applications/VLC.app/Contents/MacOS/VLC'
The pi is expected to have a button connected to gpio(general purpose input-output) 3 and a speaker via the 3.5 mm input. So suggestion is to connect the button to pin 5 and 6.
I suggest to start the script on system start up. Preferably with a cronjob. Read more about the scripts in the scripts readme.
First of all you need to figure out what ip address the raspberry pi connects to. The easiest way is probably to plug it in to a display and a keyboard and connect to your preferred network.
After that you can run ifconfig to figure out it's current ip. This ip may change over time, so make sure to configure your
home network/router to give your raspberry pi's mac address a static ip.
ifconfig
If the raspberry pi is already connected to the wifi, but you forgot the ip. I recommend using the tool nmap to find the ip.
- Install the tool
brew install nmap
- Scan for the ip
nmap -sn 192.168.1.0/24
To deploy the code to the raspberry i prefer SFTP and using Filezilla as a client. And to start the application you have to ssh into it.
ssh pi@{the ip}
Deploying changes to the pi is usually done by uploading the src folder, the package.json followed by a
yarn install
yarn run main
Commands from a single button connected to the pi's GPIO or a regular keyboard are supported.
Supported keyboard buttons are:
1Start radio2Toggle pause3Next program4Fast forward 15 seconds5Rewind 15 seconds6StopsEquals pressed in single button mode (see description for pi below)wEquals releases in single button mode (see description for pi below)
The pi is designed to be in a box. When the box lid is opened (the button is released) the pi should start playing.
The one button solution can recognize and handle the following patterns:
releasedwill start playingpressedstop playingsingle taptoggle pausedouble tapnext programtriple tapfast forward 15 secondsquadruple taprewind 15 seconds
alsamixer is a nice tool to set the volume and audio output from the terminal.
