-
Notifications
You must be signed in to change notification settings - Fork 0
ArduinoIDE
Note
You do not need this page to use the device. Ready-made firmware is installed in minutes with the Web Flasher, Android, Windows or Mac guides, and the device then keeps itself up to date over-the-air.
This page is for developers and tinkerers who want to modify the source code and build it themselves.
This guide explains how to compile M5_NightscoutMon from source with the free Arduino IDE (version 2.x, Windows/Mac/Linux). One source builds every supported board — the board model is auto-detected at runtime — so the only choice you make is the Tools menu configuration below.
Either clone the repository:
git clone https://github.com/psonnera/M5_NightscoutMon.git
or download it as a ZIP from GitHub (Code → Download ZIP) and extract it.
Important
The Arduino IDE requires the sketch folder to have the same name as the sketch. If you downloaded the ZIP, rename the extracted folder from M5_NightscoutMon-master to M5_NightscoutMon.
Then open M5_NightscoutMon.ino in the Arduino IDE.
- Open File → Preferences and add this to Additional boards manager URLs:
https://espressif.github.io/arduino-esp32/package_esp32_index.json - Open Tools → Board → Boards Manager, search for esp32 by Espressif Systems and install version 2.0.16.
Important
The project needs the 2.x line of the esp32 package. It does not build with the 3.x versions — if the Boards Manager offers you 3.x, use the version drop-down to pick 2.0.16.
Open Tools → Manage Libraries (the Library Manager) and install:
| Library | Tested version | Notes |
|---|---|---|
| M5Unified | 0.2.7 | Say yes when it offers to install its dependencies |
| M5GFX | 0.2.9 | Installed automatically as an M5Unified dependency |
| ArduinoJson | 7.4.2 | |
| Adafruit NeoPixel | 1.15.1 | For the M5Stack Fire side LED bars |
Newer versions of these libraries will usually work; the versions above are the ones each release is built and tested with.
Set these in the Tools menu (leave everything not listed at its default):
| Your device | Tools → Board (under esp32) | Tools → Partition Scheme | Other settings |
|---|---|---|---|
| Basic bought ≤ 2020.5 (4 MB flash) | M5Stack-Core-ESP32 |
Minimal SPIFFS (Large APPS with OTA) |
— |
| Basic 16 MB / v2.6 / v2.7, Fire, any Core2 | M5Stack-FIRE |
Default (2 x 6.5 MB app, 3.6 MB SPIFFS) |
PSRAM: Disabled
|
| Any CoreS3 (incl. SE / Lite) | M5Stack-CoreS3 |
Default 16MB with spiffs (2x 6.5 MB APP/3.6MB SPIFFS) |
— |
Note
Yes, Core2 owners really do select M5Stack-FIRE: one binary covers all 16 MB ESP32 boards, and the firmware detects the exact model (PMU, IMU, touch...) at runtime. PSRAM is set to Disabled so the same binary is also safe on the PSRAM-less Basic 16 MB — the application doesn't use PSRAM anyway.
If you are not sure which Basic you have: the old 4 MB model was sold until mid-2020; when in doubt try the FIRE configuration first, and if the upload fails to fit or boot, use the 4 MB configuration.
These are exactly the configurations the official releases are built with (see Scripts/README.md for the reasoning behind the partition choices). No other build flags or source edits are needed.
Connect the device by USB, pick its port under Tools → Port, and press the Upload button (arrow icon).
If no port appears, you need the USB serial driver — see Install the M5Stack USB driver (Windows) or the Mac guide.
After the first upload by USB, your device behaves like any other: configure it via SoftAP and web server, and it can update itself over-the-air.
Warning
Over-the-air updates will replace your custom build. The device offers an update on its web page whenever the official release version is higher than the version compiled into your firmware (the M5NSversion string at the top of M5_NightscoutMon.ino, format YYYYMMDDnn). If you want to keep your own build, don't click the update link — or set your M5NSversion to a date in the future.
The JC3248W535 firmware cannot be built from the Arduino IDE menus: it needs the DEVICE_JC3248W535 compiler define applied to every source file (it swaps the M5Unified driver for the board's display shim), plus the GFX Library for Arduino pinned at exactly 1.6.0 (1.6.1 is broken with its AXS15231B panel). The IDE has no way to set a global define.
To build it, use the PowerShell build script on Windows instead — it handles the define, checks the library versions, and builds any (or all) of the four firmware images:
Scripts\setup.bat (first time only - installs arduino-cli, the esp32 core and all libraries)
Scripts\build.bat (pick a target from the menu)
See Scripts/README.md for details. The scripts share the Arduino IDE's board and library folders, so they coexist happily with an IDE setup.