The PSOC™ Edge E84 AI Kit provides an easy way to prototype edge AI and embedded applications directly on hardware. One of the simplest ways to explore its capabilities is by using the onboard PDM microphones together with MicroPython.
In this ProTip, we will demonstrate how to quickly access the microphones on the board using MicroPython and read real-time audio levels.
HardwareFor this example, the only required hardware is the PSOC™ Edge E84 AI Kit.
The board integrates two digital PDM microphones, which are located on both sides of the development kit. These microphones capture environmental sound and stream it to the microcontroller through a PDM interface.
This built-in hardware makes it possible to immediately experiment with audio sensing without any additional external components.
Micropython
To follow this protip, you will need:
- PSOC™ Edge E84 AI Kit
- MicroPython firmware installed on the board
- A MicroPython IDE such as Thonny
If you have not installed MicroPython on the board, you can follow the setup guide here!
Once MicroPython is running on the device, we can start interacting with the microphones using the PDM_PCM interface.
Reading Audio Data from the Microphone
The following code initializes the onboard PDM microphone interface, reads audio samples into a buffer, and calculates a simple sound level value.
1. Import required libraries
from machine import PDM_PCM, Pin
import array
import time2. Create an audio buffer
# buffer for audio samples
buf = array.array('h', [0] * 256)
This buffer stores 256 audio samples captured from the microphone.The 'h' type represents 16-bit signed integers, which match the microphone’s output format.
3. Configure the microphone interface
# microphone interface
mic = PDM_PCM(
sck=Pin("P8_5"), # PDM clock
data=Pin("P8_6"), # PDM data
sample_rate=16000,
bits=16,
format=PDM_PCM.MONO
)Here we configure the PDM microphone driver.
Key parameters:
sck → PDM clock signal
data → microphone data stream
sample_rate = 16000 → common audio sampling rate
bits = 16 → 16-bit audio samples
MONO format → single channel audio
4. Read audio samples
print("Microphone demo running...")
while True:
mic.readinto(buf)This command fills the buffer with new audio samples captured from the microphone.
5. Compute sound level
level = sum(abs(x) for x in buf) // len(buf)
print(level)
time.sleep(0.05)This calculates the average absolute amplitude of the captured audio samples.
The result provides a simple representation of sound intensityas seen in the plotter here.
There you have it—audio alive on MicroPython and PSOC™ Edge E84 AI Kit. Now turn that signal into something creative. :)









Comments