Cards
Air Card
Display an atmospheric pressure reading with a configurable unit using dash::AirCard.
ESP-DASH Pro feature. This functionality is available only in the commercial edition of ESP-DASH.The air card displays an atmospheric pressure reading with a unit, such as the output of a BMP280 or BME680 sensor.

Constructor
dash::AirCard<T, Precision> card(dashboard, name, unit);Prop
Type
Template parameters:
Prop
Type
dash::AirCard pressure(dashboard, "Pressure"); // float, 2 decimals, hPa
dash::AirCard<float, 3> pressureKpa(dashboard, "Pressure", "kPa");
dash::AirCard<int> pressurePa(dashboard, "Pressure", "Pa");An overload without the dashboard argument creates the card without attaching it to a dashboard; attach it later with dashboard.add(card).
Methods
setValue()
bool setValue(T value);Sets the pressure value. Returns true if the value changed and an update is pending.
value()
const T& value() const;Returns the current value. Call it only when hasValue() returns true.
hasValue()
bool hasValue() const;Returns true if a value has been set.
removeValue()
bool removeValue();Clears the value. The dashboard then shows 0. Returns true if a value was removed.
setUnit()
bool setUnit(const char* unit);Sets the unit, for example "hPa" or "kPa". Returns true if the unit changed.
unit()
const char* unit() const;Returns the current unit.
Example
#include <Arduino.h>
#include <WiFi.h> // ESP32; use the networking headers for your board
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <ESPDashPro.h>
AsyncWebServer server(80);
ESPDash dashboard(server);
dash::AirCard<float> pressure(dashboard, "Pressure", "hPa");
void setup() {
// ... connect to Wi-Fi
server.begin();
}
void loop() {
float reading = 1013.25f; // replace with a sensor reading
pressure.setValue(reading);
dashboard.sendUpdates();
delay(3000);
}Notes
- The card stores the
unitpointer and does not copy the string. Pass a string literal or a buffer that outlives the card. - Changing the unit does not convert the value; set a value in the new unit as well.
