![]() |
||||||||||||||
Home | Spelletjes | Uitvindingen | Gps | Scouting | Meteo | Computers |
||||||||||||||
Ict / Internet Radio Using The Raspberry Pi | Menu | |||||||||||||
Build your own very simple to use Internet RadioLevel: Experienced
My mother is 97 years old, she is not only almost blind, she also has increasing difficulties to control her radio set. What she needs is a very simple one-button radio, which she can push if she does not like the station that is on now. Pushing that button will switch to the next pre-programmed radio station. What you need
Install the Raspberry Pi Operating systemYou will need some basic Linux skills to be able to make the Raspberry Pi to operate. Write a Linux image on you SD-card, plug it into the Raspberry Pi, connect the monitor with the HDMI cable, and plug in the power-supply. Follow the instruction on the screen. I will not go into detail on that, it is documented well on raspberrypi.org. You can do with a cli-only version, a desktop is not necessary for this application. Get back here after you made Linux run on you Pi. ![]() HardwareOn the picture you see the Raspberry Pi with the LCD display attached to it. Note that between the LCD display and the metal connectors a piece of isolating tape must be attached to prevent a short circuit. A power-cable, a loudspeaker cable and a network cable are connected. Note the four buttons, wires will be soldered to connect with the external buttons on the front panel. Turn the copper screw (on the blue potentiometer) until the characters become visible on the LCD screen. Installing the toolsWhen you want to run an Internet Radio means you have to have some software that can receive and play the stream that is sent by one of the very many radio stations on the Internet. Linux provides many solutions to that, I chose to use mpd, the Music Player Daemon. Mpd is capable to open a music-file or music-stream from somewhere on the Internet, and play it. Mpd has no fancy interface, in fact it has no controls at all. It runs in the background, continuously and invisible to the user. That is why it is called a daemon, no-one can see it but it is there. You will need a separate piece of software to be able to control this daemon. This tool is called a client. Mpc, the tool that we are going to use is such a client. There are many clients available, see the listing here. Some clients are very fancy, they have the looks of a modern juke-box, and some are sober. To install type Mpc can only be operated from the command line.
Nevertheless it is a very powerful tool.
For instance, The script that I wrote will call mpc together with an argument, according to the specific button pressed, and will send the textual output to the LCD display. ConfiguringYour Raspberry Pi should now be up and running.
From now on it is save to disconnect the HDMI, and do all work from my desktop computer through a ssh-connection.
I use MpdNormally the working files for mpd are stored in mkdir -p /home/pi/mpd sudo cp -a /var/lib/mpd/music /home/pi/mpd/ sudo cp -a /var/lib/mpd/playlists /home/pi/mpd/ sudo chown -R pi:pi /home/pi/mpd Then, edit mpd's configuration file by typing music_directory "/home/pi/mpd/music" playlist_directory "/home/pi/mpd/playlists" Restart mpd: PlaylistSearch around the Internet for your radio-stations.
Then create your playlist by typing http://streams.greenhost.nl:8080/klassiek http://74.208.197.50:8020/;stream.mp3 for two stations, and so on.
Add or change these for your favorite stations.
Restart mpd: mpc ls mpc load stations mpc playlist # should list both stations mpc play 1 mpc play 2 should play the first and then the second radio station in the playlist.
Stop playing by typing SoftwareDownload Internetradio and copy to sudo cp ~/Downloads/Internetradio /usr/local/bin/internetradio chmod +x /usr/local/bin/internetradio and run it: The functions of the buttons are:
HardwareFinally you have to build a case, and do the wiring. In the picture below you see the back with the LCD panel and the switches. The Raspberry Pi will be connected to the LCD panel shortly after taking this picture. Note the soldered connections on the back of the switches on the LCD panel. ![]() And here you can see the front of the radio. Note the big labels near the buttons to help the visually disabled radio-listeners. ![]() Extra'sIf you already have a server with loudspeakers attached to that,
you can use that one to play your Internet radio-stations.
Mpc and mpd can run on different machines (preferably within the same local network).
Simply install mpd on that server
(Linux and Windows binaries available),
and edit the internetradio python-code on your Raspberry Pi.
Change the word You can open port 22 on your internet router to be able to remotely login on the internetradio in case of problems,
or on demand to play one of my mothers favourite CD's that I put in the music-directory. Starting and stoppingThis is done in user pi's crontab. At 8 in the morning internetradio is started, and at 23 in the night stopped. Also, every hour a test for a running internetradio-process is done, if not it will be restarted. # crontab # Enter these lines after 'crontab -e' # m h dom mon dow command 00 8-22 * * * ps -ef | grep internetradio | grep -v grep || /usr/local/bin/internetradio 00 23 * * * ps -ef | grep internetradio | grep -v grep | kill $(awk '{ print $2 }') ; mpc stop An example: If you want to hear the news on the third station in the playlist at 6pm every weekday, add this line in the crontab: 00 18 * * 1-5 mpc play 3 Note that the display does not change accordingly! Known problems
Commercial infoI bought the Raspberry Pi and parts at Conrad.nl. Conrad sells the display completely assembled an ready to use. On their site you will find four pdf-files with programming examples.
hans puts - 22-02-2018
![]() nazz - 03-10-2017
![]() Ik ben geen nerd heb een piplate lc 16x2 met 5 druk toestsen wil mijn eigen internet radio stations beluisteren. Ik kom er niet uit... kun je een stappen plan maken. Het lukt mij niet op de LCD stations zichtbaar te maken en aan de hand van de toetsen de volgend station .. Nazz Antwoord: De Pyplate is anders dan de Adafruit LCD. Je moet zelf uitzoeken hoe je dit display aanstuurt en dan de code aanpassen |
Departementen |
|||||||||||||
Top | Bekijk | Afdrukken | Zoek Pagina gewijzigd op 11 maart 2019 om 19:42 |