Anniversary Sale · up to 80% off all librariesEnds Nov 9Shop now
SOFTTDocs
You are reading the documentation for ESP-DASH v4.x.x, which is no longer the latest release. View the v5.x.x documentation.

Statistics

Display built-in system metrics and custom key-value statistics on the ESP-DASH v4 Statistics page.

The dashboard includes a dedicated Statistics page that lists key-value pairs. By default, it shows system statistics such as the hardware platform, SDK version, free heap and Wi-Fi signal strength. Since ESP-DASH v4, you can also add your own statistics to this page with the Statistic class.

Statistics page

System statistics can be turned off at any time. See Disable Statistics.

Constructor

Declare statistics in global scope, outside of any function.

Statistic stat1(&dashboard, "Key", "Value");

Prop

Type

ESP-DASH Lite stores the key pointer without copying it, so pass a string literal or a buffer that remains valid for the lifetime of the statistic. The value is copied.

Methods

set(value)

Updates the value of the statistic.

stat1.set("New Value");

set(key, value)

Updates both the key and the value of the statistic.

stat1.set("New Key", "New Value");

ESP-DASH Lite v4.0.9 provides only set(const char* value). The two-argument overload that also changes the key is not available in ESP-DASH Lite.

Example

main.cpp
// ...

AsyncWebServer server(80);
ESPDash dashboard(&server);

Statistic uptime(&dashboard, "Uptime (s)", "0");

void setup() {
  // ...
  server.begin();
}

void loop() {
  uptime.set(String(millis() / 1000).c_str());
  dashboard.sendUpdates();
  delay(3000);
}

On this page