ProDave

Cheap Internet radio wanted. Raspbery Pi?

Recommended Posts

I want to put together a cheap internet radio, to link to the hifi, the main objective to be to listen to Radio Caroline that is only available on the internet.

 

So it needs a computer connected to the internet with audio output.  A Raspbery Pi?

 

I want this to be a cheap one trick pony, just turn it on and it will connect and play audio from Caroline.

 

I am a Pi novice so don't have a clue which version of the Pi I would need and how one would even set this up.  Is it even feasible as a "switch on and go" setup?  (I don't want it connected to a screen and keyboard for anything other than configuring it)

Share this post


Link to post
Share on other sites

Just done this, built a single-channel, line out audio, internet radio, using a Raspberry Pi Zero W with a Phat DAC audio board.  When powered up it just connects to BBC Radio 4 via wifi and starts playing the stream, which feeds into the audio system.  The quality is pretty good, the only slight snag is that it takes around 30 seconds or so for the Zero W to boot up and connect to the stream.

 

I've probably scribbled down the details of the script I used somewhere, but if I didn't I can always SSH into the thing and copy it off.

Share this post


Link to post
Share on other sites
4 minutes ago, JSHarris said:

Just done this, built a single-channel, line out audio, internet radio, using a Raspberry Pi Zero W with a Phat DAC audio board.  When powered up it just connects to BBC Radio 4 via wifi and starts playing the stream, which feeds into the audio system.  The quality is pretty good, the only slight snag is that it takes around 30 seconds or so for the Zero W to boot up and connect to the stream.

 

I've probably scribbled down the details of the script I used somewhere, but if I didn't I can always SSH into the thing and copy it off.

That's exactly what I want to do. As a Pi novice I will no doubt need some help.  I do have a Pi kicking about, it's a model A iirc bought a long time ago for a project that never happened and has never been powered up. I will have to look at what it has and hasn't got to see if it is any good, otherwise buy the right one.

 

surprised it needs a DAC board, I just assumed as it was a "min computer" it would already have audio out.

 

It will be going in the same cupboard as the router, so a hard wired ethernet is available if that makes it simpler than a wifi connection.

Share this post


Link to post
Share on other sites

The audio out on the bigger Pi is pretty rubbish, IIRC it's not got a DAC, but just uses PWM to generate audio.  The cheap Pi Zero doesn't have even the crude audio that the bigger Pi has, but the Pi Zero W only costs £9.30 and the Phat DAC £13.25, so even with the cost of the header it's still cheaper than buying a Pi Model 3 at £34.00.

 

I wrote up the stuff I used to get a single channel internet radio running, it seems (getting old, forgot I'd documented it!):

 

Quote

Internet Radio setup – Raspberry Pi Zero W

 

Simple version

 

Uses a Raspberry Pi Zero W, fitted with a Phat DAC that just has a line out audio connection.

 

Load an image of Raspbian Stretch Lite to µSD and edit by adding an empty file with the title SSH to the /boot/ section.

 

Set up WiFi by adding a Unix text file (created with Notepad++) to /boot/ called wpa_supplicant.conf that contains the following (Raspbian copies this from /boot/ to /etc/wpa_supplicant/wpa_supplicant.conf on first boot):

 

(see code excerpt below - the forum screwed up the formatting)

 

Put card in Pi Zero W and boot.  Find IP address and SSH in using Putty.  Change default password to a new password (for username pi).  Update using sudo update.  Install driver etc for Phat DAC using the following command:


curl https://get.pimoroni.com/phatdac | bash

Install MPD and MPC to stream and play via the internet:

 

sudo apt-get install mpd mpc

 

Get the current radio stream URL from here: http://steveseear.org/high-quality-bbc-radio-streams/

 

Add the following lines to the bottom of the /etc/rc.local/ file, using nano (just before the exit 0 line):


sudo nano /etc/rc.local

mpc clear   #clears the MPC playlist

 

mpc add http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/ak/bbc_radio_fourfm.m3u8  #adds BBC Radio 4 in high quality

mpc play    #starts the stream playing

 

The Pi Zero W should now play Radio 4 as soon as it has booted and acquired the stream.

 

Note that if using Windows you need to use a text editor that can create Unix-like text files.  Notepad++ works well and is free.

 

PS: Note also that Unix-like text files don't format properly in the quote function of this forum.  Here it is as a code insert (note that the SSID and password needs the inverted commas around them):

 

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
    ssid="your network SSID"
    psk="your network PSK password"
    key_mgmt=WPA-PSK
}

 

