Skip to content

About

Firmware for ESP32-C6 to act as a bridge between Phillips Hue (Zigbee) and multiple DMX controlled RGB(W) wash lights

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

15 Commits

Folders and files

Repository files navigation

Zigbee DMX Bridge

ESP32-C6 firmware that bridges Philips Hue (Zigbee) to DMX512 lighting fixtures. Each configured light appears as a separate Zigbee Extended Color Light on the Hue Bridge and outputs color/brightness via wired DMX512 or ArtNet (UDP).

Hue Bridge  ──(Zigbee ZCL)──>  ESP32-C6  ──(DMX512 / ArtNet)──>  RGB/RGBW fixtures
                                    │
                              Web config UI
                            (light definitions,
                             output settings)

Features

  • Browser-based installer — flash directly from netmindz.github.io/zigbee_dmx using ESP Web Tools (Chrome/Edge, no build tools needed)
  • Hue-compatible Zigbee endpoints — each configured light appears as a separate Extended Color Light (device ID 0x010D) on the Philips Hue Bridge, with full multi-endpoint discovery support
  • Dual output modes — wired DMX512 via RS-485 transceiver, or ArtNet (Art-Net DMX over UDP unicast/broadcast), selectable from the web UI
  • Up to 16 RGB/RGBW lights — each with configurable DMX start address and channel-to-offset mapping
  • Web configuration UI — captive portal for initial WiFi setup, light management, output mode selection
  • Config persistence — all settings stored in NVS (ESP32 Preferences), survive reboots
  • CIE XY and Hue/Saturation color support — full color control from the Hue app
  • Color temperature support — Hue CT (mirek) commands are converted to RGB for DMX output
  • RGBW white channel decomposition — for RGBW fixtures, the white channel is automatically extracted from RGB values (W = min(R, G, B)) producing cleaner whites and more efficient fixture use
  • Proven Hue Bridge compatibility — implements all critical pairing requirements discovered through extensive testing (End Device mode, ZLL distributed security, app_device_version=1, raw ZCL command handling)

Hardware Requirements

  • ESP32-C6-DevKitC-1 (8MB flash) — or any ESP32-C6 board with 802.15.4 radio
  • RS-485 transceiver (MAX485, SN75176, etc.) — for wired DMX512 output
    • TX pin and enable pin configurable via web UI (defaults: GPIO2 TX, GPIO4 EN)
  • DMX512-compatible fixtures — RGB or RGBW LED pars, wash lights, etc.

For ArtNet mode, no additional hardware is needed beyond the ESP32-C6 and a WiFi network.

Building

This is a PlatformIO project targeting the ESP32-C6 with Arduino framework and ESP-IDF v5.5.

# Install PlatformIO CLI (if not already installed)
pip install platformio

# Build
pio run

# Build and upload
pio run -t upload

# Monitor serial output
pio device monitor -b 115200

Partition Table

The firmware uses a custom 8MB partition layout (partitions/zigbee_dmx_8MB.csv) that includes:

  • Two OTA app partitions (3MB each)
  • NVS for configuration storage
  • zb_storage and zb_fct partitions required by the Zigbee stack
  • SPIFFS partition for future use

First-Time Setup

  1. Flash the firmware to the ESP32-C6
  2. Connect to the captive portal — the device starts a WiFi AP named ZigbeeDMX-Setup (open, no password)
  3. Configure WiFi — enter your network SSID and password in the web UI. The device restarts and connects to your network.
  4. Access the web UI — browse to the device's IP address (check serial output or your router's DHCP table)
  5. Add lights — define your DMX fixtures with name, type (RGB/RGBW), DMX start address, and channel mapping
  6. Configure output — select Wired DMX or ArtNet mode, set pin assignments or ArtNet universe
  7. Pair with Hue Bridge — open the Hue app, go to Settings > Lights > Search. The device should appear as a new light.

Web UI

The web interface is accessible at http://<device-ip>/ and provides:

  • Status bar — WiFi connection, Zigbee pairing status, light count
  • Light configuration — add, edit, delete lights with DMX address and channel mapping
  • Output settings — switch between wired DMX and ArtNet, configure pins/universe
  • Factory reset — clears all configuration including WiFi credentials

REST API

Endpoint Method Description
/api/status GET Device status (WiFi SSID, Zigbee, output mode)
/api/config GET Full configuration (lights + output settings)
/api/config POST Update configuration (JSON body)
/api/lights/state GET Current per-light RGB(W)/brightness state
/api/wifi POST Set WiFi credentials (triggers restart)
/api/factory-reset POST Erase all config and restart

Output Modes

Wired DMX512

Uses UART1 at 250kbaud through an RS-485 transceiver. The BREAK signal is generated by temporarily switching to a lower baud rate (~91kbaud). The transceiver enable pin is held HIGH during transmission.

Default pin assignment (configurable via web UI):

  • TX: GPIO2
  • EN: GPIO4 (-1 to disable)

ArtNet

Sends Art-Net OpDmx (0x5000) UDP packets at ~2Hz. Supports unicast to a configurable target IP (recommended) or broadcast to 255.255.255.255. Compatible with any ArtNet-capable DMX node or software (e.g., OLA, QLC+, MagicQ).

Settings (configurable via web UI):

  • Universe: 0-32767
  • Target IP: unicast address (leave blank for broadcast)

Hue Bridge Pairing

