Archive for the C.H.I.P. Category

Trials and tribs of RPi Audio

Posted in C.H.I.P., Docker, RaspingBreathburryDOodlePi, rhasspy trials and tribs on January 16, 2022 by asteriondaedalus

So, I have had this long winded task with the wife. She wanted wifi speakers (really BOSE), so I originally grabbed a couple of bar speakers from Target and installed shairpoint-sync on a couple of C.H.I.P.

Of course, she was not inclined to use it, and so her Apple ITunes account was not much use.

She then opted into getting a Spotity account, gave me a hook into it so I have my own song library.

I opted into looking into setting up the RPi 3 B+ home server with a spotify client, to play to the speaker that was previously driven by a C.H.I.P.

Found raspotify which ended up being a bit of a pain to get set up, but that was because, as it usually is, you might fiddle with the nuts’n’bolts of linux based audio once in a blue moon. So, yes, I had forgotten most everything I had worked out when getting the C.H.I.P. going.

The starting position was a hypriot based image on the home server (black-pearl) that had never really been set up for audio.

I had tried to get the audio to default to the headphones using sudo raspi-config, but while that made the headphones available, it did not select them for output??!!

It appears you still have to manually set up an alsa config file for the black-pearl thus:

#/etc/asound.conf
defaults.ctl.card 1
defaults.pcm.card 1

The “1” is because the headphones were setup as the second “card” per:

$ sudo aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: b1 [bcm2835 HDMI 1], device 0: bcm2835 HDMI 1 [bcm2835 HDMI 1]
  Subdevices: 4/4
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
card 1: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 4/4
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3

Adding to the confusion, the “help” at raspotify aimed that solution at a USB speaker, but it turns out the order of “cards” is really about how you setup the system.

As things were coming back to me, and I muddled through the setup to get Spotify going to the black-pearl host. YA FRACKING HOOOO!

I then cracked open a new RPi 3B+ I bought to drive the speaker bar in the main bedroom. Yes a RPi Zero would have done it, and would probably have been a better option, but you try buying one nowadays.

So, remembering I am building on a hypriot distro, I thought this time around I would look at how to setup the audio out of the box.

Recall the audio on the RPi wants desperately to drive up a wire in your HDMI port, and not out the audio jack. In the flash tool examples there was a file no-uart-config.txt. I worked through and ended up with the following which sets up your audio out to CARD 0 and does not include a HDMI card per se.

#no-uart-config.txt
hdmi_ignore_edid_audio=1
hdmi_ignore_hotplug=1
enable_uart=0
dtparam=audio=on

Works a treat, as evidenced by the following immediately after booting for the first time:

$ sudo aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 7/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7

Turned out then, if you flash a hypriot image with that version of no-uart-config.txt above, you have no fluffing around when using raspotify and simply need install it and it finds the audio no problem. As per the destructions at the raspotify site, bump your volume up with alsamixer.

For the record, the flash command was:

flash --userdata wifi-user-data.yml --bootconf no-uart-config.txt hypriotos-rpi-v1.12.3.img

So, I do also tend to use a static IP address for my hosts since, while it is apparently good practice to use cloud-init to the max, besides Android browsers, there are other apps (including the URL within rotten rhasspy) that don’t understand the Avahi provided local hostname resolution using a “<hostname>.local“. What worked for me then is the following changes to the wifi setup section of wifi-user-data.yml:

#wifi-user-data.yml
write_files:
  - content: |
      allow-hotplug wlan0
      iface wlan0 inet static
          address 192.168.1.131
          mask 255.255.255.0
          gateway 192.168.1.1
          dns-nameservers 192.168.1.1 8.8.8.8 8.8.4.4

      wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
      iface default inet dhcp
    path: /etc/network/interfaces.d/wlan0

Two raspotify clients!

Blowed if I know why the second raspotify (silver-pearl) has a different icon above? May have to do with it being the one I have a microphone currently attached to? It otherwise seems an amalgam of a speaker and a tv?

Regardless, that’s what you have to do to get the raspotify install to work “out of the box” … cringe.

One error in hindsight for the black-pearl host in the “asound.conf” file at the start, note the “defaults.pcm.card 1” is the headphones, the “defaults.ctl.card 1” will need revisiting, once the mic is added. Bet the “card” for the mic on the black-pearl ends up “2”. May need to clean the audio up on the original host, which may be a rip it all off and build it again … groan.

