Problem compiling with Include M5Stack.h

  • If I try and compile in Arduino IDE and sketch that has the #include M5Stack.h, even on Example code in the "examples from Custom Library - M5Stack - Basic - Hello World, I get an compiling error.

    Here is the error I get for Hello World with display to the TFT:
    C:\Users\█████\Documents\Arduino\libraries\M5Stack\src\M5Stack.cpp: In member function 'void M5Stack::powerOFF()':

    C:\Users\█████\Documents\Arduino\libraries\M5Stack\src\M5Stack.cpp:65:62: error: 'esp_sleep_enable_ext0_wakeup' was not declared in this scope

     esp_sleep_enable_ext0_wakeup((gpio_num_t)_wakeupPin , LOW);

    Now I I have updated the library with GIT.

    Arduino: 1.8.5 (Windows Store (Windows 10), Board: "M5Stack-Core-ESP32

    I can compile and run others like ResetReason.

    So guidance would be helpful to resolve this

  • hi, Zathras0
    Why you use Arduino IDE, work rather with PlatformIO it's easier to use.
    And I think that your function was not declared above in your code or from what I saw this function and made for an ESP.

    Did you know that select M5Stack in your board from the menu <tool>

    and I start in C++ so I tell you about my problems that I met

  • @pépémax
    I will give PlatformIO a go. Might give me more direction of where the issue is. Trying via VScode, supposed to be easier for casual programer like myself

    In response to what you said, the M5Stack at its core is a ESP32.

    The statement it complains about is in the M5Stack.h itself for the power off function.

  • @Zathras0
    I know that the MStack is an ESP32 but you should know that some function of the ESP32 does not work yet for the M5Stack library like analogWrite(), I saw this morning on a forum if I find the link I give it to you.
    And I think it's your function that is not handled by the M5Stack librairy

  • please see my post here:

    Try this and let me know as I have just been fighting with the GUI.

  • Hi @Zathras0,
    That seems a weird error to get from running M5Stack's simple Hello sketch which does not include a poweroff function. (?).
    Also I don't know the "ResetReason" sketch that you referred to. Where did you find this ?

    (1)OK it seems you have the M5Stack library installed in the correct place.

    (2) Is the Espressif ESP32 library installed ? Check: C:\Users\█████\Documents\Arduino\Hardware\espressif\esp32\libraries . If you don't have files there go to M5Stack setup guide and install them.

    (3) As PépéMax suggested, in the Arduino IDE, check that the M5Stack is selected as the board that you are using with the IDE. On the Arduino menu go to /Tools/Board . The M5Stack should be set here as the board you are using.


    '...some function of the ESP32 does not work yet for the M5Stack library like analogWrite()

    Just to clarify, as I understand it, the issue is that not all functions available on Arduino or ESP8266 boards are available at present on ESP32 boards in general - eg: analogWrite();. That is, the problem is not specific to M5Stack boards - it effects all ESP32 boards. Referenced here

  • same problem!!!

    solved on commenting out




    I don't know why, but now arduino compile