用 ESP32 与双块 HUB75 LED 面板打造实时互动绘图白板与相框Build a Real-Time Interactive Drawing Board and Photo Frame with ESP32 and Dual HUB75 LED Panels


AI free token/AI免费积分

用 ESP32 与双块 HUB75 LED 面板打造实时互动绘图白板与相框

ESP32 实时 HUB75 网页绘图板与相框(128×64)

将一个 ESP32 和两个串联的 64×64 HUB75 LED 面板组合成一个实时互动的绘图画布和数字照片显示界面。本地网络中的任何人(或通过互联网)都可以在手机、平板或笔记本电脑上打开网页,实时绘制像素、作画,或直接裁剪并上传照片到墙上的显示屏。

硬件说明:如果你之前在我的 ESP32 公交车出发显示项目上使用了 Hackster.io,那么本项目采用完全相同的硬件和接线方式。无需焊接、无需重新布线,也无需更换任何硬件——只需刷入此固件,即可让你的显示屏重获新生。

•实时在线绘图:通过 WebSockets 实现约每秒 60 帧的网页画布同步。快速的鼠标或手指笔触流畅且持续连接,无像素丢失。

•客户端照片裁剪:可直接从你的设备上传任意照片。支持平滑缩放(0.1倍至4倍,支持鼠标滚轮缩放)、拖拽定位取景以及即时客户端缩小至128×64 RGB565分辨率,ESP32无图像处理负担。

•移动端自适应界面:流畅响应的触控手势UI,适配智能手机屏幕,无需横向滚动或意外页面跳转。

•实时亮度控制:屏幕上的平滑滑块(0到150),可实时调节面板亮度。

•内置安全与反垃圾信息功能:采用PIN码保护访问,防止未经授权的用户或机器人覆盖您的画布。包含固件级上传速率限制器,防止用户对视频流进行垃圾发送。

•自托管模式:ESP32通过内部闪存运行整个Web应用程序,无需外部网络托管、云订阅或配套应用。

•5V 2/3A电源(高亮度时灯板需大电流)

•标准HUB75 IDC连接线(通常随灯板附带)

两个 64×64 面板串联连接(菊花链):ESP32 → 面板1 DATA IN → 面板1 DATA OUT → 面板2 DATA IN

重要电源提示:切勿从 ESP32 的 5V/VIN 引脚为 LED 面板供电。请直接使用粗规格螺丝端子电源线,将 5V 和 GND 从您的 5V 电源供应器连接到两个面板。将 ESP32 的 GND 连接到电源的 GND 接地。在 ESP32 的 5V 和 GND 引脚之间并联一个 100µF–470µF 的电容。WiFi 传输会产生约 300mA 的射频脉冲;该电容可防止系统因断电而重启。

前往“文件”>“首选项”,添加 ESP32 板件管理器的 URL:

前往“工具”>“板子”>“板子管理器...”,搜索 esp32,然后通过 Espressif 平台安装 esp32。

打开“工具”>“管理库”... 并安装以下内容:

•WebSockets,由 Markus Sattler 提供(版本 2.3.5 或更高)

设置自定义安全 PIN(默认为 1234):

•在“工具”>“板子”中选择您的板子(ESP32 Dev Module)。

•将分区方案设置为“大型应用”(3MB,无 OTA/1MB SPIFFS)或“默认 4MB + FAT 文件系统”。

当 ESP32 启动后,它会连接到您的 Wi-Fi,并直接在 LED 屏幕上显示其分配的 IP 地址(例如:192.168.1.150)。

在手机、平板或电脑上打开浏览器,访问以下网址:

解锁:系统会弹出锁屏提示,要求您输入 PIN。请输入 1234(或您在代码中设置的任意 PIN)。浏览器会将此令牌保存在本地存储中,因此您无需每次重新输入。

绘画:选择颜色、画笔大小(1px、2px、3px)或橡皮擦工具,在画布上进行绘制。

上传照片:点击“ 选择并裁剪图片”,选择一张图片,放大或缩小,拖动以居中主体,然后点击“✂️ 应用并发送至矩阵”。

调整亮度:拖动亮度滑块(0–150),使其与房间照明相匹配。

传统浏览器的 touchmove 和 mousemove 事件会被限制在屏幕刷新率(60 Hz)范围内,并在快速滑动时丢失中间点。本网页界面采用现代的 Pointer Events API,结合 e.getCoalescedEvents() 方法,捕捉高频微小移动。它每16毫秒将这些数据打包成一个轻量级的二进制多边形数据包(0x05),由 ESP32 使用布雷森汉线算法进行渲染。快速绘制的线条保持完全连续,无断开间隙。

ESP32 没有足够的空闲内存来解码 JPEG/PNG 图像或调整其尺寸。网页界面在客户端设备的 HTML5 Canvas 中完成图像解码和裁剪的全部工作。它直接将选定帧降采样至 128×64 像素,将其打包为 16 位 RGB565 颜色字节,并以 4 行为一组通过 WebSocket 流式传输。

HUB75 胶带电缆传输高速 10 MHz 方波,会产生明显的 2.4 GHz 射频噪声。在此固件中,Wi-Fi 连接和 WPA2 握手会在矩阵 DMA 引擎启动前完成,并将 Wi-Fi 功率锁定在最大发射功率(WIFI_POWER_19_5dBm)。这确保了即使距离路由器超过 10 米远,也能通过墙壁实现稳定可靠的连接。

为了让网络外的朋友也能访问屏幕,我使用自建服务器通过 NPM 进行代理,并通过 Cloudflare Tunnel 将服务暴露到我的域名上。

