Pi Zero W, Pirate Radio and the PhatBeat

I added the mopidy user to the gpio group to no avail.

When I play a sound with aplay the vu meter works fine, and I’ve set up mopidy to use alsa, so a mystery?

without looking at your project in detail it is hard to tell what could be wrong - but if aplay works fine it is almost certain to have to do with the user context.

Note that above post specifically was resolved by adding user mpd to group gpio, not user mopidy. Whichever is right (including, possibly another suspect) will depend on your use case.

Hi again,

I tried mopidy as suggested above by @gadgetoid (following the tutorial by @sandyjmacdonald on mopidy + spotify, i.e. spotipy script). I have managed to get mpd running and configured on a zero before (with phat dac), but am not able to get mopidy going… it seems.

None of my mpd clients (MPdroid on Android, Ario on Linux nor MPoD on iOS) recognise the mopidy mpd extension. I can find no other way to start mopidy and load my playlist. The playlist only contains internet radio streams so it is relatively short. I plan to use the zero (non-W) + phat beat to stream internet radio in the garage, no local music access (nor spotify) is needed.

Mopidy conf output below:

[core]
cache_dir = /var/cache/mopidy
config_dir = /etc/mopidy
data_dir = /var/lib/mopidy
max_tracklist_length = 10000
restore_state = false

[logging]
color = true
console_format = %(levelname)-8s %(message)s
debug_format = %(levelname)-8s %(asctime)s [%(process)d:%(threadName)s] %(name)s\n  %(message)s
debug_file = /var/log/mopidy/mopidy-debug.log
config_file = /etc/mopidy/logging.conf

[audio]
mixer = software
mixer_volume = 35
output = autoaudiosink
buffer_time = 

[proxy]
scheme = 
hostname = 
port = 
username = 
password = 

[iris]
enabled = true
pusherport = 6681
country = NZ
locale = en_NZ

[local-images]
enabled = true
library = json
base_uri = /images/
image_dir = 
album_art_files = 
  *.jpg
  *.jpeg
  *.png

[ttsgpio]
enabled = true
debug_gpio_simulate = false
pin_button_main = 6
pin_button_next = 5
pin_button_previous = 13
pin_button_vol_up = 16
pin_button_vol_down = 26
pin_play_led = 20
tts_default_volume = 2

[local-sqlite]
enabled = true
directories = 
  Albums                  local:directory?type=album
  Artists                 local:directory?type=artist
  Composers               local:directory?type=artist&role=composer
  Genres                  local:directory?type=genre
  Performers              local:directory?type=artist&role=performer
  Release Years           local:directory?type=date&format=%25Y
  Tracks                  local:directory?type=track
  Last Week's Updates     local:directory?max-age=604800
  Last Month's Updates    local:directory?max-age=2592000
timeout = 10
use_album_mbid_uri = true
use_artist_mbid_uri = false
use_artist_sortname = false

[mpd]
enabled = true
hostname = 127.0.0.1
port = 6600
password = 
max_connections = 20
connection_timeout = 60
zeroconf = Mopidy MPD server on $hostname
command_blacklist = 
  listall
  listallinfo
default_playlist_scheme = m3u

[http]
enabled = true
hostname = ::
port = 6680
static_dir =
zeroconf = Mopidy HTTP server on $hostname

[stream]
enabled = true
protocols = 
  http
  https
  mms
  rtmp
  rtmps
  rtsp
metadata_blacklist = 
timeout = 5000

[m3u]
enabled = true
base_dir =
default_encoding = latin-1
default_extension = .m3u8
playlists_dir = /var/lib/mopidy/playlists

[softwaremixer]
enabled = true

[file]
enabled = true
media_dirs = 
  $XDG_MUSIC_DIR|Music
  ~/|Home
excluded_file_extensions = 
  .jpg
  .jpeg
show_dotfiles = false
follow_symlinks = false
metadata_timeout = 1000

[local]
enabled = true
library = json
media_dir = /var/lib/mopidy/media
scan_timeout = 1000
scan_flush_threshold = 100
scan_follow_symlinks = false
excluded_file_extensions = 
  .directory
  .html
  .jpeg
  .jpg
  .log
  .nfo
  .png
  .txt

[alsamixer]
enabled = true
card = 0
control = PCM

[spotify]
enabled = true
username = martin@nidingen.com
password = ********
bitrate = 160
volume_normalization = true
private_session = false
timeout = 10
allow_cache = true
allow_network = true
allow_playlists = true
search_album_count = 20
search_artist_count = 10
search_track_count = 50
toplist_countries =

As far as I can tell, my /etc/mopidy/mopidy.conf and local conf file are the same (although the local one was not configured properly using the install script).

