ESP32-CAM Live Viewer
Upload base64-encoded JPEG frames from your ESP32-CAM and they appear here in real time.
Latest frame
Waiting for upload…No frames yet
Arduino / ESP32-CAM 範例
#include <WiFi.h>
#include <HTTPClient.h>
#include "esp_camera.h"
#include "mbedtls/base64.h"
const char* UPLOAD_URL = "/api/public/upload";
const char* DEVICE_ID = "esp32cam-01";
void sendFrame() {
camera_fb_t* fb = esp_camera_fb_get();
if (!fb) return;
size_t b64_len = 0;
mbedtls_base64_encode(NULL, 0, &b64_len, fb->buf, fb->len);
String b64; b64.reserve(b64_len);
unsigned char* out = (unsigned char*)malloc(b64_len);
mbedtls_base64_encode(out, b64_len, &b64_len, fb->buf, fb->len);
b64.concat((char*)out, b64_len);
free(out);
esp_camera_fb_return(fb);
HTTPClient http;
http.begin(UPLOAD_URL);
http.addHeader("Content-Type", "application/json");
String body = String("{\"device_id\":\"") + DEVICE_ID +
"\",\"mime_type\":\"image/jpeg\",\"image\":\"" + b64 + "\"}";
int code = http.POST(body);
Serial.printf("upload status=%d\n", code);
http.end();
}
void loop() {
sendFrame();
delay(5000); // 每 5 秒拍一張
}