A simple and efficient Art-Net DMX512 controller implementation in Rust for controlling lighting fixtures over Ethernet.
This project provides a lightweight Rust implementation for controlling Art-Net nodes. Art-Net is an Ethernet protocol for transmitting DMX512 lighting control data, commonly used in stage lighting, architectural lighting, and entertainment applications.
- ๐ Simple and intuitive API
- ๐ฆ Minimal dependencies
- ๐จ Control up to 512 DMX channels per universe
- ๐ Support for multiple Art-Net universes
- โก High-performance UDP communication
- ๐ง Easy integration into existing projects
- ๐ Well-documented code examples
- Rust 1.70.0 or higher (Install Rust)
- An Art-Net compatible node or software (e.g., QLC+, Enttec ODE, DMXKing)
- Basic network connectivity
git clone https://github.com/ThePhoenixPixel/artnet-rust.git
cd artnet-rustcargo buildcargo run --example examplesuse artnet::controller::ArtNetController;
use artnet::package::ArtNetDmxPacket;
use bx::network::address::Address;
use std::time::Duration;
use std::thread;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Configure your Art-Net node IP address
let address = Address::new(&"192.168.178.125".to_string(), &6454);
// Create controller instance
let mut controller = ArtNetController::new(address.clone())?;
// Create a DMX packet for Universe 0
let mut packet = ArtNetDmxPacket::new(0);
// Set channel values (1-512, values 0-255)
packet.set_channel(1, 255);
packet.set_channel(2, 128);
packet.set_channel(3, 0);
packet.set_channel(4, 0);
// Send the packet
controller.send_dmx(packet)?;
Ok(())
}Control individual DMX channels with specific values:
let mut packet = ArtNetDmxPacket::new(0); // Universe 0
packet.set_channel(1, 255); // Channel 1: 100%
packet.set_channel(2, 255); // Channel 2: 100%
packet.set_channel(3, 255); // Channel 3: 100%
packet.set_channel(4, 255); // Channel 4: 100%
controller.send_dmx(packet)?;
println!("โ Channels 1-4 set to 255 (100%)");Use arrays for efficient multi-channel control:
let mut packet = ArtNetDmxPacket::new(0);
packet.set_channels(1, &[255, 0, 0, 255]); // Channels 1-4
controller.send_dmx(packet)?;
println!("โ Channels 1,4: 255 (100%) | Channels 2,3: 0 (0%)");Create dynamic lighting effects with gradual transitions:
println!("Starting fade effect...");
for brightness in (0..=255).step_by(5) {
let mut packet = ArtNetDmxPacket::new(0);
packet.set_channel(1, 0);
packet.set_channel(2, 0);
packet.set_channel(3, brightness);
controller.send_dmx(packet)?;
thread::sleep(Duration::from_millis(20));
}
println!("โ Fade complete");Control RGB fixtures with ease:
// Red
let mut packet = ArtNetDmxPacket::new(0);
packet.set_channels(1, &[255, 0, 0]);
controller.send_dmx(packet)?;
thread::sleep(Duration::from_secs(1));
// Green
packet.set_channels(1, &[0, 255, 0]);
controller.send_dmx(packet)?;
thread::sleep(Duration::from_secs(1));
// Blue
packet.set_channels(1, &[0, 0, 255]);
controller.send_dmx(packet)?;let packet = ArtNetDmxPacket::new(0);
// All channels default to 0
controller.send_dmx(packet)?;
println!("โ All lights off");Update the IP address in your code:
// Replace with your Art-Net node's IP address
let address = Address::new(&"192.168.178.125".to_string(), &6454);Note: Art-Net typically uses UDP port
6454
Art-Net supports multiple universes (0-32767), each with 512 channels:
let packet = ArtNetDmxPacket::new(0); // Universe 0
let packet = ArtNetDmxPacket::new(1); // Universe 1DMX512 provides 512 channels per universe with values ranging from 0-255:
0= Off / Minimum127= 50%255= On / Maximum
Channel 1: Red (0-255)
Channel 2: Green (0-255)
Channel 3: Blue (0-255)
Channel 1: Red
Channel 2: Green
Channel 3: Blue
Channel 4: White
Channel 1: Red
Channel 2: Green
Channel 3: Blue
Channel 4: White
Channel 5: Amber
Channel 1: Brightness (0-255)
Tip: Always consult your fixture's manual for the exact DMX channel mapping!
Problem: Cannot connect to Art-Net node
Solutions:
- โ Verify the IP address is correct
- โ Check both devices are on the same network/subnet
- โ Disable firewall or allow UDP port 6454
- โ
Try broadcast address
255.255.255.255for discovery - โ Ensure the Art-Net node is powered on and connected
Problem: Lights don't respond to commands
Solutions:
- โ Verify DMX addresses on your fixtures
- โ Check universe number matches your node configuration
- โ Confirm channel mapping in fixture manual
- โ Test with Art-Net viewer software (e.g., QLC+)
- โ Check network traffic with Wireshark
Problem: Choppy or laggy light updates
Solutions:
- โ Limit DMX update rate to ~44 Hz (max for DMX512)
- โ Add appropriate delays between updates
- โ Reduce packet sending frequency
- โ Check network bandwidth and latency
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Art-Netโข is a trademark of Artistic Licence Holdings Ltd.
- Thanks to the Rust community for excellent tools and libraries
- ๐ญ Stage Lighting: Control theater and concert lighting
- ๐๏ธ Architectural Lighting: Building and monument illumination
- ๐ Event Production: DJ setups, weddings, corporate events
- ๐ Home Automation: Smart home lighting integration
- ๐จ Art Installations: Interactive light art
- ๐ฎ Entertainment: Theme parks, escape rooms
Made with โค๏ธ and Rust
If you find this project helpful, please consider giving it a โญ!