Zenbu Manual

Last updated 2 months ago

This is the manual/datasheet for the Zenbu-pHat. This hat for the Raspberry Pi gives you microphones and a 3W amplifier.

Precautions

  • Only connect suitable speakers. Using speaker with a insufficient power rating can lead to overheating, its destruction or in the worst case cause fire.

  • Make sure the software you are using is not pulling GPIO 17 to HIGH if no audio output is intended.

  • Do not remove LRCLK while BLCK is present. Removing LRCLK while BCLK is present can cause unexpected output behavior, including a large DC output voltage to the speaker.

  • If smoke develops or if the speaker is heating up, disconnect the device from the power source immediately and contact the manufacturer at office@nyumaya.com.

  • We only supply the hardware and have no influence on software. The Zenbu-Kit is intended to be used for research and development. Make sure that you have suitable knowledge to operate it safely. Faulty software can cause damage to the speaker.

Power Supply

We recommend using a power supply capable of delivering 2.5 Ampere. If you experience system restarts during playback we recommend using a better power supply.

Hardware

Dimensions of the Zenbu pHat
Pinout of the Zenbu pHat

Specifications

Microphones

The Zenbu Mic Board features two InvenSense ICS-43434 microphones. The board is powered from a 3v3 supply. Internally the Mic Board uses a 3v3 to 1v8 LDO which reduces noise in the power supply for the microphones.

  • Stereo bottom port MEMS-Microphones: ICS43434

  • Signal to noise ratio: 65 dBA

  • Acoustic overloading point: 120 dB SPL

Amplifier

  • Amplifier MAX98357A

  • Power 3.2W Output Power into 4 Ω

  • Load 4/8 Ω

3V3 Rail

  • All expansions are powered by a shared 300mA LDO

Quickstart Guide

Update Raspbian to its latest version

Older version of Raspbian or other Linux distributions will include the necessary driver for the pHat. Get the latest version of Raspbian and flash it to a SD Card. Update any old version of Raspbian:

sudo apt-get update
sudo apt-get upgrade
sudo reboot

Alsa configuration

Resetting Alsamixer Controls

If you have accidentally messed up the alsa configuration it can happen that phantom controls remain visible (e.g. in the alsamixer). To reset the alsa configuration to a clean state remove the alsa state file and make alsactl not executable. This will prevent alsa to recreate the state file. After rebooting alsactl has to be made executable again.

sudo rm /var/lib/alsa/asound.state
sudo chmod -x /usr/sbin/alsactl
sudo reboot
sudo chmod +x /usr/sbin/alsactl

Verify that the sound-card is recognized

arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: sndrpigooglevoi [snd_rpi_googlevoicehat_soundcar], device 0: Google voiceHAT SoundCard HiFi
Subdevices: 1/1
Subdevice #0: subdevice #0
aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpigooglevoi [snd_rpi_googlevoicehat_soundcar], device 0: Google voiceHAT SoundCard HiFi
Subdevices: 1/1
Subdevice #0: subdevice #0

On a fresh install aplay -l will show two additional sound cards.

**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 7/7
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
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: sndrpigooglevoi [snd_rpi_googlevoicehat_soundcar], device 0: Google voiceHAT SoundCard HiFi
Subdevices: 1/1
Subdevice #0: subdevice #0

Edit the file /boot/config.txt and comment the dtparam=audio=on line to disable the raspberry default audio. If you want to keep the default audio you have to modify your /etc/asound.conf file accordingly (This one assumes the Zenbu Sound-card has index 0)

# Enable audio (loads snd_bcm2835)
#dtparam=audio=on

The Zenbu pHat will work without any special alsa configuration, but will have no volume control. This can be especially troublesome since the microphones will pick up sound at very low volume.

We provide a possible configuration to boost the microphone volume and provide a software volume control. Edit the file /home/pi/.asoundrc and replace the content with the following content.

/home/pi/.asoundrc
pcm.softvol {
type softvol
slave.pcm dmix
control {
name Master
card 0
}
}
pcm.micboost {
type route
slave.pcm dsnoop
ttable {
0.0 50.0
1.1 50.0
}
}
pcm.micvol {
type softvol
slave.pcm "micboost"
control.name "Micmaster"
control.card 0
min_dB -5.0
max_dB 50.0
resolution 40
}
pcm.ampvol {
type softvol
slave.pcm dmix
control.name "Ampmaster"
control.card 0
}
pcm.asymed {
type asym
playback.pcm "ampvol"
capture.pcm "micvol"
}
pcm.dsp0 {
type plug
slave.pcm "asymed"
}
pcm.!default {
type plug
slave.pcm "asymed"
}
pcm.default {
type plug
slave.pcm "asymed"
}
ctl.mixer0 {
type hw
card 0
}

Connecting Microphone Board and Speaker

Use the included 7pin cable to connect the microphone board to the connector labeled MIC on the baseboard. Connect the speaker to the 2 pin connector on the baseboard which is labeled LS.

Switching the user LED

The green led on the Zenbu board can be switched on by setting the Raspberry Pi’s GPIO 13 to high. Here is an example how this can be done from the command line.

echo "13" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio13/direction
echo "1" > /sys/class/gpio/gpio13/value

Testing the speaker

Test your speaker by entering this command in the command line.

speaker-test

You should now see an output like this

speaker-test 1.0.28
Playback device is default
Stream parameters are 48000Hz,
Using 16 octaves of pink noise
Rate set to 48000Hz (requested
Buffer size range from 2048 to
Period size range from 1024 to
Using max buffer size 16384
Periods = 4
was set period_size = 1024
was set buffer_size = 16384
0 - Front Left
S16_LE, 1 channels
48000Hz)
16384
1024

and you should hear a pink noise coming from the speaker. You can stop the test by hitting CTRL+C

Testing the microphones

Record and Replay audio

Use arecord to capture a short audio file from the microphones. Then you can use aplay to replay the captured audio file.

arecord -f S32_LE -r 48000 -c2 > /tmp/audiotest.wav

aplay /tmp/audiotest.wav

Stream audio to a host PC

Another simple way to test the microphones is streaming the audio to a Host-PC. Use arecord to record audio and nc for the transmission on the Raspberry Pi. Assuming the IP-Address of the raspberry is 10.0.0.41:

pi@raspberrypi:~ $ arecord -f S32_LE -r 48000 -c2| nc -l 5555

On the Host-PC use nc connect to the Raspberry Pi and use a pipe to redirect the audio data to aplay

user@hosstpc:~ $ nc 10.0.0.41 5555|aplay

Troubleshooting

My Raspberry Pi doesn’t recognize the pHat: Make sure you use an up to date version of Raspbian. Make sure the pHat is connected to the Raspberry Pi before booting.

The microphones are not working: Make sure your ALSA settings are correct. If you skipped creating the asound file the volume of the microphone may be too low to hear. Try speaking closer to the microphone to verify this.

FAQ

Why are you using the google-voicehat driver? The basic philosophy of Linux is avoiding code duplication. The google-voicehat provides a minimal generic duplex I2S implementation. Any duplex sound-card which doesn’t require any special configuration will work with it. Introducing another redundant driver would add unnecessary complexity to the Linux project.