Skip to content

Building from source

psonnera edited this page Jul 31, 2026 · 1 revision

Building from source

You don't need to build anything to use xDripMon — ready-made binaries are in the repository's Binaries/ESP32_16MB/ folder (see Flashing from a computer). This page is for those who want to compile the firmware themselves with the Arduino IDE, to modify it or just to build what they flash.

One build covers the whole 16 MB lineup — Basic 2.6/2.7, Fire and Core2. The board model (PMU, IMU, touch…) is auto-detected at runtime by M5Unified, so there is a single binary and a single board selection.

1. Install the Arduino IDE

Download Arduino IDE 2.x from arduino.cc/en/software and install it normally.

2. Add the M5Stack board package

  1. File → Preferences → Additional boards manager URLs, add:

    https://static-cdn.m5stack.com/resource/arduino/package_m5stack_index.json
    
  2. Tools → Board → Boards Manager, search for M5Stack, install "M5Stack by M5Stack official" (tested with 2.1.1).

3. Install the libraries

Tools → Manage Libraries (Library Manager), install:

Library Tested with Used for
M5Unified 0.2.7 display, buttons, speaker, board auto-detection
NimBLE-Arduino 2.3.2 (must be 2.x) all Bluetooth (Mi Band 2 emulation, xDrip4iOS protocol)
Adafruit NeoPixel 1.15.1 the Fire's side LED bars

When the IDE offers to install dependencies (M5Unified pulls in M5GFX), accept. Newer versions normally work — the versions above are the ones the released binaries are built with. NimBLE-Arduino 1.x will not compile: the code uses the 2.x API.

Everything else (Preferences, mbedTLS, NVS…) ships with the ESP32 core — no extra installs.

4. Get the source

Either clone it:

git clone https://github.com/psonnera/M5Stack_xDripMon.git

or download the ZIP from github.com/psonnera/M5Stack_xDripMon (green Code button → Download ZIP) and extract it.

The Arduino IDE requires the sketch folder to be named like the sketch: keep the folder name M5Stack_xDripMon (rename it if your ZIP extractor added a -main suffix).

Open M5Stack_xDripMon.ino in the IDE — the other .cpp/.h files of the project open with it as tabs.

5. Select the board

Tools → Board → M5Stack → M5Fire — yes, also for a Basic or a Core2: this entry just means "16 MB ESP32 M5Stack core", and the model is detected at runtime. The default board options are already correct (16 MB flash, Default partition scheme with two OTA app slots, 80 MHz flash) — no need to change anything.

Connect the M5Stack over USB and pick its port under Tools → Port. If no port appears, you are missing the USB serial driver — see the driver note in Flashing from a computer.

6. Build and upload

Sketch → Verify/Compile to build, Sketch → Upload to build and flash. The first build compiles the whole ESP32 core and takes several minutes; later builds are much faster.

The Serial Monitor at 115200 baud shows the boot banner and the device's log output — handy when debugging.

After flashing, continue with Device setup.

Command-line alternative (Windows)

The repository also has a build script for arduino-cli — it finds arduino-cli (including the one bundled inside Arduino IDE 2.x) and drops the three flashable binaries in Binaries/ESP32_16MB/:

Scripts\build.bat

See Scripts/README.md in the repository for details (prerequisites, release builds, flashing offsets).

Clone this wiki locally