In fact, I cannot get Iris to connect either… which is strange, mopidy is running, which “top” also verifies (it really should it starts on reboot, enabled via systemctl).

Any tips?

Edit: realised there is a test.sh for the phat beat. The output is here:

testing audio

speaker-test 1.0.28

Playback device is default
Stream parameters are 48000Hz, S16_LE, 2 channels
WAV file(s)
ALSA lib pcm_direct.c:1539:(_snd_pcm_direct_get_slave_ipc_offset) Invalid value for card
Playback open error: -2,Filen eller katalogen finns inte

testing basic wav playback

ALSA lib pcm_direct.c:1539:(_snd_pcm_direct_get_slave_ipc_offset) Invalid value for card
aplay: main:722: audio open error: Filen eller katalogen finns inte

testing gpio control...
press all buttons along the side of the pHAT...
press the power button on the pHAT to exit...

testing VU meter

Seems there is something wrong, but can’t figure out what (I did not go the vlc route, but the spotipy installer ran through w/o errors). The VU meter seems to work fine, half of the leds are green, other half red (until I terminated script).

if the modipy server is running then the (audio) test cannot run. You must disable it using sudo systemctl disable mopidy (just stopping the service is not enough, IIRC). This will only tell you whether your soldering job is good though.

I see at least one error in your config:

hostname = 127.0.0.1

… try hostname = :: instead

if you cannot get Iris to log you into the spotify frontend though there is probably something else going on.

One point though, you say that the ‘local config file’ is the same… if you are talking about what is generated by mopidy config then no, it wouldn’t be, but it has zero relevance in a server context, which is why it does not exist out of the box after running our installer (which provides an ‘always on’ server).

So if you generated one, by running the command above, then know that editing it will never have any effect (unless you disable the mopidy service as per command in my opening paragraph, and start mopidy manually - which will then be ran as pi, or whatever user you are logged as).

I hope that clarifies how things work (or at least my understanding, from hours of fiddling around with it, as well as reading the doc).

one way to debug your problem btw, is to ssh into the box and check the output of:

sudo service mopidy status
… it usually logs any important issues inline.

If that does not reveal anything bizarre then check the log at /var/log/mopidy/mopidy-debug.log which should hopefully have more details that may help you figure out why you are not able to connect the way you expect (using Iris on port 6680, or a mpd client on port 6600 presumably)

About the ip adress in config, I consulted the Mopidy docs before leaving it at the default value:

mpd/hostname
Which address the MPD server should bind to.

127.0.0.1
Listens only on the IPv4 loopback interface

I understood that leaving the adress at 127.0.0.1 would leav all IPv4 adresses open. I might have misunderstood, will definitely try ::.

Regarding “mopidy conf” I understood at first it was a config editing utility. Turned out it was not… but I never realized it created the local config files, although I did wonder why they would be there in the first place.

I did run the status check and this came out:

sudo service mopidy status
● mopidy.service - Mopidy music server
   Loaded: loaded (/lib/systemd/system/mopidy.service; enabled)
   Active: active (running) since ons 2017-03-29 14:39:21 UTC; 2h 25min ago
 Main PID: 949 (mopidy)
   CGroup: /system.slice/mopidy.service
           └─949 /usr/bin/python /usr/bin/mopidy --config /usr/share/mopidy/c...

