M5stack and Blynk

I’m trying to get the M5Stack (based on ESP32) working with Blynk. I tried to compile a basic Blynk sketch and it’s not working.

#define BLYNK_PRINT Serial

#include <M5Stack.h>
#include <BlynkSimpleEsp32.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "my_auth_token";

// Your WiFi credentials.
char ssid[] = "my_ssid";
char pass[] = "my_ssid_password";

void setup()
// Debug console

Blynk.begin(auth, ssid, pass);

void loop()

Here are the errors from the Arduino IDE (v1.8.5)

Arduino: 1.8.5 (Mac OS X), Board: "M5Stack-Core-ESP32, QIO, 80MHz, 921600, None"

In file included from /Users/world101/Documents/Arduino/libraries/Blynk/src/Blynk/BlynkApi.h:17:0,
from /Users/world101/Documents/Arduino/libraries/Blynk/src/BlynkApiArduino.h:14,
from /Users/world101/Documents/Arduino/libraries/Blynk/src/BlynkSimpleEsp32.h:20,
from /Users/world101/Documents/Arduino/m5stack_blynk/m5stack_blynk.ino:38:
/Users/world101/Documents/Arduino/libraries/Blynk/src/Blynk/BlynkTimer.h:38:36: error: conflicting declaration 'typedef void (* timer_callback)()'
typedef void (*timer_callback)(void);
In file included from /Users/world101/Documents/Arduino/libraries/M5Stack/src/M5Stack.h:94:0,
from /Users/world101/Documents/Arduino/m5stack_blynk/m5stack_blynk.ino:37:
/Users/world101/Documents/Arduino/libraries/M5Stack/src/utility/M5Timer.h:34:35: note: previous declaration as 'typedef class std::function<void()> timer_callback'
typedef std::function<void(void)> timer_callback;
Multiple libraries were found for "WiFi.h"
Used: /Users/world101/Documents/Arduino/hardware/espressif/esp32/libraries/WiFi
Not used: /Applications/Arduino.app/Contents/Java/libraries/WiFi
Multiple libraries were found for "SD.h"
Used: /Users/world101/Documents/Arduino/hardware/espressif/esp32/libraries/SD
Not used: /Users/world101/Documents/Arduino/libraries/SD
Not used: /Applications/Arduino.app/Contents/Java/libraries/SD
exit status 1
Error compiling for board M5Stack-Core-ESP32.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

If I comment out #include <M5Stack.h> it will compile fine, but I don’t get to use any of the M5 functions like M5.Lcd.printf().

Any ideas on how to fix it?

I also tried the DH12 example from github and get similar errors.


M5Timer is conflicting with BlynkTimer… oh well I’ll have to ckeck what can be done :frowning:
You can omit the #include <M5Stack.h> for now…

After further digging for the error, I found the following which has the solution. It looks like you already opened the issue on github. I’ll post it on the m5stack community as well.

I modified the header file Arduino/libraries/M5Stack/src/utility/M5Timer.h as follows.

    //typedef std::function<void(void)> timer_callback;
    typedef void (*timer_callback)(void);
    typedef void (*timer_callback_p)(void *);

It now builds successfully and connects to the blynk cloud :slight_smile: