🌈 ESP32-S3 Rainbow: ZX Spectrum Emulator Board! Get it on Crowd Supply →
View All Posts
read
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi

In the last post we were testing out the audio on my new board. There something in the code that piqued my interest.

We’re using a standard I2S PDM microphone - which has the normal pins you’d expect for I2S.

Here’s my schematic:

The Schematic

And here’s the datasheet to confirm I haven’t made a silly error:

The data sheet

You’re probably thinking - yes yes, all very interesting, that’s the standard pins for I2S - CLK, Data, L/R and power.

Well, what confused me was the I2S code in the latest ESP-IDF version.

What about the LR pin?

There is no way to specify the LR pin! The gpio_cfg structure for PDM microphones doesn’t have an entry for it.

It’s not here!

For PCM microphones the LR clock is pretty important - particularly if you want to have a stereo signal.

Looking back at one of my ancient YouTube videos you can see the waveforms:

PCM Signals

And if we look at the structure used to initialise I2S for PCM the pin is definitely there.

There’s an LR pin here!

So, what’s going on with PDM microphones? What are we supposed to do with the LR pin?

A quick question to the ESP32 forums set me straight with a very friendly - look again at the data sheet for your microphone.

And looking a bit more closely we find these example IO timing diagrams:

Look at the data sheet properly…

If the LR pin is held high - the data is valid for the high to low transition of the clock and then the data pin goes high impedance.

If the LR pin is held low - the data is valid for the low to high transition of the clock and then the data pin goes low impedance.

This means that if you want to have two microphones (for stereo recording) you just need to tie one high and one low - and they will happily coexist on the same data line.

Stereo PDM microphones

I’d recently purchased some fancy probes, so I decided to check this out.

Nice probes!

These are really nice - they have a pogo needle on the end so you can get into very small places on the PCB. They are also hands free. Pretty cool - you can pick up you own set here (affiliate link!).

Needle point

Probing the PCB

I monkeyed around with the code a bit and changed the data pin so that it had a pull down resistor and made it so I could toggle the LR pin between high and low.

Here’s what we see when the LR pin is held low:

LR = GND

And here’s what we see when the LR pin is held high:

LR = VDD

Hopefully you can see the difference. With the LR pin low, the signal starts to decay when the clock is high, and with the LR pin high, the signal starts to decay when the clock is low.

We’ve only got the internal pull down resistor pulling it down so it doesn’t go to zero that quickly. If there was another microphone driving the pin then it would fall straight to zero if needed.

So, all in all pretty interesting. One thing that is quite useful is that we don’t need to connect the LR pin to a GPIO - we can save a pin in our next design!

Related Posts

ESP32-S3 USB UAC - I turned my new ESP32‑S3 board into a USB Audio device. After a ninja LED fix and confirming the IMU and charging, I streamed mic audio over Web Serial (with a slick AI-made ‘Audio Studio’) and then via USB UAC. The mic sounds great, but the speaker is crackly over UAC—even though I2S WAV playback is perfectly clean. ESP-IDF worked; Arduino didn’t. Bonus annoyance: macOS vs Windows is a toggle, not a combo. Still, this board passes QA.
E32-S3 no DAC - No Problem! We'll Use PDM - In this post, I tackle the lack of a DAC on the ESP32-S3 by demonstrating how to use Pulse Density Modulated (PDM) audio with Sigma Delta Modulation to achieve analog audio output. I explore the simplicity of creating a PDM signal and its reconstruction into an audio signal using a low pass filter, even an RC filter, though a more sophisticated active filter is recommended. I guide through using both a timer and the I2S peripheral on the ESP32 for outputting PDM data, noting the quirks and solutions for each method. And I wrap up with how straight PDM signals can drive headphones or work with various amplifiers, including the MAX98358 or SSM2537, exhibiting the versatility of PDM in audio applications with the ESP32-S3.
I made a 10 Cent MCU Talk - I taught a 10¢ CH32V003 RISC‑V MCU to talk. By bit-banging PWM as a DAC and using a tiny 2‑bit ADPCM decoder, I squeezed ~6–7 seconds of recognizable audio into 16 KB of flash. Then I went full retro with LPC speech synthesis (Think: Speak & Spell) using the Talkie library and a small web tool I built to generate LPC data—so this little 8‑pin chip can now play samples and ‘speak’ lots of words with only a few kilobytes.
ESP32 Audio Input - MAX4466, MAX9814, SPH0645LM4H, INMP441 - In this blog post, I've delved deep into the world of audio input for ESP32, exploring all the different options for getting analogue audio data into the device. After discussing the use of the built-in Analogue to Digital Converts (ADCs), I2S to read ADCs with DMA, and using I2S to read directly from compatible peripherals, I go on to present hands-on experiments with four different microphones (MAX4466, MAX9814, SPH0645, INPM441). This comprehensive look at getting audio into the ESP32 should be a valuable resource for anyone hungry for a deep-dive into ESP32's audio capabilities, complete with YouTube videos for an even more detailed look!
ESP32 TV Version 3 - In the latest board revision, I've successfully resolved some key issues, including a USB interface conflict between the USB2244 and the ESP32 and a risky battery charging mistake—no more direct USB 5V to the battery! Plus, I managed to wrap this up without any clumsy bodge wiring. I've even introduced a new feature: a microphone is now on board, setting the stage for some exciting future projects. Stay tuned for what's coming!

