An ESP32 and Eight ToF Sensors Give This Antique Lamp a Sixth Sense
An ESP32 and Eight ToF Sensors Give This Antique Lamp a Sixth Sense
ESP32 与八个 ToF 传感器赋予这盏古董灯“第六感”
What if a floor lamp could feel you crossing the room and answer with light and sound? That is the trick behind Bloom Chandelier, an interactive installation built around a brass floor lamp handed down from the maker’s great-grandmother. 如果一盏落地灯能感知到你穿过房间,并以光影和声音作为回应,会怎样?这就是“Bloom Chandelier”背后的奥秘,这是一个互动装置,其核心是一盏从创作者曾祖母那里传下来的黄铜落地灯。
Instead of a switch, the lamp watches the space around it. Walk closer and it glows brighter while soft tones swell up from nowhere. Step away and both the light and the sound fade back into silence, leaving a short trail behind you like a wake. 这盏灯不再使用开关,而是通过“观察”周围的空间来运作。当你走近时,它会变得更亮,同时柔和的音调会凭空响起。当你走开时,光线和声音会逐渐消退,归于寂静,并在你身后留下一道如同尾迹般的余韵。
How does it know you are there? Eight VL53L1X time-of-flight sensors ring the lamp’s collar, giving it a full 360-degree view that reaches roughly four feet out. These are not motion detectors. Each one measures actual distance many times a second, so the firmware can react to how near you are rather than just whether you moved. 它是如何感知到你的存在的?八个 VL53L1X 飞行时间(ToF)传感器环绕在灯座周围,使其拥有了约四英尺(约 1.2 米)范围内的 360 度全方位视野。这些并非普通的运动检测器,每一个传感器每秒都会多次测量实际距离,因此固件可以根据你的距离远近做出反应,而不仅仅是判断你是否移动。
The catch: every VL53L1X ships with the same default I2C address, so eight of them on one bus would collide instantly. The wiring answer: An Adafruit HUZZAH32 ESP32 Feather runs the show, talking to the sensors through a PCA9548A eight-channel I2C multiplexer. The code polls each sensor one at a time in a round-robin loop, switching multiplexer channels so no two sensors ever share the bus at once. Aiming each sensor outward also keeps their infrared beams from bleeding into each other. 难点在于:每个 VL53L1X 出厂时都带有相同的默认 I2C 地址,因此如果将八个传感器连接到同一总线上,会立即发生冲突。解决方案是:使用一块 Adafruit HUZZAH32 ESP32 Feather 开发板作为核心,通过 PCA9548A 八通道 I2C 多路复用器与传感器通信。代码以循环轮询的方式逐一读取每个传感器,通过切换多路复用器通道,确保同一时间只有一个传感器占用总线。将每个传感器向外对准,也防止了它们的红外光束相互干扰。
Those distance readings drive a 59-pixel warm-white LED strip split into eight zones, one per sensor, with brightness following a squared proximity curve so the glow ramps up fast as you approach. The same numbers stream over USB serial to a Raspberry Pi 4 Model B, where a Python engine maps each sensor to one note of a two-octave C major pentatonic scale. The notes are not synth patches but recordings of fingers circling wine-glass rims, pitch-shifted in SciPy from four sampled anchors. 这些距离读数驱动着一条 59 像素的暖白光 LED 灯带,灯带被分为八个区域,每个区域对应一个传感器。亮度遵循平方接近曲线,因此当你靠近时,光芒会迅速增强。同样的数值通过 USB 串口传输到树莓派 4 Model B,其中的 Python 引擎将每个传感器映射到两个八度 C 大调五声音阶中的一个音符。这些音符并非合成器音色,而是手指摩擦酒杯边缘的录音,通过 SciPy 从四个采样锚点进行变调处理。
Try a smaller version: You do not need eight sensors to learn the core ideas here. Wire a single VL53L1X to an ESP32 over I2C, read the distance, and map it to the brightness of one LED. Once that works, add a PCA9548A and a second sensor to practice channel switching, the exact skill that lets Bloom Chandelier scale to eight. The full write-up, sensor pinouts, and build photos are on the Hackster project page. 尝试简化版本:你不需要八个传感器就能掌握其中的核心理念。只需将一个 VL53L1X 通过 I2C 连接到 ESP32,读取距离并将其映射到一个 LED 的亮度上。一旦成功,再添加一个 PCA9548A 和第二个传感器来练习通道切换——这正是让 Bloom Chandelier 扩展到八个传感器的关键技术。完整的项目说明、传感器引脚图和制作照片可以在 Hackster 项目页面上找到。