NodeMCU error trying to use DMXSerial.h library

I am working with DMX, I have successful managed to get a DMX receiver working on a Uno R3 using the DMXSerial library.

Next step is to send some of the received data over Wi-Fi to some other devices.
I already have a master/slave arrangement working over Wi-Fi with NodeMCU devices.

The easiest option would be to now add the DMX receiver code to the existing master NodeMCU device.

To this end, I have tried adding the DMXSerial library to the NodeMCU and it fails to compile.

Not sure what I am missing here.

#include <FastLED.h>
#include <DMXSerial.h>
#include <ESP8266WiFi.h>
#include <WiFiUDP.h>
#include "reactive_common.h"


#define DMX_START_CHANNEL 10  //DMX starting channel (Brightness) channel+1 = 
#define BRIGHTNESS          50 //up to 255
#define NUMBER_OF_CLIENTS 1

const int checkDelay = 5000;
const int numOpModes = 11;

unsigned long lastChecked;

WiFiUDP UDP;

struct led_command {
  uint8_t opmode;
  uint32_t data;
};

bool heartbeats[NUMBER_OF_CLIENTS];

const int opMode = 4;
int old_opMode = 0;


void setup()
{
  
  /* WiFi Part */
  Serial.begin(115200);
  Serial.println();
  Serial.println();
  Serial.print("------------------------------------------------");
  Serial.println();
  Serial.print("Setting soft-AP ... ");
  WiFi.persistent(false);
  WiFi.mode(WIFI_AP);
  WiFi.softAP("sound_reactive", "123456789");
  Serial.print("Soft-AP IP address = ");
  Serial.println(WiFi.softAPIP());
  UDP.begin(7171); 
  resetHeartBeats();
  waitForConnections(); //wait here until we have a connection, the resume
  lastChecked = millis();
 
  /* DMX part */
  //DMXSerial.init(DMXReceiver);
  // set some default values
  //DMXSerial.write(DMX_START_CHANNEL, 0);
  //DMXSerial.write(2, 0);
  //DMXSerial.write(3, 0);
  
}


void loop()
{
  uint32_t analogRaw;
  // Calculate how long no data backet was received
  //unsigned long lastPacket = DMXSerial.noDataSince();

  
  if (millis() - lastChecked > checkDelay) {
    if (!checkHeartBeats()) {
      waitForConnections();
    }
    lastChecked = millis();
  }
  
//    Serial.print("BEFORE IF: opMode = ");
//    Serial.print(opMode);
//    Serial.print(",  old_opMode - ");
//    Serial.print(old_opMode);
//    Serial.println();
//    delay(5000);

  if (opMode != old_opMode){ //if loop has not run before

//    Serial.print("Inside else: opMode = ");
//    Serial.print(opMode);
//    Serial.print(",  old_opMode - ");
//    Serial.print(old_opMode);
//    Serial.println();
//    delay(5000);
    
    switch (opMode) {
      case 1:

        break;
      
      case 2:
        sendLedData(0, opMode);
        delay(10);
        break;
      
      case 3:
        sendLedData(0, opMode);
        delay(10);
        break;
        
      case 4 ... 11:
        Serial.print("Sending Brightness = ");
        Serial.print(BRIGHTNESS);
        Serial.print(",  Sending opMode = ");
        Serial.print(opMode);
//        Serial.print(",  old_opMode - ");
//        Serial.print(old_opMode);
        sendLedData(BRIGHTNESS, opMode);
        delay(10); //was 10
        old_opMode = opMode;
//        Serial.println();
//        Serial.print("old_opMode  after reset - ");
//        Serial.print(old_opMode);
//        Serial.println();
//        Serial.println();
        break;
    }
    
    delay(4);
  }
 
}


void sendLedData(uint32_t data, uint8_t op_mode) 
{
 struct led_command send_data;
 send_data.opmode = op_mode; 
 send_data.data = data; 
 for (int i = 0; i < NUMBER_OF_CLIENTS; i++) 
 {
    IPAddress ip(192,168,4,2 + i);
    UDP.beginPacket(ip, 7001); 
    UDP.write((char*)&send_data,sizeof(struct led_command));
    UDP.endPacket();
 }
}


void waitForConnections() {
  while(true) {
      readHeartBeat();
      if (checkHeartBeats()) {
        return;
      }
      delay(checkDelay);
      resetHeartBeats();
  }
}


void resetHeartBeats() {
  for (int i = 0; i < NUMBER_OF_CLIENTS; i++) {
   heartbeats[i] = false;
  }
}


void readHeartBeat() {
  struct heartbeat_message hbm;
 while(true) {
  int packetSize = UDP.parsePacket();
  if (!packetSize) {
    break;
  }
  UDP.read((char *)&hbm, sizeof(struct heartbeat_message));
  if (hbm.client_id > NUMBER_OF_CLIENTS) {
    Serial.println("Error: invalid client_id received");
    continue;
  }
  heartbeats[hbm.client_id - 1] = true;
 }
}


bool checkHeartBeats() {
  for (int i = 0; i < NUMBER_OF_CLIENTS; i++) {
   if (!heartbeats[i]) {
    return false;
   }
  }
  resetHeartBeats();
  return true;
}

Here is the failure:-

IC:\Users\Paul\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\variants\nodemcu" “-IC:\Users\Paul\OneDrive\Documents\Arduino\libraries\FastLED” “-IC:\Users\Paul\OneDrive\Documents\Arduino\libraries\DMXSerial\src” “C:\Users\Paul\AppData\Local\Temp\arduino_build_98772\sketch\PT_led_master.ino.cpp” -o nul
Alternatives for avr/io.h:
ResolveLibrary(avr/io.h)
→ candidates:
In file included from C:\Users\Paul\OneDrive\Documents\Arduino\PT_led_master\PT_led_master.ino:2:0:

C:\Users\Paul\OneDrive\Documents\Arduino\libraries\DMXSerial\src/DMXSerial.h:39:20: fatal error: avr/io.h: No such file or directory

#include <avr/io.h>

^

compilation terminated.

Using library FastLED at version 3.3.3 in folder: C:\Users\Paul\OneDrive\Documents\Arduino\libraries\FastLED
Using library DMXSerial at version 1.5.0 in folder: C:\Users\Paul\OneDrive\Documents\Arduino\libraries\DMXSerial
exit status 1[/color]
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

Thanks in advance for ideas and suggestions.

I have looked at this again this morning and am still stuck.

If I used the DMXSerial library on a Uno it complies ok (different code but same library).

As soon as I include DMXSerial in my master/slave Wi-Fi program it does not compile.

Could anybody please help as I'm desperate to get this code working today?
I don't even know where to start at the moment.

You won't get it to work on a nodeMCU for cause of a nodeMCU hardware limitation. DMX has a BAUD rate of 250Kbps (be it with inverted polarity and a latch break) and a nodeMCU has a maximum BAUD rate of 115200
If you want it working on an ESP you need an ESP32 or a wemos

C:\Users\Paul\OneDrive\Documents\Arduino\libraries\DMXSerial\src/DMXSerial.h:39:20: fatal error: avr/io.h: No such file or directory

This means that the DMXSerial library needs the register declarations for the AVR processor family (ATmega328P, ATmega2560...). Those registers don't exist on an ESP.

Edit DMXSerial.h to comment out the line that tries to include that file (line 39). You will then get compile errors where the AVR registers are used. You will then need to re-write the DMXSerial library to NOT use AVR registers.

I have only used the DMX Master with this library GitHub - Rickgg/ESP-Dmx: A library to use the ESP8266 as a DMX controller so far. You could give it a try, if it handles the receiver also.

Thank you for your advice.