Gizmo Furby, speak my pretty
2017-Dec-17, Sunday 02:35 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
After disassembling Gizmo I found I needed to remove, and discard, some stuff.
The Back pet button is a custom switch, and would be cool but is a bit in the way. Unscrew the metal bit attached to the yellow wire, remove it. A black plastic bit will come loose from underneath, then the metal bit attached to the green wire will come off.
Cut the Gear control wires and remove the LED. The matching LED is still attached to the old circuit board, so no use to us.
I trimmed down (with some snips);
The white plastic shaft that contained the spring.
The black shaft which held the screw to attach the old circuit board.
The black spacing column (middle-ish, towards hinge), but be careful, there's a metal pin inside almost full length.
Remove the Belly rub button enclosure, and snip the two melted plastic parts that keep the Speaker in. Cut the Speaker wires, and discard. (We'll be using the new speaker with the Speaker pHAT.)
Now, some assembly; the brain transplant.
Solder a male-male header to your the Raspberry Pi Zero W. Typically they are soldered to the top, but as you'll see later I soldered mine to the bottom (accidentally, but it worked out).
Don't solder headers onto your Speaker pHAT. To save space it will be soldered directly onto the Raspberry Pi Zero W headers. The speaker is supposed to be soldered to solder-pads on the bottom of the Speaker pHAT board. We will instead solder wires to the solder-pads so that we can place the speaker in the gap left by removing the old speaker from the Tummy rub button assembly.
If you soldered your Pi headers to the top, the Speaker pHAT will go on top of the Pi. So make sure you solder the speaker wires on before you solder the Speaker pHAT to the Pi. Also, make sure you add some insulation tape between the two boards.
If you soldered your Pi headers to the bottom, the Speaker pHAT will go on bottom of the Pi. Before you do, attach the four plastic screws meant to hold the speaker in place to the Speaker pHAT (attaching nothing but the plastic nuts). You can use these as spacers between the two boards to prevent shorts. (The excess parts of the screws will need to be trimmed afterwards.)
It's always a good idea to test as you go. So now is the time to setup your Raspbian OS, configure network access, and enable ssh. You'll also want to install everything you need to use the Speaker pHAT, so;
Once installed verify everything is working;
You should see output like;
You can also;
And you'll get something like;
You can use this information to find the path to your audio device status file. Here it is card 0, device 0, subdevice 0. So the path will be;
With no sound playing you should get output of;
But I ran into the problem that my device, my speaker, was supposedly always on. I always got output that began;
This is problematic for a later step, so I spent some time trying to figure out what was going wrong. It appears that PulseAudio is configured (by the Speaker pHAT installation) to keep the device running in order to minimise speaker pops/clicks. But we need to know when sound is playing and when it's not, so we need to edit the configuration.
Find the line;
and comment out the timeout section. Reload/reboot, and the changes will take affect. You can now
You can test this with two ssh sessions. In one
(you need to be in the directory because paths in the script are relative)
And while the script is running through the audio samples, in your first session
Part 1 | Part 2 | Part 3 | Part 4 | Part 5
The Back pet button is a custom switch, and would be cool but is a bit in the way. Unscrew the metal bit attached to the yellow wire, remove it. A black plastic bit will come loose from underneath, then the metal bit attached to the green wire will come off.
Cut the Gear control wires and remove the LED. The matching LED is still attached to the old circuit board, so no use to us.
I trimmed down (with some snips);
The white plastic shaft that contained the spring.
The black shaft which held the screw to attach the old circuit board.
The black spacing column (middle-ish, towards hinge), but be careful, there's a metal pin inside almost full length.
Trimmed internals where circuit board used to be
Photo by chebe
Remove the Belly rub button enclosure, and snip the two melted plastic parts that keep the Speaker in. Cut the Speaker wires, and discard. (We'll be using the new speaker with the Speaker pHAT.)
Back of Tummy rub button and Speaker enclosure
Photo by chebe
Tummy rub button and Speaker enclosure opened, next to Speaker pHAT speaker
Photo by chebe
Now, some assembly; the brain transplant.
Solder a male-male header to your the Raspberry Pi Zero W. Typically they are soldered to the top, but as you'll see later I soldered mine to the bottom (accidentally, but it worked out).
Don't solder headers onto your Speaker pHAT. To save space it will be soldered directly onto the Raspberry Pi Zero W headers. The speaker is supposed to be soldered to solder-pads on the bottom of the Speaker pHAT board. We will instead solder wires to the solder-pads so that we can place the speaker in the gap left by removing the old speaker from the Tummy rub button assembly.
If you soldered your Pi headers to the top, the Speaker pHAT will go on top of the Pi. So make sure you solder the speaker wires on before you solder the Speaker pHAT to the Pi. Also, make sure you add some insulation tape between the two boards.
If you soldered your Pi headers to the bottom, the Speaker pHAT will go on bottom of the Pi. Before you do, attach the four plastic screws meant to hold the speaker in place to the Speaker pHAT (attaching nothing but the plastic nuts). You can use these as spacers between the two boards to prevent shorts. (The excess parts of the screws will need to be trimmed afterwards.)
Bottom of Speaker pHAT board with wires soldered to speaker
Photo by chebe
It's always a good idea to test as you go. So now is the time to setup your Raspbian OS, configure network access, and enable ssh. You'll also want to install everything you need to use the Speaker pHAT, so;
curl -sS https://get.pimoroni.com/speakerphat | bash
Once installed verify everything is working;
aplay -l
(lowercase L)You should see output like;
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
You can also;
cat /proc/asound/cards
And you'll get something like;
0 [sndrpihifiberry]: HifiberryDac - snd_rpi_hifiberry_dac
snd_rpi_hifiberry_dac
You can use this information to find the path to your audio device status file. Here it is card 0, device 0, subdevice 0. So the path will be;
cat /proc/asound/card0/pcm0p/sub0/status
(the p at the end of pcm0p is for playback)With no sound playing you should get output of;
closed
But I ran into the problem that my device, my speaker, was supposedly always on. I always got output that began;
status: RUNNING
This is problematic for a later step, so I spent some time trying to figure out what was going wrong. It appears that PulseAudio is configured (by the Speaker pHAT installation) to keep the device running in order to minimise speaker pops/clicks. But we need to know when sound is playing and when it's not, so we need to edit the configuration.
sudo vim /etc/pulse/default.pa
Find the line;
load-module module-suspend-on-idle timeout=604800
and comment out the timeout section. Reload/reboot, and the changes will take affect. You can now
cat /proc/asound/card0/pcm0p/sub0/status
and get closed
.You can test this with two ssh sessions. In one
cat ...status
, see closed
. In the other run some audio. You can;cd /home/pi/Pimoroni/speakerphat/test
./test.sh
(you need to be in the directory because paths in the script are relative)
And while the script is running through the audio samples, in your first session
cat ...status
again and you will see status: RUNNING
. Once the sounds stop cat ...status
will give you closed
again. Rightly so.