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.

Image Card

Display an image from a URL on the ESP-DASH Pro v4 dashboard with the image card.

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

The image card displays an image loaded from a URL. Use it to show camera snapshots, diagrams or other remotely hosted images on the dashboard.

Image card

Constructor

Card image(&dashboard, IMAGE_CARD, "Camera", "lg");

Prop

Type

Methods

update()

Sets the URL of the image to display. The card shows no image until a URL is set.

image.update(const char* url);

Pass a second argument to change the image size at the same time. Supported sizes are lg and xl:

image.update(const char* url, const char* size);

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

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 image(&dashboard, IMAGE_CARD, "Camera", "lg");

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

  image.update("https://picsum.photos/800/600");

  server.begin();
}

void loop() {
  // ...
}

On this page