PPS:  If you have wired Ethernet, then you can use a USB to Ethernet adapter plugged in to the µUSB port on the cheaper Pi Zero (rather than the Pi Zero W).  The Pi Zero is a fiver, IIRC.

Share this post


Link to post
Share on other sites

@ProDave did you ever get a chance to have a look at that internet radio I dropped off some time ago - just wondering if you could cannibalise anything from that?

Share this post


Link to post
Share on other sites
46 minutes ago, Stones said:

@ProDave did you ever get a chance to have a look at that internet radio I dropped off some time ago - just wondering if you could cannibalise anything from that?

I have spent hours on that. It works in short bursts, and that has whetted my interest in getting something to listen to Radio Caroline.  But I can't find any service information and am convinced I am never going to get that one working, hence this project.

Share this post


Link to post
Share on other sites

I have just found the Pi that I have.

 

I did say it was the basic version available when it was bought at least 5 years ago.

 

It appears to have 2 USB connectors, a mini one labelled "PWR" and a full sized one.  It has what looks to be an hdmi or similar socket. A yellow phono socket and blue 3.5mm jack socket (which I had thought would be audio out)

 

It does not appear to have a network socket. So it might not be any good for this.

 

There is an 8GB memory card plugged in, and when I put that into a card reader on the laptop it appears to be empty at the moment.

Share this post


Link to post
Share on other sites

Not sure what Pi that is, TBH, but here's the parts needed to build a pretty cheap internet radio with hifi quality audio (you'll need a 5 V power supply)

 

Pi Zero, £4.66:  https://shop.pimoroni.com/products/raspberry-pi-zero

 

Micro USB to Ethernet adapter, £3.30: https://www.ebay.co.uk/itm/5-Pin-micro-usb-2-0-to-RJ45-LAN-ethernet-network-adapter-100mbps-for-tablet-AL/264224644254?hash=item3d85041c9e%3Ag%3Ad5sAAOSw2gNb6UVs&LH_BIN=1

 

Phat DAC, £13.25: https://shop.pimoroni.com/products/phat-dac

 

Header, £1.00:  https://shop.pimoroni.com/products/male-40-pin-2x20-hat-header?variant=10476117383

 

You'd also need a micro SD card, 2Gb is plenty big enough to take Stretch Lite.

Share this post


Link to post
Share on other sites

The Pi I have is the opriginal Pi 1 model A https://www.raspberrypi.org/model-a/

 

And https://www.raspberrypi.org/blog/model-a-now-for-sale-in-europe-buy-one-today/

 

no ethernet port but it makes reference to using it with a wifi dongle.

 

However I don't think it has the HAT connector so I am probably flogging a dead horse trying to use this one.

Share this post


Link to post
Share on other sites

You could use a chrome cast audio and a mobile phone. 

https://www.mymemory.co.uk/google-chromecast-audio.html

For £20 you can't beat the value of these things. High quality output too, I use one to stream radio and personal cloud based audio through my hifi. Very easy to use and handy to be able to control everything via a phone. 

Share this post


Link to post
Share on other sites

I have come across the Pi Music Box https://www.pimusicbox.com/

 

I will give that a try on the Pi that I have once I get a network adaptor for it.

Share this post


Link to post
Share on other sites
21 minutes ago, ProDave said:

I have come across the Pi Music Box https://www.pimusicbox.com/

 

I will give that a try on the Pi that I have once I get a network adaptor for it.

 

Depends how you want to control it, or whether you need to control it at all, really.  I just wanted a simple device that had no controls and needed no form of interface to work. 

 

All mine does is start playing Radio 4 (could be any stream you like) shortly after it's powered up.  I didn't need a built-in interface (which would cost far more than all the other components put together), and definitely didn't want to have to power up a PC, tablet or whatever just to listen to the radio, so I opted not to go for something like Pi Musicbox, just to keep things really simple.  It doesn't get much simpler than just having something come on when you turn the power on.

