[M5 Fire] Wave playing?

  • Hi all,

    I try to follow this tutorial to play wav file on M5stack Fire: https://m5stack.hackster.io/lukasmaximus89/m5stack-rfid-face-wav-playing-flashcard-program-526cb5

    But I have a little problem with the module wave. When i run my micropython code i have an error on the fire:

    no module named 'wave'

    Thanks for your help.

  • Hi, @inrepublica ,
    Sorry about that,try "from wav import wave".

  • Thanks for your reply, when i test this code in UIFlow 1.7.7 on Fire:

    from machine import I2S
    import os, uos
    from wav import wave
    #initialize the I2S device
    i2s = I2S(  mode = I2S.MODE_MASTER | I2S.MODE_TX | I2S.MODE_DAC_BUILT_IN,
                rate = 16000,
                bits = 16,
                channel_format = I2S.CHANNEL_ONLY_RIGHT,
                data_format = I2S.FORMAT_I2S_MSB)
    #uncomment the following line if you have issues mounting the sd
    #create a function to play the wav
    def wav_player(fname):
        wav = wave.open(fname)
        i2s.bits(wav.getsampwidth() * 8)
        while True:
            data = wav.readframes(1024)
            if len(data) > 0:
    # Playing WAV audio file
        lcd.print('sd card not mounted',0,50,0xffffff)
    while True:

    I have another error on line 39:

    module object has no attribute 'mountSD'

  • has anyone tried to run this on a core2 ?

    I get errors when trying to initialize i2s device:

    "type object 'I2S' has no attribute MODE:MASTER....

  • Have you updated to the latest UIFLow firmware?
    You are replying to old topics and the firmware has changed quite a bit since.

  • @ajb2k3 Yes, I updated to the latest firmware.
    I know, it's an old topic, but I made a new one, about playing audio to external speakers but nobody replied :(
    So I am trying to figure what people did before me.

  • I have got a wave file to play on the core2 in UIFlow but I found a bug with one of the blocks.
    I just used the Play local file block which played a file stored in memory.

    If your trying from the SD card the documents say the path is sd/somefile.wav not /sd/somefile.wav (no preceding forward slash)
    however this assumes that somefile.wav is stored in the root of the SD card. also the wav file has to match certain file requirements that are a restriction of MicroPython.

  • @ajb2k3 thanks for your reply. Yeah, I figured out the same thing with the file path on the core2 and it plays wavs quite reliably through the speaker.... however, this speaker is quite low volume and in my setup it has to give voice commands to an ipad (in an art exhibition)... so I need to connect to an external speaker.

    Do you happen to know how I can route the wav-audio to the DAC (pin 25) on the core2?

    I tried with the wav player template by @lukasmaximus or @lukasmaximus89 ... but the result is that the firmware of core2 doesn't seem to know the I2S modes...

    any suggestions what to do?

  • I know the ESP32 supports I2S (audio) output but have no idea how so setup and use I2S.

  • @ajb2k3 ok, I see. But thanks for your reply. I post in this forum if I can figure it out