网页界面会自动检测 HTTPS 和域名,从标准的 ws://:81 切换为通过端口 443 的安全 wss:///ws。

本文来源:https://www.21ic.com/a/1017394.html
若有版权问题,请来信告知:13951431913#139.com 或在右方提交评论。

Build a Real-Time Interactive Drawing Board and Photo Frame with ESP32 and Dual HUB75 LED Panels

ESP32 Real-Time HUB75 Web Drawing Board & Photo Frame (128×64)

Combine an ESP32 with two daisy-chained 64×64 HUB75 LED panels into a real-time interactive drawing canvas and digital photo display. Anyone on the local network (or over the internet) can open a web page on their phone, tablet, or laptop to draw pixels in real time, create artwork, or simply crop and upload a photo to the display on the wall.

Hardware note: If you previously used Hackster.io for my ESP32 bus departure display project, this project uses exactly the same hardware and wiring. No soldering, no rewiring, and no hardware changes needed—just flash this firmware to give your display a new lease on life.

• Real-time online drawing: WebSockets enable web canvas synchronization at about 60 frames per second. Fast mouse or finger strokes are smooth and continuously connected, with no lost pixels.

• Client-side photo cropping: Upload any photo directly from your device. Supports smooth zooming (0.1× to 4×, with mouse wheel zoom), drag-to-position framing, and instant client-side downscaling to 128×64 RGB565 resolution, with no image-processing burden on the ESP32.

• Mobile-adaptive interface: Smooth, responsive touch-gesture UI that fits smartphone screens, with no horizontal scrolling or accidental page jumps.

• Real-time brightness control: A smooth on-screen slider (0 to 150) adjusts panel brightness in real time.

• Built-in security and anti-spam features: PIN-protected access prevents unauthorized users or bots from overwriting your canvas. Includes a firmware-level upload rate limiter to prevent users from spamming the video stream.

• Self-hosted mode: The ESP32 runs the entire web application from its internal flash memory, with no external web hosting, cloud subscription, or companion app required.

• 5V 2/3A power supply (the panels need high current at high brightness)

• Standard HUB75 IDC cable (usually included with the panels)

Two 64×64 panels connected in series (daisy chain): ESP32 → Panel 1 DATA IN → Panel 1 DATA OUT → Panel 2 DATA IN

Important power warning: Never power the LED panels from the ESP32's 5V/VIN pin. Use a thick-gauge screw-terminal power cable to connect 5V and GND directly from your 5V power supply to both panels. Connect the ESP32's GND to the power supply's GND. Place a 100µF–470µF capacitor in parallel between the ESP32's 5V and GND pins. WiFi transmission produces RF pulses of about 300mA; this capacitor prevents the system from rebooting due to power drops.

Go to File > Preferences and add the ESP32 board manager URL:

Go to Tools > Board > Boards Manager..., search for esp32, and install esp32 via the Espressif platform.

Open Tools > Manage Libraries... and install the following:

• WebSockets by Markus Sattler (version 2.3.5 or higher)

Set a custom security PIN (default 1234):

• Select your board under Tools > Board (ESP32 Dev Module).

• Set the partition scheme to "Large App" (3MB no OTA/1MB SPIFFS) or "Default 4MB with FAT filesystem".

When the ESP32 boots, it connects to your Wi-Fi and displays its assigned IP address directly on the LED screen (e.g., 192.168.1.150).

Open a browser on your phone, tablet, or computer and go to:

Unlock: A lock screen prompt will ask you to enter the PIN. Enter 1234 (or whatever PIN you set in the code). The browser saves this token in local storage, so you won't need to re-enter it each time.

Draw: Select a color, brush size (1px, 2px, 3px), or the eraser tool, and draw on the canvas.

Upload a photo: Click "Choose and Crop Image", select an image, zoom in or out, drag to center the subject, then click "✂️ Apply and Send to Matrix".

Adjust brightness: Drag the brightness slider (0–150) to match the room lighting.

Conventional browsers' touchmove and mousemove events are limited to the screen refresh rate (60 Hz) and drop intermediate points during fast swipes. This web interface uses the modern Pointer Events API combined with the e.getCoalescedEvents() method to capture high-frequency tiny movements. Every 16 milliseconds it packs these data into a lightweight binary polyline packet (0x05), which the ESP32 renders using Bresenham's line algorithm. Fast-drawn lines stay completely continuous with no broken gaps.

The ESP32 doesn't have enough free memory to decode JPEG/PNG images or resize them. The web interface does all the image decoding and cropping work client-side in the HTML5 Canvas of your device. It downsamples the selected frame directly to 128×64 pixels, packs it into 16-bit RGB565 color bytes, and streams it via WebSocket in groups of 4 rows.

The HUB75 ribbon cable carries high-speed 10 MHz square waves, generating noticeable 2.4 GHz RF noise. In this firmware, the Wi-Fi connection and WPA2 handshake complete before the matrix DMA engine starts, and Wi-Fi power is locked at maximum transmit power (WIFI_POWER_19_5dBm). This ensures a stable, reliable connection through walls even at distances of more than 10 meters from the router.

To let friends outside the network access the display, I used a self-hosted server proxied through NPM and exposed the service to my domain via Cloudflare Tunnel.

The web interface automatically detects HTTPS and a domain name, switching from standard ws://:81 to secure wss:///ws over port 443.

本文来源:https://www.21ic.com/a/1017394.html
若有版权问题,请来信告知:13951431913#139.com 或在右方提交评论。

暂无评论,快来发表第一条评论吧!No comments yet. Be the first!

📮 需求咨询📮 Inquiry