Share this post


Link to post
Share on other sites

That Pi Music box has a web interface.  I am assuming once you have logged in and selected an interned radio channel it will continue playing that forever until you tell it to play something else.

 

I don't expect to be using the interface very often.

 

I am expecting the "music" Pi to be powered up 24/7

Share this post


Link to post
Share on other sites

so streaming 24/7 regardless of actual useage?

Share this post


Link to post
Share on other sites
2 hours ago, Miek said:

You could use a chrome cast audio and a mobile phone. 

https://www.mymemory.co.uk/google-chromecast-audio.html

For £20 you can't beat the value of these things. High quality output too, I use one to stream radio and personal cloud based audio through my hifi. Very easy to use and handy to be able to control everything via a phone. 

This would be my approach too (given I already have a few Chromecast audios)

 

To avoid fiddling with a phone (or shouting at Siri), I would use my server that is on 24/7 anyway to watch for the chromecast to powering. on and automatically send the cast command to it using https://github.com/barnybug/go-cast (or with home assistant if feeling fancy).

 

In fact, this thread has inspired me to give that a go. (~10 years ago I used my squeezebox as an alarm clock on R4 for much the same purpose. I still have the squeezebox, but their server software is a pile of steaming Perl and I have no inclination to going back to running it)

 

 

Share this post


Link to post
Share on other sites
47 minutes ago, ProDave said:

That Pi Music box has a web interface.  I am assuming once you have logged in and selected an interned radio channel it will continue playing that forever until you tell it to play something else.

 

I don't expect to be using the interface very often.

 

I am expecting the "music" Pi to be powered up 24/7

 

 

The snag with that is the bandwidth the thing will use when you aren't listening to the audio from it.  If you have enough broadband capacity for this not to be a concern, then this is fine, but I prefer being able to shut the stream off when I'm not listening to it, as our broadband isn't that great and there are times when we need all the bandwidth we can get.

 

The other thing with leaving the stream on is that there's a reasonable chance that it will just stop.  One thing that bugs me with internet radio in general (and as well as the Pi Zero we have a Roberts internet radio) is that the stream can just glitch from time to time.  The Roberts recovers from stream glitches within 30 seconds or so, the Pi Zero needs rebooting to recover (takes around 30 seconds too).  This doesn't happen that often, but often enough that if I had to fire up a PC and log in to the thing to get it running again it would annoy the living daylights out of me.  Turning it off and on again is the lesser of two evils, and something I may well fix sometime by detecting the stream going down and making it automatically restart.

Share this post


Link to post
Share on other sites

We get about 3MB download, so the audio stream is not going to use more than 10% of the bandwidth if left on.

 

when I was trying to get the one from @Stones working, when it was working for a short while that was left on 24/7 with no noticable difference to general interned performance. But judging by how hot it got, I am sure it used more power than a Pi will.

 

I can't now do any more for a couple of days until the USB - Network adaptor arrives.

Share this post


Link to post
Share on other sites

Could you do it with an old mobile phone and a cable? Must be loads of Internet Radio Apps.

Share this post


Link to post
Share on other sites

Okay some help needed from Pi / Linux experts.

 

So I have downloaded the image file for the Pi Music box.  I followed the instructions to copy the image file to my SD card.  At the end of the process it told me it had coppied 892 MB.  I did the copying using my Ubuntu laptop and with the card plugged into a USB card reader.

 

After the copying, Ubuntu does not recognise the memory card any more and does not see it.

 

I tried the card reader into the windows PC and it sees 4 empty volumes.

 

Oh well I plugged the memory card into the pi, connected the hdmi socket to a tv and powered up the Pi hopefully expecting to see some boot up messages giving me some confidence that the image has worked and the Pi is booting up. But all I get is a blank hdmi raster.

 

I feel I am "somewhat in the dark"  I obviously can't try connecting to the Pi Music player via the web interface until I get the network adaptor, but it would have been nice to have had some assurance the first part of the process had worked.

Share this post


Link to post
Share on other sites

There's a good chance that the Pi Music box version of Raspbian (I'm guessing it will be a cut down version of Raspbian) may not natively have an enabled desktop.  Might be worth trying to load an image file of Raspbian to the SD card and see if that boots, as by default the "full fat" version of Raspbian has a desktop and keyboard/mouse interface.

 