mar 29 14:39:58 guderian mopidy[949]: INFO     Loaded 0 local tracks using json
mar 29 14:39:59 guderian mopidy[949]: INFO     Starting Mopidy core
mar 29 14:40:00 guderian mopidy[949]: INFO     Logged in to Spotify in offl...de
mar 29 14:40:03 guderian mopidy[949]: INFO     Logged in to Spotify in onli...de
mar 29 14:40:31 guderian mopidy[949]: INFO     Starting Mopidy frontends: I...nd
mar 29 14:40:31 guderian mopidy[949]: INFO     Starting Iris 2.13.7
mar 29 14:40:36 guderian mopidy[949]: INFO     MPD server running at [::fff...00
mar 29 14:40:36 guderian mopidy[949]: INFO     Starting GLib mainloop
mar 29 14:40:36 guderian mopidy[949]: INFO     HTTP server running at [::]:6680
mar 29 15:07:24 guderian mopidy[949]: sh: 1: festival: not found
Hint: Some lines were ellipsized, use -l to show in full.

i’ll check the debug log as well.

As always, super thanks for all help!

Edit:

Updating to :: (from 127.0.0.1) AND uncommenting a few things in mopdiy.conf solved part of the trick. Iris not connects. And Ario seems too (MPoD might be, but is not very communicative so hard to know given the stuff I describe below).

But, my playlists in /var/lib/mopidy/playslists/ do not show up in any client… so although I can now connect to mopidy I cannot play my radio station list, rendering that success pretty much useless (for the time being).

Thanks again.

A post was split to a new topic: Pirate radio crashing after 2 minutes

So, question: I’ve run the airdac installer but buttons on phatbeat aren’t working


I’ve run test.sh and buttons are recognised, but there’s no phatbeatd service running and sudo service phatbeatd start throws up a ‘Failed to start / No such file’ error … help?

you are confusing 2 different scripts, airdac is a shairport-sync airplay daemon, it has no vocation to provide button support since you will be controlling playback from your phone or tablet.

phatbeatd is a custom daemon specifically for the vlcradio project found in the phat-beat github repo, see instructions there.

… technically both daemons could coexist though, so in theory it should be posssible to have both running at the same time, doing their job. Still they don’t aim to provide the same functionality.

OK, thanks - so I could write my own script to look out for the power button being pressed (only interested in being able to cause a safe shutdown)?

what are you trying to do? if you only want soft shutdown try:

curl get.pimoroni.com/cleanshutdown | bash

the pin to use is bcm12 so when prompted, type ‘12’.

1 Like

Exactly what I was after, thanks!

Hello! I’ve got my pirate radio up and running with VLC, but I can’t seem to add my own radio stations.

I tried creating the playlist.m3u file in /home/pi/.config/vlc/, and the new station showed up for a moment (on the web interface) and then disappeared when I tried to play it.

Then I tried adding my station to the default.m3u file, and it didn’t show up. I also tried copying the default stations to my playlist.m3u file and adding my new one. The new one showed up but then disappeared when I tried to play it. The default ones work just fine.

What should I try next? Any ideas would be appreciated.

Ahh, never mind. I just had to find a streaming URL that would work (and I finally did). VLC fails in many different ways when it can’t deal with a station, I guess.

Hi all,

I’ve just built my shiny new pirate radio, followed the instructions and used the installer here: https://learn.pimoroni.com/tutorial/sandyj/internet-radio-on-your-pirate-radio

And it all seems to have run successfully (no error messages), however I’m not getting any response from my radio, other than one loud ‘pop’ when I press the >> button. I’m not getting any lights, or any other sound.

I’m logged in via ssh so it’s on the wifi, what am I doing wrong? :/

[edit: I’ve pinged Google.com and I get a response. I also noticed that there was no playlist file in /home/pi/.config/vlc so I’ve created that, rebooted, still dead - no lights, no sound, only a ‘pop’ on pressing >>]

[Further edit: I have just followed this process


with the same result]

Thanks,
Lou

Hi pirates,

I have got a problem regarding Mopidy. I have tried the VLC Radio project and it worked perfectly. So I wanted to try Mopidy, since it has many more features. But I have got some problems installing it and setting everything up. It goes until “Configuring Mopidy” and then I get error messages.

ERROR failed to load extension iris: No module named spotipy

Then, Mopidy is not even starting. I have tried in several times and could not figure out the problem. The problem is even reproducible. It also occurs on the other PIs I have. Hopefully someone can help me.

Aha, finally I figured out the problem myself. There is an issue with the Iris extension. Other then that everything was fine but Mopidy could not start because of this issue with Iris.

Hi there,

Does anyone have any ideas how to help me find the issue?

Lou

I suggest anybody frustrated with the tiny buttons on the pHat Beat have a go at wiring up some bigger easier to push buttons. My Pirate radio is in a wooden subwoofer box. I mounted some mini arcade buttons in the top and wired them to a Proto pHat board. Then just jumper wired them to appropriate GPIO pins. The GPIO used by each button on the pHat Beat is marked on it next to the buttons. The other contact on the button/switch just goes to ground. No coding required.
Pictures of what I did here, https://1drv.ms/f/s!AjOYwiwlwDtpgrJY6ORLsK5AVpwNuw

Hi, I’m new here but could really use some help. I purchased a pirate radio and soldered everything and loaded Rasperian Jessie onto my SD Card and I get no picture, its like the Pi isn’t getting power…I had our maintenance guy at work check my soldering and everything is good he even checked them with a voltage meter. also when I have the pirate radio plugged in I can feel the device heat up so I feel confident that its getting power but I get nothing. I even went out and bought another raspberry pi and put my SD Card into it and got it to load no problem (I was unable to log in using the “pi” and “raspberrypi” as the password but that’s another question all together.) Anyway my SD Card works, my soldering looks good, the power adapter works on with a raspberry Pi 3 running retropie with 2x Xbox 360 controllers so I think I’m getting plenty of power. Can anybody help?

Thanks

Jeff