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.

Password Card

Collect passwords and other secrets through a masked input field on the ESP-DASH Pro v4 dashboard.

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

The password card collects sensitive text, such as passwords or secrets. The dashboard masks the input, and the value is not sent back to the dashboard.

Password card

Constructor

Card pass(&dashboard, PASSWORD_CARD, "WiFi Password");

Prop

Type

Callback

The callback fires when the user submits a value on the dashboard. value is the submitted string. Because the value is never displayed on the dashboard, no update() call is required.

pass.attachCallback([&](const char* value) {
  // Store or apply the value
});

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);

String storedPassword;

Card pass(&dashboard, PASSWORD_CARD, "WiFi Password");

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());

  pass.attachCallback([&](const char* value) {
    storedPassword = value;
    Serial.println("Password received");
  });

  server.begin();
}

void loop() {
  // ...
}

Notes

  • The password card does not need update(), since its value is not passed back to the dashboard.

On this page