Arduino: DMX Master and Slave


Some time ago I wrote about implementing a DMX master controller using Arduino Uno and MikroElektronika RS-485 click board. Today I will show how to implement a slave DMX node, also based on Arduino and MikroElektronika click boards.

Warning: Use of undefined constant ICL_LANGUAGE_CODE - assumed 'ICL_LANGUAGE_CODE' (this will throw an Error in a future version of PHP) in /home/teodorc8/public_html/wp-content/plugins/insert-php/includes/class.execute.snippet.php(456) : eval()'d code on line 19

Warning: Use of undefined constant ICL_LANGUAGE_CODE - assumed 'ICL_LANGUAGE_CODE' (this will throw an Error in a future version of PHP) in /home/teodorc8/public_html/wp-content/plugins/insert-php/includes/class.execute.snippet.php(456) : eval()'d code on line 22

The required hardware is:

3 pcs. Arduino Uno / Genuino Uno (or any other 5V-based Arduino clone).
3 pcs. Arduino Uno Click Shield
3 pcs. RS-485 click boards
2 pcs. 4×4 RGB click boards

As in many other cases, the hardware is extremely simple to implement: just stick the Arduino Uno click shield on top of the Arduino Uno. Install the RS-485 click boards into slot#1 of the Click Shield. Install the 4×4 RGB clicks into slot #2 of the slave DMX boards.

Parts for the DMX Master and Slave project

Parts for the DMX Master and Slave project

The only thing that requires some care is setting the correct jumper position of the RS-485 click boards: on the master DMX node all jumpers are connected. This setting activates DMX bus terminator and also applies some bias on the RS-485 lines. Biasing has the role in providing a differential voltage to the DMX in idle state so the receivers are held in a known logic state. You can read more about the role of RS-485 / DMX biasing here.
– on the slave node(s) located on ine middle of the DMX bus all jumpers are disconnected.
– on the slave node on the opposite end of the DMX bus only the terminator jumper is connected.

The pictures below show the jumper configuration for all DMX nodes:

To connect the DMX nodes I used Cat5 UTP cable. The wire colors are those recommended by the Electronic Theatre Controls on their DMX-over-Cat5 page: white/orange is for Data+, orange is for Data- and both brown and white/brown wired are connected to the ground terminal. All other data pairs on the UTP cable remain unused.

DMX Master and Slave Arduino code

The code for the DMX master node is largely based on the Conceptinetics DMX library, which I found to be the code library the that works the best with the RS-485 click boards. So, please install this code library first. The same code library is used by the slave nodes. Also, the slave nodes require the Adafruit Neopixel library to be installed. So, as a prerequisite download and install these two code libraries.

Arduino code for DMX master node

Implementation of the code for the master node is explained in detail on my previous post. Here I post only the code for the current project:

Arduino code for DMX slave node

In this project I decided to keep the DMX nodes as simple as possible, and I designed the two nodes to run the same program. Also I have designed the code so all the LED’s on the same node show the same color – just like an architectural light or a PAR projector – as this makes the code easier to understand.

The above code requires both Neopixel and Conceptinetics libraries to be installed. As recommended by MikroElektronika, this project is designed to drive the LED’s at a fraction of their maximum possible output in order to avoid overheating. The maximum LED level is controlled by the variable MAXLEVEL, which was set at a value of 150 (of the maximum 255).

In the initialization part of the code some pin attributions are made to match the hardware. The pin that controls if the RS-485 click is set to transmit or receive setting is pin 6. RX and TX pins are pins 1 and 2 of Arduino Uno. As you may already know from other projects, these are pins used also by the FTDI chip responsible for programming. Thus, both master and slave nodes the switch on the Arduino Uno Click shield MUST be placed in PROG position when programming, and on UART position when running on DMX mode. There is no serial monitor availlable.

Also on the initialization phase we define pin A2 (imposed by hardware) as data pin for the NeoPixels, and we define the number of NeoPixels as 16.

After all the pins are defined we initialize the DMX and the Neopixel libraries.

The most interesting part of the code happens within the OnFrameReceiveComplete function. This function enables us to execute time-sensitive code, as is the case with the Neopixels. So, as a DMS frame is received, the values received are first mapped to match the maximul intensity we previously set, then the new data is sent to the NeoPixels.

That’s all for this code example.

Some ideas to improve the code:

– Each slave node can be set to its own channels, so the slaves will display different color combinations
– Each NeoPixel can be driven independently, a number of three DMX channels being necessary (RGB). Increasing the number of channels will increase the CPU load. At some point there might even arise the need to switch to a more capable board.
– The code for the master node becomes huge when implementing a larger number of DMX effects, especially when using transitions and fades. I’m working towards an advanced code for the master, using a DMX script stored on SD card.



  1. Avatar

    Hi, I was wondering if you have done a version of this with separate led control? I am trying to create and led dmx fixture with separate led control and i’m a bit stuck.

    • Teodor


      By individual control you mean driving the LEDs with PWM? If so, you might take a look to the review of the TINKERKIT DMX receiver MOS. That board does exactly this: it has four DMX channels, so it can drive RGBA LED’s using PWM.
      Even if you don’t have that board, you can use its code example as a starting point, and the power stage used to drive the LEDs is easy to replicate.

  2. Avatar


    is it possible to address every neopixel to a different start channel?
    I need to build up a preview rgb strip where I can preview 4 or 8 channels on a neopixel strip.

    I have 4 rgb floorlights connected via DMX to a DMX controller.
    Each has a different dmx channel (10,20,30,40)
    so I would like to use your project to preview the rgb values on the neopixel strip.
    neopixel 1 shows rgb values from channel 10,11,12
    neopixel 2 shows rgb values from channel 20,21,22
    … etc
    could you please help me with this?

    • Teodor


      In my project only channels 1-3 were used. To add more channels you have to do the following in the receiver part:

      – change the number of channels to 42
      #define SLAVE_CHANNELS 42

      – change number of channels to 4 or 8, depending on your strip
      #define NUMPIXELS 4

      – for Neopixel #1 you will have
      red1 = map ( dmx_slave.getChannelValue(10) ,0 , 255, 0, MAXLEVEL);
      blue1 = map ( dmx_slave.getChannelValue(11) ,0 , 255, 0, MAXLEVEL);
      green1 = map ( dmx_slave.getChannelValue(12) ,0 , 255, 0, MAXLEVEL);

      – for Neopixel #2 you will have
      red2 = map ( dmx_slave.getChannelValue(20) ,0 , 255, 0, MAXLEVEL);
      blue2 = map ( dmx_slave.getChannelValue(21) ,0 , 255, 0, MAXLEVEL);
      green2 = map ( dmx_slave.getChannelValue(22) ,0 , 255, 0, MAXLEVEL);

      and so on…

      Update the Neopixels as follows:

      pixels.setPixelColor(1, pixels.Color(red1,green1,blue1)); // Moderately bright green; // This sends the updated pixel color to the hardware.
      pixels.setPixelColor(2, pixels.Color(red2,green2,blue2)); // Moderately bright green; // This sends the updated pixel color to the hardware.; // This sends the updated pixel color to the hardware.