Now I also have decided to use the two RPi as rhasspy satellites, so much pain there I suspect. I am using my old 64bit PC as the main rhasspy host. Very fiddly setting up BUT will be fun.

For the wake word and spoken comments I needed and therefore bought me a pair of omni microphone from OfficeWorks.

Attached a mic to the silver-pearl host, which found the mic!

$ sudo arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: ATR4697USB [ATR4697-USB], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Then sorted out another file on the silver-pearl, so that the mic and headphones would work a treat. So asound.conf needed a little more love than the example at raspotify, thus voila!:

#/etc/asound.conf
pcm.!default {
  type asym
  capture.pcm "mic"
  playback.pcm "speaker"
}

pcm.mic {
  type plug
  slave {
    pcm "hw:1,0"
  }
}

pcm.speaker {
  type plug
  slave {
    pcm "hw:0,0"
  }
}

So that’s where I’m at, having test recorded and then replayed a wav.

I have just worked out I need go to the porcupine site to download wake word files to then upload to the two RPi satellites. Or at least as I think is the case, since the satellite are responsible for wake word detection.

So much to work out, to then forget again afterwards … groan.

POST SCRIPT

Wife no longer uses Spotify … groan. Has opted for streaming radio stations on the internet. Well, not stations, only one station. So, I am now trying to work out how to get a headless streamed internet radio station up. I was headless myself, when she told me … FRACK!

She’ll have to wait until I get the rhasspy stuff up and running. Might take a while …

Punked it!

Posted in C.H.I.P., Networking on July 30, 2017 by asteriondaedalus

So, the joke I had with Mike Brady, the chap who maintains shairport-sync, was that the problem I was having with dropping of audio was that I was listening to my wife’s punk music.

The acid test for the fix I have used (basic interpolation and longer background buffer) was to pump The Living End to two of the C.H.I.P.

Voila!

2rooms

Of course, Madam was too consumed by her Sunday afternoon sitting of Criminal Minds to appreciate the success … so she told me to turn off the Backroom link.

So, the one for her office is ready, just needs some fiddling to fit the speaker on top of the storage cabinet.

I am now looking at setting up one in the gazebo in the backyard and one under the veranda in the front yard (we have a pool area in the front).

Ah ha!

Posted in C.H.I.P., Linux on July 26, 2017 by asteriondaedalus

So.

I am now building the third C.H.I.P. with shairport-sync.

I went to look on the gateway admin page to check to see if the other two were still up.

Neither turned up in the wifi list.

Hmmm.

So I went to the iPad and sure enough, I could see and select the other two as Airplay targets.

So, I ssh’d in and I could connect to both  AND I could ping google.com from both.  That validates both that I can get out and the DNS setup is still working.

So, it looks like there is some bug in the gateway web admin since I can’t have internet access if something isn’t right.

Not sure if that relates though to the OPiZ story as that was definitely devices dropped.

Still, so many niggly confounding problems.

So, I will ignore them and build the third C.H.I.P. for Madam’s office.

What the!?

With the static IP set, the third C.H.I.P. can be seen on the gateway wifi list.  The only difference between the third C.H.I.P. and the other two is it is connected by USB to my PC for the setup.  Why on earth would that make a difference as to whether it is “seen” by the gateway list?

Okay, so I had deleted a network scanner off my Android phone when I found it had broken post an update.  I downloaded a new one tonight that similarly could only see the new C.H.I.P. attached to my PC???  I scrapped that one and downloaded yet another one and it could see all three C.H.I.P.???  Fracked if I know what is going on there.

Too dopey to bother with, no concern given I can still talk to board by USB and all other evidence is that, from the C.H.I.P. point of view everything is fine.

Hmmm

Posted in C.H.I.P., Linux, Orange Pi on July 22, 2017 by asteriondaedalus

So, here it is Sunday.

Morning coffee in hand while I wake up.

Dogs still asleep but will be doing backflips once they hear me getting their leads out for the Sunday bush walk.

OPiZ still up, node-red console full of reports of reboot every 5 odd minutes.

Since it has been in this reboot cycle since Friday night I am happy enough the nodejs, node-red, npm combo is not the contributing factor to the ethernet and usb stopping.

