diff --git a/docs/cli_commands.md b/docs/cli_commands.md index 8772b929fe..9ef7210547 100644 --- a/docs/cli_commands.md +++ b/docs/cli_commands.md @@ -194,6 +194,19 @@ This document provides an overview of CLI commands that can be sent to MeshCore --- +### Show the current battery voltage +**Usage:** `batt` + +**Notes:** +- Reports the board's raw battery reading in millivolts, e.g. `> 4051 mV`. +- Reads the same value the node reports over the mesh in its repeater stats, so + a headless node can be checked locally over USB without a second radio to + query it. +- On a node running from USB this reflects the charging voltage rather than the + battery's resting state. + +--- + ## Configuration ### Radio diff --git a/src/helpers/CommonCLI.cpp b/src/helpers/CommonCLI.cpp index b318bb58e8..8c85a00d7d 100644 --- a/src/helpers/CommonCLI.cpp +++ b/src/helpers/CommonCLI.cpp @@ -273,6 +273,11 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re sprintf(reply, "%s (Build: %s)", _callbacks->getFirmwareVer(), _callbacks->getBuildDate()); } else if (memcmp(command, "board", 5) == 0) { sprintf(reply, "%s", _board->getManufacturerName()); + } else if (memcmp(command, "batt", 4) == 0) { + // Live battery reading. Until now this was only reachable over the mesh + // via REQ_TYPE_GET_STATUS, so a headless node on the bench could not be + // checked without a second radio to ask it. + sprintf(reply, "> %u mV", _board->getBattMilliVolts()); } else if (memcmp(command, "sensor get ", 11) == 0) { const char* key = command + 11; const char* val = _sensors->getSettingByKey(key);