Skip to content

Instantly share code, notes, and snippets.

@jkrasnay
Last active June 7, 2022 15:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkrasnay/1db66fc8c0b28b2b9cd6eaacc3bb6265 to your computer and use it in GitHub Desktop.
Save jkrasnay/1db66fc8c0b28b2b9cd6eaacc3bb6265 to your computer and use it in GitHub Desktop.
Getting Started on the M5Stack Core2

Getting Started on the M5Stack Core2

This is a short guide to getting the M5Stack Core2 running on MacOS Catalina.

Setting Up the Environment

The following commands get us set up with arduino-cli

brew install arduino-cli
arduino-cli config init
vi Library/Arduino15/arduino-cli.yaml   # add board download URLs as below

(TODO: describe how to install the USB driver for MacOS)

We need URLs so arduino-cli knows about ESP32 boards. See https://conferre.cf/arduino/cli.php

board_manager:
  additional_urls:
  - https://dl.espressif.com/dl/package_esp32_index.json
  - https://arduino.esp8266.com/stable/package_esp8266com_index.json
  - https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json

Now we can install the required tooling for ESP32.

arduino-cli core update-index
arduino-cli core search                 # see that esp32:esp32 is available
arduino-cli core install esp32:esp32
arduino-cli board listall               # see that M5Stack-Core-ESP32 is available

We’ll need the M5Core2 library to be installed

arduino-cli lib install M5Core2

Creating Our First Sketch

arduino-cli sketch new FirstApp

Edit FirstApp.ino to look as follows:

#include <M5Core2.h>

void setup() {
    M5.begin();
    M5.Lcd.print("Hello, world!");
}

void loop() {
}

Now compile the sketch from the FirstApp directory:

arduino-cli compile --fqbn esp32:esp32:m5stack-core-esp32

Installing the Sketch

Run the following without the Core2 plugged into USB:

arduino-cli board list

Now, plug the Core2 into USB and run the command again. In my case, the second run produced the following additional lines:

Port                            Type              Board Name FQBN Core
/dev/cu.SLAB_USBtoUART          Serial Port (USB) Unknown
/dev/cu.usbserial-01F9709F      Serial Port (USB) Unknown

It’s OK that arduino-cli doesn’t know the board type. It just means we have to specify it when we upload.

arduino-cli upload --fqbn esp32:esp32:m5stack-core-esp32 --port /dev/cu.SLAB_USBtoUART

The upload should take a few seconds, after which the Core2 should restart and display "Hello, world!" in tiny little letters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment