Fixing I2S Initialization Error for Voice-Controlled Home Automation on ESP32

Hey guys am developing a home automation voice-controlled system using MicroPython and TinyML on an ESP32 microcontroller to recognize specific voice commands ("turn on" and "turn off") for controlling an LED, How do I set up the ESP32 with an I2S microphone and an LED for a voice-controlled system?

Am encountering an error
OSError: I2S Not Found

But I have verified the physical connections of the microphone to the ESP32.

Re-checked the pin numbers in the I2S configuration.

Confirmed the ESP32 firmware supports I2S functionality.

Here's my code
from machine import Pin, I2S

# Configure LED on GPIO 2
led = Pin(2, Pin.OUT)

# Configure I2S for microphone input
i2s = I2S(0, 
          sck=Pin(14), 
          ws=Pin(15), 
          sd=Pin(32), 
          mode=I2S.RX, 
          bits=16, 
          format=I2S.MONO, 
          rate=16000, 
          ibuf=2000)


My aim is to resolve the I2S initialization error to successfully capture audio input from the microphone
Solution
Hey @Enthernet Code
Update to the latest MicroPython firmware that supports I2S on your ESP32
Verify that the sck, ws, and sd pins are correctly assigned for I2S functionality, and initialize I2S with I2S.NUM0 to fix the error
Was this page helpful?