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

Air Card

Display air pressure, wind speed and similar readings with an air icon on the ESP-DASH Pro v4 dashboard.

ESP-DASH Pro feature. This functionality is available only in the commercial edition of ESP-DASH.

The air card displays a value next to an air icon, with an optional unit symbol. Use it for wind speed, air pressure or similar measurements.

Air card

Constructor

Card air(&dashboard, AIR_CARD, "Wind Speed", "km/h");

Prop

Type

Methods

update()

Sets the displayed value. Call dashboard.sendUpdates() afterwards to push the change to connected clients.

air.update(int value);
air.update(float value);
air.update(const String &value);

Pass a second const char* symbol argument to change the symbol at the same time:

air.update(value, "m/s");

Example

main.cpp
#include <Arduino.h>
#if defined(ESP8266)
  #include <ESP8266WiFi.h>
  #include <ESPAsyncTCP.h>
#elif defined(ESP32)
  #include <WiFi.h>
  #include <AsyncTCP.h>
#endif
#include <ESPAsyncWebServer.h>
#include <ESPDash.h>

const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";

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

Card air(&dashboard, AIR_CARD, "Wind Speed", "km/h");

void setup() {
  Serial.begin(115200);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  if (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("WiFi connection failed");
    return;
  }
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

  server.begin();
}

void loop() {
  static unsigned long lastUpdate = 0;
  if (millis() - lastUpdate > 3000) {
    lastUpdate = millis();
    air.update((int)random(0, 100));
    dashboard.sendUpdates();
  }
}

On this page