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.Humidity Card
Display humidity readings with a humidity icon and an optional unit symbol on the ESP-DASH v4 dashboard.
The humidity card displays a value next to a humidity icon, with an optional unit symbol such as %.

Constructor
Card humidity(&dashboard, HUMIDITY_CARD, "Humidity", "%");Prop
Type
Methods
update()
Sets the displayed value. Call dashboard.sendUpdates() afterwards to push the change to connected clients.
humidity.update(int value);
humidity.update(float value);
humidity.update(const char* value);
humidity.update(const String &value);Each overload also accepts a second const char* symbol argument that replaces the card's symbol:
humidity.update(value, "RH");Example
#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 humidity(&dashboard, HUMIDITY_CARD, "Humidity", "%");
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();
humidity.update((int)random(30, 70));
dashboard.sendUpdates();
}
}