Best bet once you can connect it to Ethernet is to SSH into it and see what's going on, but there's a trick needed to do that.  By default, newer versions of Raspbian (and I'd guess variants of it) don't enable SSH, so you need to create an empty file in the root directly of the SD card called SSH (no suffix).  You can create this file using Notepad on a Windows machine, just save an empty file as SSH, then edit it to remove the .txt extension.  When the SD card is put into the Pi and booted it will automatically enable SSH and delete the blank file.

 

Having done this, you should be able to connect to the Pi by finding it's IP address on your router, then using a terminal programme, like PuTTY, to SSH in and see what's going on from the command line.

 

I have a feeling that there may be a way to SSH in to a Pi from USB, but it's not something I've done, as all mine have Ethernet.  Might be worth digging around on the Pi support forums to see if you can find anything out about using USB to connect to a Pi directly.

 

 

Share this post


Link to post
Share on other sites

I feel near certain the process of imaging the memory card has not worked. And feel frustrated at my lack of knowledge.

 

These are the instructions I used https://elinux.org/RPi_Easy_SD_Card_Setup#Flashing_the_SD_Card_using_Windows

 

Near the bottom, the section that starts "flashing the memory card using linux"

 

I wanted to use the GUI method they suggested using "Image Writer" unfortunately the Ubuntu software centre denies any knowledge of that existing. So I used the command line method.

 

That starts by unmounting the card (umount /dev/sdd1)  Then copying the image file with the DD command.  That appeared to work.

 

I would have expected to have mounded the card again at the end of the process but no mention to do that.

 

I am convinced that step is needed because now ubuntu does not see this memory card in it's file manager (so I could not even try as you suggest as you say re SSH if I cannot see the card and write to it)

 

I only put the card into the Pi as a matter of desperation to prove it had worked and was not surprised that it seems dead.

 

So thinking the card needs to be mounted, and not knowing the format for the mount command, I have tried the obvious "mount /dev/sdd1" but it says "can't find /dev/sdd1 in /etc/fstab or /etc/mtab

 

Getting frustrated.

Share this post


Link to post
Share on other sites

I think you may well be on the right track, as RPi's do seem a bit sensitive to the way that the SD/µSd card is imaged.  Part of the problem seems to be that the card seems to have a Windows-compatible partition, AFAICS, so isn't wholly formatted as a Linux-like file system.  I believe this was done to allow Windows users to be able to access the boot part of the file system, but may be wrong.

 

The SD card section of this page may help, as you can write the image to the SD card using dd from the command line, which should faithfully create it on the card OK: https://www.raspberrypi.org/documentation/linux/filesystem/backup.md

 

 

Share this post


Link to post
Share on other sites

That's interesting.  It makes no mention of unmounting before using the DD command.  Perhaps the "mistake" was me reading those other instructions and unmounting the card?

 

How do I get it back to square 1 so I can at least read the card again on the ubuntu PC?

Share this post


Link to post
Share on other sites

Okay got it sorted.

 

I had copied the image to /dev/sdd1 whereas I should have copied it to /dev/sdd

 

Now I can read the copied image and see all the files and the good news is the Pi is working and you see it booting up via the hdmi output.  Of course it now reports a "network timed out" error as there is no network adaptor yet.

Share this post


Link to post
Share on other sites

So I have the Pi, I have sorted the memory card programing, I have ordered the network adaptor. All  I need is a DAC board.

 

The pHAT DAC linked above has a 40 pin header, as do modern versions of the Pi.  but mine being an old Mk1 only has the original 26 pin header.  As I undrstand it this DAC works over the I2S lines, which are on the original 26 pin header, so I see no reason why a pHAT DAC would not work if I just fit a 26 pin header to it.  But the supplier linked to above says it won't work.

 

I have however found this one that clearly only has the 26 pin header so should work, but not yet found a UK supplier so may just have to wait for it from China https://www.ebay.co.uk/itm/HIFI-DAC-HIFI-Audio-Sound-Card-Module-I2S-Interface-For-Raspberry-Pi-B-Black/292203010088?hash=item4408a81828:g:Jz0AAOSwJLJZguV4

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now