Small Speaker & Dual Mic hats at the same time?

I connected the Dual Mic and the Smol Speaker hats to a single Pi3 using the HAT Hacker HAT.

I can’t seem to get both the speaker and the microphone to be detected at the same time. The installation scripts overwrite the dtoverlay with adau7002-simple for the mic and hifiberry-dac for the speakers. Loading both (adau7002-simple,hifiberry-dac) results in just the mic being detected, and the other way around in just the speaker being detected (by arecord -l and/or aplay -l).

Is there a way to use both at the same time?

Best,
D.

I’d say it’s an i2s issue. The two hats are trying to use the same interface / GPIO pins.
This might help.
PCM at Raspberry Pi GPIO Pinout

So the line on Pirate Audio: Dual Mic for Raspberry Pi – Pimoroni that says " You could potentially also use one of our other Pirate Audio boards for audio output, via something like a HAT Hacker HAT" - the product page for the dual mic hat is VERY misleading in that case.

D.

I’m far from being any kind of expert on i2s. It may be doable, you may have to make sure only one device is accessing i2s at a time. It’s above my skill level that’s for sure.

Looks like I can manually load and unload the dtoverlay without a reboot - but it still doesn’t mean that they ‘work’ together.

Can anyone on the support team confirm if that was just a bit of misleading marketing fluff on the product page, or if there is any way to use both via the hacker hat without unloading and loading the dtoverlay between each use of the mic and playback - which makes any sort of voice controlled playback impossible since you can’t listen for a wakeword to interrupt the playback without having the mic available.

I don’t want to spend too much time going down a dead end if I have to get start looking for some other hardware to get it working in the end.

Thanks,
D.

It’s unfortunately a bit more complicated than we’ve made it sound- requiring a separate dtoverlay to setup the adau7002 for input and pcm5102a for output. Device-tree stuff is a bit of a dark art, and while I’m sure it can work I’ve not had much luck finding an overlay which uses “simple-audio-card” to glue two codecs together like this.

I have, however, had a go at writing my own which at least loads and shows some… reasonable?.. devices:

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2835";

    fragment@0 {
        target = <&i2s>;
        __overlay__ {
            status = "okay";
        };
    };

    fragment@1 {
        target-path = "/";
        __overlay__ {
            pcm5102a_codec: pcm5102a-codec {
                #sound-dai-cells = <0>;
                compatible = "ti,pcm5102a";
                status = "okay";
            };
        };
    };

    fragment@2 {
        target-path = "/";
        __overlay__ {
                adau7002_codec: adau7002-codec {
                #sound-dai-cells = <0>;
                compatible = "adi,adau7002";
/*                IOVDD-supply = <&supply>;*/
                status = "okay";
            };
        };
    };

    fragment@3 {
        target = <&sound>;
            sound_overlay: __overlay__ {
            compatible = "simple-audio-card";
            simple-audio-card,format = "i2s";
            simple-audio-card,name = "adau7002";
            simple-audio-card,bitclock-slave = <&dailink1>;
            simple-audio-card,frame-slave = <&dailink1>;
            simple-audio-card,widgets =
                    "Microphone", "Microphone Jack";
            simple-audio-card,routing =
                    "PDM_DAT", "Microphone Jack";
            status = "okay";
            dailink0: simple-audio-card,dai-link@0 {
                reg = <0>;
                format = "i2s";
                cpu {
                    sound-dai = <&i2s>;
                };
                codec {
                    sound-dai = <&adau7002_codec>;
                };
            };
            dailink1: simple-audio-card,dai-link@1 {
                reg = <0>;
                format = "i2s";
                cpu {
                    sound-dai = <&i2s>;
                };
                codec {
                    sound-dai = <&pcm5102a_codec>;
                };
            };
        };
    };


    __overrides__ {
        card-name = <&sound_overlay>,"simple-audio-card,name";
    };
};

You can compile this with:

dtc -I dts -O dtb -o adau7002-pcm5102a-io.dtbo adau7002-pcm5102a-io-overlay.dts

And try loading it!

1 Like

I’ve updated our marketing fluff to hopefully make it clearer that getting two I2S devices working nicely together in Raspberry Pi OS is currently a bit here be dragons - if you need to swap anything drop us an email at support@pimoroni.com with a link to this thread and we’ll get it sorted.

1 Like

Great, that worked!

Just for anyone coming after me the steps that worked for me are:
(I think my start state was running both install scripts for the microphone hat and then the speaker hat)

  1. Paste the code above into a file called adau7002-pcm5102a-io-overlay.dts
  2. Run the compile command to make the .dtbo
  3. Move the .dtbo file to /boot/overlays/
  4. In /boot/config.text change the dtoverlay line to be “dtoverlay=adau7002-pcm5102a-io”
  5. Add the /etc/asound.conf configuration lines from pirate-audio/clip-recorder at master · pimoroni/pirate-audio · GitHub
  6. Reboot
  7. Check the speaker works with: speaker-test -c2 -twav -l2
  8. Check the microphone hardware details with: arecord -L
    – look for the device that has ‘Hardware device with all software conversions’, mine looked like:
plughw:CARD=adau7002,DEV=1
    adau7002, bcm2835-i2s-adau7002-hifi adau7002-hifi-1
    Hardware device with all software conversions
  1. Test the mic using the CARD and DEV details shown by arecord:
    arecord -D hw:adau7002,1 -c2 -r48000 -fS32_LE -twav -d5 -R10000 -Vstereo test.wav
    then play with: aplay test.wav
    If all went to plan you should be able to hear someone saying 'Work you &£*@&*@ piece of *$&*£ ’

Thanks for the help,
D.

1 Like