🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Core2 Arduino samples do not work

    Units
    2
    2
    563
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      G00TH
      last edited by

      I have a brand new Core2 and a Macbook with the latest Arduino IDE. The IDE is freshly installed, I have only installed the M5Core2 library. The Espressif boards are already up to date. I have tested sample code and everything concerning the display fails. I can flash an empty sketch.
      Here is the code:

      /*
      *******************************************************************************
      * Copyright (c) 2021 by M5Stack
      *                  Equipped with M5Core2 sample source code
      *                          配套  M5Core2 示例源代码
      * Visit for more information: https://docs.m5stack.com/en/core/core2
      * 获取更多资料请访问: https://docs.m5stack.com/zh_CN/core/core2
      *
      * Describe: Hello World
      * Date: 2021/7/21
      *******************************************************************************
      */
      #include <M5Core2.h>
      
      /* After M5Core2 is started or reset
      the program in the setUp () function will be run, and this part will only be run
      once. 在 M5Core2
      启动或者复位后,即会开始执行setup()函数中的程序,该部分只会执行一次。 */
      void setup() {
          M5.begin();  // Init M5Core2.  初始化 M5Core2
          /* Power chip connected to gpio21, gpio22, I2C device
                 Set battery charging voltage and current
                 If used battery, please call this function in your project */
          M5.Lcd.print("Hello World");  // Print text on the screen (string)
                                        // 在屏幕上打印文本(字符串)
      }
      
      /* After the program in setup() runs, it runs the program in loop()
      The loop() function is an infinite loop in which the program runs repeatedly
      在setup()函数中的程序执行完后,会接着执行loop()函数中的程序
      loop()函数是一个死循环,其中的程序会不断的重复运行 */
      void loop() {
      }
      

      Errors:

      In file included from /Users/jonathan/Documents/Arduino/libraries/M5Core2/src/M5Display.h:10,
                       from /Users/jonathan/Documents/Arduino/libraries/M5Core2/src/M5Core2.h:12,
                       from /private/var/folders/6m/wp1p74qn5djfp08mcy83nzgr0000gn/T/.arduinoIDE-unsaved2024930-70928-12jngy4.v8s9/helloworld/helloworld.ino:13:
      /Users/jonathan/Documents/Arduino/libraries/M5Core2/src/M5Display.h: In member function 'void M5Display::startWrite()':
      /Users/jonathan/Documents/Arduino/libraries/M5Core2/src/utility/In_eSPI.h:231:5: error: 'GPIO' was not declared in this scope
        231 |     GPIO.out_w1tc = (1 << TFT_CS); \
            |     ^~~~
      /Users/jonathan/Documents/Arduino/libraries/M5Core2/src/M5Display.h:54:9: note: in expansion of macro 'CS_L'
         54 |         CS_L;
            |         ^~~~
      /Users/jonathan/Documents/Arduino/libraries/M5Core2/src/M5Display.h: In member function 'void M5Display::endWrite()':
      /Users/jonathan/Documents/Arduino/libraries/M5Core2/src/utility/In_eSPI.h:233:14: error: 'GPIO' was not declared in this scope
        233 | #define CS_H GPIO.out_w1ts = (1 << TFT_CS)  //;GPIO.out_w1ts = (1 << TFT_CS)
            |              ^~~~
      /Users/jonathan/Documents/Arduino/libraries/M5Core2/src/M5Display.h:66:9: note: in expansion of macro 'CS_H'
         66 |         CS_H;
            |         ^~~~
      Multiple libraries were found for "SD.h"
        Used: /Users/jonathan/Library/Arduino15/packages/esp32/hardware/esp32/3.0.7/libraries/SD
        Not used: /Users/jonathan/Library/Arduino15/libraries/SD
      exit status 1
      
      Compilation error: exit status 1
      
      felmueF 1 Reply Last reply Reply Quote 0
      • felmueF
        felmue @G00TH
        last edited by

        Hello @G00TH

        I think the issue is with M5Core2 library not being ready/compatible for Arduino library version 3.x.x. (I get the same compilation errors as you are reporting.)

        That said, you could downgrade Arduino library to version 2.x.x - then the Hello World example of the M5Core2 library works for me.

        Or I suggest you try M5Unified with M5GFX libraries instead. For me they compile and run fine with Arduino library 2.x.x or 3.x.x.

        #include <M5Unified.h>
        #include <M5GFX.h>
        
        void setup() {
          auto cfg = M5.config();
          M5.begin(cfg);
          M5.Display.println("M5Core2 - Hello world");
        }
        
        void loop() {
        }
        

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        1 Reply Last reply Reply Quote 2
        • First post
          Last post