Related Videos

ESP32 PDM Microphone - What do you do with the L/R pin? - I treated myself to some hands-free probes and dug into the PDM mic on my ESP32 board. I was confused that the new I2S PDM API only asks for clock and data—no LRCLK—yet the mic datasheet shows an LR/SEL pin. The trick: in PDM, LR is just a static select. Tie it low and data is valid on the rising edge; tie it high and it’s valid on the falling edge, so two mics can share the same I2S lines by picking opposite polarities. I proved it on the scope and realized I don’t need to burn a GPIO on LR at all—just hard-wire it high or low and save a pin.
ESP32-S3 USB UAC Audio Device - does it work? - Time for an audio project: I took my PCBWay ESP32‑S3 board for a spin—fixed the common anode/cathode LED mix‑up, verified the IMU and battery charger, then tested an I2S PDM mic and tiny speaker with a Web Serial Audio Studio (scope, spectrogram, tuner). I also turned it into a USB UAC device in ESP‑IDF: the mic is clean, but speaker over UAC is crackly (Mac/Windows toggle oddity); direct I2S WAV playback is perfect, so the hardware passes QA.
How Is This 10¢ Chip Talking? - I got a 10‑cent MCU literally talking. With just 16K of flash and 2K of RAM, I used PWM and a tiny transistor amp to play 6+ seconds of audio at 8 kHz by compressing it with super‑simple 2‑bit ADPCM—4:1 compression and a decoder in under 2 KB. I built a handy WAV‑to‑2‑bit‑ADPCM tool to make it easy. For longer phrases, I switched to the Talkie library (TI LPC speech synthesis from the TMS5220/TMS5100 era—think Speak & Spell and classic arcades), and I even made a web tool and player for generating and previewing LPC data. It’s wild what you can squeeze out of a 10‑cent MCU. Also, PCBWay did the boards—link below.
10¢ MCU Music Hack - CH32V003 - I spun some tiny WCH boards at PCBWay around an 8‑pin MCU (48 MHz, 16k flash, 2k RAM) to beep tunes off a coin cell. I tried hand-soldering, then used my paste-dispensing PCB printer—expired paste still worked great. Standby sips under 8 µA, but it locks out programming; a WLink flash wipe rescued me. Wake draws ~3.3 mA, and audio peaks hit ~130 mA (~13–14 mA average), which browned out the coin cell. A tiny 80 mAh LiPo with a TP4056 (modded to ~100 mA) proved the design, then swapping the buzzer’s base resistor from 1k to 10k tamed it to ~56 mA peak and just over 7 mA average—coin cell friendly and still loud. I’m bit-banging audio for now (PWM/timers later). I also made a quick MIDI-to-note tool and a one-bit SFX generator. These boards are heading into my next project—stay tuned.
ESP-IDF 6 Setup in VS Code: Blink & Debug an ESP32-S3 - Time to get with the program and jump to ESP-IDF v6.0.1 in VS Code. I show you how to install the prerequisites (I’m on a Mac with Homebrew), run the ESP-IDF Installation Manager, spin up a Blink example for an ESP32-S3, tweak menuconfig (GPIO21, 500 ms), then build and flash—switching from stubborn USB JTAG to trusty UART when things fail. We check the monitor, bump CPU to 240 MHz, fix flash to 16 MB, peek at PSRAM, and give PCBWay a quick shout-out.
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening


Published

> Image

atomic14

A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff. Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...

View All Posts