Does anyone knows how to read microphone in esp32 s3 sense development board using micropython.
Does anyone knows how to read microphone in esp32 s3 sense development board using micropython.
You could check ESP BOX at Adafruit to see if it is compatible.
There are micropython code that are available but it is showing pin error in it.
Please check the bellow code
import machine
import time
import ustruct
# Configure I2S for the built-in microphone
# Pin definitions for ESP32-S3 (based on ESP32-S3 Sense specs)
# These may vary depending on the board revision. Check the datasheet.
I2S_SCK = 18 # Serial clock pin
I2S_WS = 19 # Word select (left/right channel)
I2S_SD = 21 # Serial data input pin (microphone data)
# Set up I2S
i2s = machine.I2S(
id=0, # I2S interface 0
sck=machine.Pin(I2S_SCK), # Serial clock pin
ws=machine.Pin(I2S_WS), # Word select pin
sd=machine.Pin(I2S_SD), # Serial data input pin
mode=machine.I2S.MASTER, # Mode is master
bits=16, # Data bits per word (16-bit audio)
format=machine.I2S.MONO, # Mono audio (single channel)
rate=16000, # Sampling rate in Hz (typically 16kHz for mic)
dma=True # Use DMA (Direct Memory Access) for efficient data transfer
)
# Buffer to store audio data (e.g., 256 bytes for each read)
buffer = bytearray(256)
while True:
# Read audio data from the microphone
bytes_read = i2s.readinto(buffer)
if bytes_read:
# Process the data (e.g., printing first 10 bytes for debugging)
print("Data read from mic:", [ustruct.unpack('<h', buffer[i:i+2])[0] for i in range(0, bytes_read, 2)])
# Delay to allow for continuous reading at a reasonable rate
time.sleep(0.1)
The ESP32-S3 Sense has a built-in PDM microphone. For I2S, verify that the pins you've defined (I2S_SCK
, I2S_WS
, and I2S_SD
) match the board's actual pinout. Not all pins on the ESP32-S3 support I2S. Verify that your selected pins are valid I2S pins by consulting the ESP32-S3 datasheet or technical reference manual. You may also want to check this Raspberry pi passed voice control project for some references: www.theengineeringprojects.com/.../voice-control-project-using-raspberry-pi-4.html
The ESP32-S3 Sense has a built-in PDM microphone. For I2S, verify that the pins you've defined (I2S_SCK
, I2S_WS
, and I2S_SD
) match the board's actual pinout. Not all pins on the ESP32-S3 support I2S. Verify that your selected pins are valid I2S pins by consulting the ESP32-S3 datasheet or technical reference manual. You may also want to check this Raspberry pi passed voice control project for some references: www.theengineeringprojects.com/.../voice-control-project-using-raspberry-pi-4.html