Problems with DMX data using DMXSerial

I am using an Arduino Mega and the DMXSerial include file to convert DMX data from a 256 channel NJD Merlin to access various programs and modes within my project.

I checked the DMX signal firstly using a Max485 board and the DmxSerialRecv sketch.
The DMX values were correct when I checked the serial Monitor to verify this.

When I transpose the relevant code into my sketch, I am getting spurious '0’s along with the DMX data

i.e 0,0,0,0,0,120,120,0,0,0,0,120,120,120,120,0,0,0,0,0,0,0,0,0,0,120,120 etc

I have had to write in a workaround by ignoring the '0’s, but this is not an ideal fix.

The DMXSerial.cpp file has been modified to allow data into the Rx1 pin as I am also using Rx0 serial.begin(9600).

I am using additional hardware such as I2C LCD display, nRF24L01 transceiver module,microphone board, Neopixels as well as EEProm for saving settings such as DMX address,RF frequency, Standalone, mic gain.

The program works fine, apart from this DMX receive issue.
When I also read DMX address +1 data, it seems to corrupt the first DMX address data.

I have only been using the Arduino C language for around 6 months, so I am still a newbie so any help would be much appreciated. Not too sure if there is some conflict using some of the other include files or timing sync issues.

My include files are as follows:-

#include <Adafruit_NeoPixel.h>
#include <FastLED.h>
#include <EEPROM.h>
#include <SPI.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DMXSerial.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <math.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // i2c address 0x3F (20 or 27 only)

RF24 radio(22, 24); // CE, CSN   
const byte address[6] = "00001";
boolean buttonState = 0;

//********************************  Set Receive Protocol Variables *************************************
//*************************************** within DataStruct ********************************************

struct dataStruct {
uint8_t   rxData0;    // **** Program Number 1-15 *********
bool      rxData1;    // **** Magic Button Pressed 1-on 0- off *******
uint8_t   rxData2;    // **** Check for interactive programs 0=passive 1=Single Shot 2=Continuous *******
uint8_t   rxData3;    // **** 
uint8_t   rxData4;    // ****
uint8_t   rxData5;    // ****
uint8_t   rxData6;    // **** Sync Mode Number

} myData; 

//********************************  Set Transmit Protocol Variables ************************************
//************************************* within DataStructTx ********************************************

struct dataStructtx {
uint8_t   txData0;      // **** Program Number 1-15 *********
bool      txData1;      // **** Magic Button Pressed 1-on 0- off *******
uint8_t   txData2;      // **** Check for interactive programs 0=passive 1=Single Shot 2=Continuous *******
uint8_t   txData3;      // **** 
uint8_t   txData4;      // **** 
uint8_t   txData5;      // **** 
uint8_t   txData6;      // **** Sync Mode Number   

} myDatatx;

my DMX receive code which is called from within each sub-program:-

//******************* Check for DMX program receving ***************************
void tubeDmxReceive(){
//*************** Check DMX for program number **********************   
    tubeDmxVal =;//Read DMX program value from DMX address
    modeValTemp =;//Read DMX mode value from DMX address +1

    unsigned long lastPacket = DMXSerial.noDataSince();//Time since no DMX packet was received.

    if (lastPacket < 500){//Check for DMX packet within 0.5 secs
       tube_Dmx_On = HIGH;
       //  Turn on DMX LED
       //  digitalWrite(dmxLed,HIGH);
    if (tubeDmxVal >0 && tubeDmxVal <= 255 ){//Stop program from reading 0
            dmxProgTemp = map (tubeDmxVal ,0 ,255 ,1 ,12);
     if (modeValTemp >0 && modeValTemp <=255){//Stop mode from reading 0
      tube_Dmx_On = HIGH;
       if (tubeProg == 4){tubeDmxModeVal = map(modeValTemp ,0 ,255 ,150 ,1);}
       if (tubeProg == 6){tubeDmxModeVal = map(modeValTemp ,0 ,255 ,0 ,6);}
       if (tubeProg == 7){tubeDmxModeVal = map(modeValTemp ,0 ,255 ,1 ,5);}

      if (lastPacket >= 2000)  {//Check for no DMX received for 2 secs
        tube_Dmx_On = LOW;
       //  Turn off DMX Receiving LED
       //  digitalWrite(dmxLed,LOW);

//      Serial.println(tube_Dmx_On);
//      Serial.println(lastPacket);


I have tried just the without calling the DMX read routine, but still get random '0’s along with the DMX value.

The program is 2500 lines of code, so didn’t think it would be advisable to paste it on here, but hopefully someone with more experience can point me in the right direction.

Thanks in advance…

Usually a call to Serial.available() precedes any attempt to read data from a serial connection. Look for it in the sample code.

Thanks for the reply, but I can't find any reference to Serial.available() in the DmxSerialRecv, or RDMSerialRecv sketches provided with the DMXSerial include files.

I assumed the DMXSerial include file dealt with the serial data coming in, as the DMXSerial.noDataSince();
command I call is working ok on the DmxSerialRecv sketch I tried earlier.

Does the incoming data on Port0 add to the incoming data on Port1, or are they totally separate?

Im still a newbie on these Arduinos, and slowly finding my way around the I/O side of things so thankful of any advice or help from the forum.


The available() method is part of the Serial base class. I can't help with the DMX libraries, never used DMX myself.

I forgot to mention that I am running 4 strips of WS2812 LED tape each running 100 LEDs. It appears to be a problem regarding the timing needed using the NeoPixel class.
When I rem out the; to;, the DMX data runs perfectly. As I add the;'s back in 1 at a time, the DMX timing starts to go astray.

From what I have read on the Adafruit site, Neopixel timing is critical and turns off interrupts to do its routine.

I have thought of using an Arduino nano just for the DMX receiving side of things and calculating the values from the DMX data. I can then send serial data I need from the nano to the mega at a more sedate speed of 9600 baud or less via the serial port.
I need bi-directional data to send DMX addresses to read from the mega to the nano.

Would it be advisable to use the SoftwareSerial class to make additional serial ports on the Nano on its digital output ports, as the only serial port on the nano would be needed for the RS485 data.

Im just throwing ideas in, as I mentioned earlier Im still a newbie with Arduino and unfamiliar with the internal workings of the Mega architecture. I do have previous assembly programming knowledge from the early days of the 6502 and Z80 microprocessors and PIC programming using MicroChips MPLab.
I like to use Atmel Studio and have an AVR ISP mkII which I have managed to connect to the Mega via the ICSP header.

Would the fact that Im sending data out to view via the Serial monitor contribute to the DMX timing issue and would I be better using the AVR ISP via Atmel Studio to see realtime register values?