After the walk I will … well I will have a nap.  But after the nap I will … well I will build another C.H.I.P. with shairpoint-sync for the second sound bar.

Later tonight I might have another go at the emqttd install on the OPiZ.

I am still not sure how that might induce the dropping  of devices, but it in hindsight there is a conspicuous connection since the problems seemed to start once I had installed and was running the emqttd – that observation holds over the at least a dozen times I re-burnt then setup a distro for the OPiZ.

Curious, because these are the exact same steps to set up a Raspingdoodleburry Pi or ODROID-W with the same combo of app – neither with any problems with devices dropping.

Pump up the volume

Posted in C.H.I.P., Embedded, Linux on July 22, 2017 by asteriondaedalus

So Target had finally dropped prices of sound bars with aux input to AUS$49 so I can deal with the wife’s nagging about the BOSE wifi sound system with a $9 C.H.I.P. and a $49 sound bar.

Voila!

thomson

Perfect for the bedhead in the main bedroom and the window sill in the guest bedroom or in the book case in the wife’s study.

I only bought two as we had the speaker tower in the backroom.

Now, given all the problems I had with Armbian.com debian server distro and the OPiZ, here I am using nmcli to setup the static IP for the wifi on the C.H.I.P. with no problems.

Given I had the 3-pin serial cable out, I just swapped it over to the C.H.I.P. from the OPiZ.

I flashed with the headless server version 4.4 of for the C.H.I.P..

I used nmcli to setup the wifi using the provided example.

I then used “sudo nmtui” and setup the static ip and then reboot.

I found the device on my gateway list of wifi devices … bute!

To install shairpoint-sync I simply followed the instructions at Hackster.

The trick is where the instruction asks for interpolation to be set to soxr I reset it back to basic.  I also set the alsa property:

audio_backend_buffer_desired_length_in_seconds = 0.5 (it was set to 0.15).

I did this because the audio would drop out briefly.  Evidence is the soxr interpolation takes a grunting cpu and there might have been some network problems.  So, between relaxing the interpolation and buffering more audio, the dropping of audio apparently has ceased – much to Madam’s delight.

The nuisance, the wife has given up her iPhone for a Samsung S8 – which she doesn’t like.

I found you can get Airplay running on Android so we could get by.  I bought her a new laptop but she hasn’t moved her iTunes to that yet.

She hasn’t installed iTunes on the PC that I built her.  iTunes is on her old laptop so there are some politics there to get that transferred – especially as I have my eye on her old laptop to be my 64bit Debian dev box.

So while the Airplay route is “comfortable” it is rather “complicated”.

However, she has an iPad that she now hardly if ever uses so it can be the server for the house music.

Too easy drill sergeant!

Too easy, that is, because even though I am using a debian based distro on the C.H.I.P., and essentially using the same tools to set up the C.H.I.P. as I was the OPiZ, I am having no problems with C.H.I.P. headless server.

What?

Oh … yes, if she asks BOSE was bought out by Thompson.

 

 

Here’s the theory …

Posted in Arduino, Beaglebone Black, C.H.I.P., General niff naff and trivia on April 29, 2017 by asteriondaedalus

… straight forward really.

MOOS-IVP happily compiles and runs on on of my Beaglebone Blacks.

beagleboneblack-topweb

Sooooo, no stretch (pardon the pun) for MOOS-IVP to fit onto a C.H.I.P.!

 

Both are 1GHz processors with 512M of memory.

The standard approach, in any event, is run MOOS-IVP on the linux board and have an arduino interfacing with the hardware.

Of course, I am running against the AIO:

You could just as easily run against a raft of other boards, such as:

Or even a Parallax Propeller board!

That would all depend on what you are offloading to the hardware layer.

Xmas sales!

Posted in C.H.I.P. on December 20, 2016 by asteriondaedalus

Wow, a shield for your Arduino with Wifi and Airplay and Audio, down from AUS$159 to AUS$99 for Xmas!

Or just ask Mike Brady for Airplay on your US$9 C.H.I.P.!

No, not that “Mike Brady“.

Wow! An ESP-13 shield down from AUS$34.95!  Or a WEMOS D1 R2 for US$6.  US4.60 if you buy 5 at a time, and you get AUS$3.14 change from the price of the ESP-13.