aztech
Created November 5, 2023

Smart Sound Processing with Infineon MEMS and MicroPython

Smart audio with Infineon's IM69D130 Shield2Go and CY8CPROTO-062-4343W, delivering high-fidelity sound capture in embedded system.

23
Smart Sound Processing with Infineon MEMS and MicroPython

Things used in this project

Hardware components

CY8CPROTO-062-4343W
Infineon CY8CPROTO-062-4343W
×1
S2GO MEMSMIC IM69D MEMS Microphone
Infineon S2GO MEMSMIC IM69D MEMS Microphone
×1

Software apps and online services

MicroPython
MicroPython

Story

Read more

Schematics

schematics

Code

main.py

MicroPython
import micropython
from machine import I2S, Pin, Timer
from audio_processor import AudioProcessor
from system_monitor import SystemMonitor
import _thread

# Initialize the audio processor and system monitor
audio_processor = AudioProcessor()
system_monitor = SystemMonitor()

# Configure pin P5_0 on J5 as an output
pin_p50 = Pin(5, Pin.OUT)  # Assuming '5' is the pin number for P5_0

# Initialize I2S for the MEMS microphone (adjust pin numbers as necessary)
i2s = I2S(1, ws=Pin(21), sd=Pin(22), sck=Pin(23), mode=I2S.RX, bits=32, format=I2S.MONO, rate=44100)

# Define threads for system monitoring and audio processing
def monitor_system():
    while True:
        system_monitor.check_system_status()
        micropython.schedule(system_monitor.report_status, 0)
        _thread.sleep_ms(500)

def process_audio():
    while True:
        audio_data = i2s.readinto(audio_processor.buffer)
        if audio_data:
            audio_processor.process_data(audio_data)
            if audio_processor.detect_keyword():
                print("Keyword detected!")
                pin_p50.value(1)  # Set P5_0 high
                _thread.sleep_ms(100)  # Debounce delay
                pin_p50.value(0)  # Set P5_0 low
        _thread.sleep_ms(100)

# Start the threads
_thread.start_new_thread(monitor_system, ())
_thread.start_new_thread(process_audio, ())

# Main loop to perform other tasks
while True:
    Timer.sleep_ms(1000)
    # Other tasks can be added here

Credits

aztech

aztech

2 projects • 0 followers

Comments