The firmware implements several critical requirements for Philips Hue Bridge V2 compatibility:

  1. End Device mode — Hue rejects Router joins to its distributed network
  2. Distributed security with ZLL link key — the well-known ZLL distributed link key is required for Hue's network
  3. app_device_version = 1 — Hue requires this in the endpoint Simple Descriptor
  4. Extra on_off attributes — global_scene_control, on_time, off_wait_time
  5. Minimum join LQI = 0 — PCB antennas often produce low LQI values
  6. Raw ZCL command handler — required because:
    • Hue sends off_with_effect (0x40) instead of plain off, which ZBOSS silently ignores
    • Hue sends manufacturer-specific scene commands (0x100b) that crash ZBOSS
    • SET_ATTR_VALUE_CB doesn't fire for ZCL commands like move_to_color
  7. WiFi/802.15.4 coexistence — enabled before WiFi starts, re-applied on WiFi reconnect

Multi-Endpoint Support

Each configured light gets its own Zigbee endpoint with spaced numbering (endpoints 10, 20, 30, ...) and device ID 0x010D (Extended Color Light). This matches the approach used by commercial multi-output Zigbee controllers (e.g., Gledopto 2ID) and ensures the Hue Bridge discovers all endpoints as separate lights.

After changing the number of lights, you must:

  1. Restart the device (endpoints are registered at Zigbee stack startup)
  2. Delete the old light(s) from the Hue Bridge
  3. Erase the Zigbee storage partition: esptool.py erase_region 0x650000 0x4000
  4. Re-pair by running "Search for lights" in the Hue app

Development Tools

Hue Bridge Debug Tool

# Prerequisites
pip install requests

# Auto-discover bridge, show overview
python3 tools/hue_debug.py

# Specify bridge IP
python3 tools/hue_debug.py --bridge-ip 192.168.178.216

# Also query the ESP32 device status
python3 tools/hue_debug.py --device-ip 192.168.178.110

# Trigger a new light search
python3 tools/hue_debug.py --search

# Analyze discovered endpoints
python3 tools/hue_debug.py --endpoints

# Inspect a specific light
python3 tools/hue_debug.py --light-id 25 --raw

# Delete a light (for re-pairing)
python3 tools/hue_debug.py --delete-light 25

The API key is auto-generated on first use (requires pressing the Hue Bridge link button) and persisted to .hue_api_key (git-ignored).

Integration Test

End-to-end test that verifies Hue API light state changes are reflected in ArtNet DMX output.

# Prerequisites
pip install requests

# Run tests against a paired device
python3 tools/integration_test.py --device-ip 192.168.178.110

# Specify bridge IP and light ID explicitly
python3 tools/integration_test.py --bridge-ip 192.168.178.216 --light-id 25

# Run specific test suite
python3 tools/integration_test.py --device-ip 192.168.178.110 --test color

# Skip ArtNet verification (Hue API round-trip only)
python3 tools/integration_test.py --device-ip 192.168.178.110 --skip-artnet

Test suites:

  • onoff — verifies ON/OFF state propagates to DMX channels
  • color — tests saturated red/green/blue via CIE xy coordinates
  • brightness — tests brightness scaling at multiple levels
  • accuracy — compares actual DMX values against expected values from the CIE XY -> RGB conversion
  • colortemp — tests color temperature (mirek) control and RGB conversion
  • rgbw — tests RGBW white channel decomposition accuracy and correctness across colors, brightness levels, and color temperatures

The test auto-discovers all lights belonging to the device and runs all suites against each light independently. RGBW-specific tests run only against lights configured as RGBW. With 2 lights configured (1 RGB + 1 RGBW), the full suite runs 180 tests.

Project Structure

zigbee_dmx/
├── platformio.ini              # PlatformIO configuration
├── partitions/
│   └── zigbee_dmx_8MB.csv     # Custom 8MB partition table
├── include/
│   ├── config_store.h          # Configuration types and storage API
│   ├── dmx_output.h            # DMX output (wired + ArtNet)
│   ├── web_ui.h                # Web server and WiFi management
│   └── zigbee_manager.h        # Zigbee stack management
├── src/
│   ├── main.cpp                # Entry point, main loop
│   ├── config_store.cpp        # NVS persistence, JSON serialization
│   ├── dmx_output.cpp          # Wired DMX (UART) and ArtNet (UDP) output
│   ├── web_ui.cpp              # Web UI, REST API, captive portal
│   └── zigbee_manager.cpp      # Zigbee endpoints, Hue compatibility
└── tools/
    ├── hue_debug.py            # Hue Bridge query/debug tool
    └── integration_test.py     # End-to-end ArtNet verification test

Configuration JSON Format

The configuration exchanged via /api/config follows this format:

{
  "output": {
    "mode": "artnet",
    "txPin": 2,
    "enPin": 4,
    "artnetUniverse": 0
  },
  "lights": [
    {
      "name": "Stage Left",
      "type": "RGB",
      "dmxAddr": 1,
      "channelMap": { "r": 0, "g": 1, "b": 2 }
    },
    {
      "name": "Stage Right",
      "type": "RGBW",
      "dmxAddr": 4,
      "channelMap": { "r": 0, "g": 1, "b": 2, "w": 3 }
    }
  ]
}

Known Issues

  • Zigbee reconfiguration requires restart — changing the number of lights requires a device reboot and re-pair for Zigbee endpoints to be recreated (endpoints are registered at stack startup and cannot be dynamically changed).
  • WiFi/Zigbee coexistence — the 2.4GHz WiFi and 802.15.4 Zigbee share the same radio band. Coexistence is enabled, but expect 1-2s ping latency and occasional packet loss. HTTP requests to the device should use generous timeouts (20s) and retries.
  • OTA unreliable — firmware uploads over WiFi frequently fail due to coexistence. Use USB serial for flashing.

References

License

This project is provided as-is for educational and development purposes.

About

Firmware for ESP32-C6 to act as a bridge between Phillips Hue (Zigbee) and multiple DMX controlled RGB(W) wash lights

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages