dmx over wifi led project

Hi, I want to make several strips of leds which won't be physically connected to each other controlled by dmx wirelessly.

I tried to follow a tutorial Using Artnet DMX and the ESP32 to Drive Pixels - SparkFun Learn

I used the MKR1010 board instead of the one in the tutorial. I thought since it uses the esp32 module that it would be compatible with ArtnetWifi Library GitHub - rstephan/ArtnetWifi: Arduino library for Art-Net (artnet) over WiFi, send and receive DMX data. Runs on ESP8266, ESP32, Pi Pico W, WiFi101 and WiFiNINA devices. but doesn't appear to be.

I'm stuck at this point. I don't see any Artnet Wifi Libraries compatible with my board. Is there something I can do to change the library from rstephan to make it work? Is there a better library to use? Any help is appreciated, this is my first Arduino project.

Thanks,
Michele

#include <noise.h>
#include <bitswap.h>
#include <fastspi_types.h>
#include <pixelset.h>
#include <fastled_progmem.h>
#include <led_sysdefs.h>
#include <hsv2rgb.h>
#include <fastled_delay.h>
#include <colorpalettes.h>
#include <color.h>
#include <fastspi_ref.h>
#include <fastspi_bitbang.h>
#include <controller.h>
#include <fastled_config.h>
#include <colorutils.h>
#include <chipsets.h>
#include <pixeltypes.h>
#include <fastspi_dma.h>
#include <fastpin.h>
#include <fastspi_nop.h>
#include <platforms.h>
#include <lib8tion.h>
#include <cpp_compat.h>
#include <fastspi.h>
#include <FastLED.h>
#include <dmx.h>
#include <power_mgt.h>

#include <ArtnetWifi.h>

#include <WiFi.h>
#include <WiFiUdp.h>
#include <ArtnetWifi.h>
#include <FastLED.h>

#include <WiFi.h>
#include <WiFiUdp.h>
#include <ArtnetWifi.h>
#include <FastLED.h>

//Wifi settings - be sure to replace these with the WiFi network that your computer is connected to

const char* ssid = "o2WLAN73";
const char* password = "46848T476676439";

// LED Strip
const int numLeds = 90; // Change if your setup has more or less LED's
const int numberOfChannels = numLeds * 3; // Total number of DMX channels you want to receive (1 led = 3 channels)
#define DATA_PIN 12 //The data pin that the WS2812 strips are connected to.
CRGB leds[numLeds];

// Artnet settings
ArtnetWifi artnet;
const int startUniverse = 0;

bool sendFrame = 1;
int previousDataLength = 0;

// connect to wifi – returns true if successful or false if not
boolean ConnectWifi(void)
{
 boolean state = true;
 int i = 0;

 WiFi.begin(ssid, password);
 Serial.println("");
 Serial.println("Connecting to WiFi");

 // Wait for connection
 Serial.print("Connecting");
 while (WiFi.status() != WL_CONNECTED) {
   delay(500);
   Serial.print(".");
   if (i > 20){
     state = false;
     break;
   }
   i++;
 }
 if (state){
   Serial.println("");
   Serial.print("Connected to ");
   Serial.println(ssid);
   Serial.print("IP address: ");
   Serial.println(WiFi.localIP());
 } else {
   Serial.println("");
   Serial.println("Connection failed.");
 }

 return state;
}

void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
{
 sendFrame = 1;
 // set brightness of the whole strip 
 if (universe == 15)
 {
   FastLED.setBrightness(data[0]);
 }
 // read universe and put into the right part of the display buffer
 for (int i = 0; i < length / 3; i++)
 {
   int led = i + (universe - startUniverse) * (previousDataLength / 3);
   if (led < numLeds)
   {
     leds[led] = CRGB(data[i * 3], data[i * 3 + 1], data[i * 3 + 2]);
   }
 }
 previousDataLength = length;     
 FastLED.show();
}

void setup()
{
 Serial.begin(115200);
 ConnectWifi();
 artnet.begin();
 FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, numLeds);

 // onDmxFrame will execute every time a packet is received by the ESP32
 artnet.setArtDmxCallback(onDmxFrame);
}

void loop()
{
 // we call the read function inside the loop
 artnet.read();
}

error messages

WARNING: library ArtnetWifi-master claims to run on (esp8266, esp32) architecture(s) and may be incompatible with your current board which runs on (avr) architecture(s).
In file included from /Users/TheOracle/Documents/Arduino/libraries/FastLED-3.2.1/noise.h:4:0,
                from /Users/TheOracle/Documents/Arduino/LEDstaves/LEDstaves.ino:1:
/Users/TheOracle/Documents/Arduino/libraries/FastLED-3.2.1/FastLED.h:14:21: note: #pragma message: FastLED version 3.002.001
#    pragma message "FastLED version 3.002.001"
                    ^
/Users/TheOracle/Documents/Arduino/LEDstaves/LEDstaves.ino: In function 'boolean ConnectWifi()':
/Users/TheOracle/Documents/Arduino/LEDstaves/LEDstaves.ino:65:28: warning: invalid conversion from 'const char*' to 'char*' [-fpermissive]
  WiFi.begin(ssid, password);
                           ^
In file included from /Users/TheOracle/Documents/Arduino/LEDstaves/LEDstaves.ino:31:0:
/Applications/Arduino.app/Contents/Java/libraries/WiFi/src/WiFi.h:79:9: note:   initializing argument 1 of 'int WiFiClass::begin(char*, const char*)'
    int begin(char* ssid, const char *passphrase);
        ^
Sketch uses 11402 bytes (35%) of program storage space. Maximum is 32256 bytes.
Global variables use 1349 bytes (65%) of dynamic memory, leaving 699 bytes for local variables. Maximum is 2048 bytes.
avrdude: stk500_recv(): programmer is not responding
WARNING: library ArtnetWifi-master claims to run on (esp8266, esp32) architecture(s) and may be incompatible with your current board which runs on (avr) architecture(s).

What board type did you select?

The mkr1010 has a samd21 chip which your code gets uploaded to. I don't know if/how you can directly upload code to the esp32 chip.

But the samd21 is not avr architecture either, hence my question about board selection.

Also, before you post again, please read the forum guidelines in the sticky post to find out how to post code and error messages correctly, using code tags. Then you can modify your post above and put the code tags in.

Thank you, yes its is mKr1010

Thanks for editing your post. But really, I meant the code and error messages would be in separate code tags, one for the code and one for the error messages.

The bad news is I know nothing about the mkr series Arduino. I always looked at them and thought "who wants that?" because they seem over complicated and expensive.

For your project I would have chosen an esp8266 board. Wemos Mini are my favourite. But then I know little about dmx either, so you had better get a second opinion. This is the Arduino forum, so I'm sure one will be along in a moment...

i wish i new that a few days ago... it seems pretty useless at the moment because nothing works on it. i'm sure that will change but for now i decided to get a different board and try again. i want to use esp because artnet libraries support it.

MicheleFClark:
for now i decided to get a different board and try again

What did you decide?
Oh, and thanks for editing your post again.

PaulRB:
The bad news is I know nothing about the mkr series Arduino. I always looked at them and thought "who wants that?" because they seem over complicated and expensive.

My impression as well.

But then I think the ESP has really taken over from whatever "space" those might have filled and is (8266 at least) ridiculously cheap ...

I got the Adafruit ESP8266 Feather and so far so good. Everything compiled and now I just need to understand somethings about the code and the way artnet works so that I will be able to add more led strips to my system and control them all as one matrix. I'm going to try a few things and if it doesn't work, well I'll ask more questions. If it does work I'll share what I did here.

I got it working, but now once I turn off the board and strip by removing the power source and then plug everything back in I need to also reload the program on board or nothing works, not even the inittest. I want to be able to turn it on and off without having to put the program on every time. Any suggestions or ideas why it is that is happening?

/*
This example will receive multiple universes via Artnet and control a strip of ws2811 leds via 
Adafruit's NeoPixel library: https://github.com/adafruit/Adafruit_NeoPixel
This example may be copied under the terms of the MIT license, see the LICENSE file for details
*/

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <ArtnetWifi.h>
#include <Adafruit_NeoPixel.h>

//Wifi settings
const char* ssid = "o2-WLAN73";
const char* password = "46848T4766776439";

// Neopixel settings
const int numLeds = 90; // change for your setup
const int numberOfChannels = numLeds * 3; // Total number of channels you want to receive (1 led = 3 channels)
const byte dataPin = 2;
Adafruit_NeoPixel leds = Adafruit_NeoPixel(numLeds, dataPin, NEO_GRB + NEO_KHZ800);

// Artnet settings
ArtnetWifi artnet;
const int startUniverse = 0; // CHANGE FOR YOUR SETUP most software this is 1, some software send out artnet first universe as 0.

// Check if we got all universes
const int maxUniverses = numberOfChannels / 512 + ((numberOfChannels % 512) ? 1 : 0);
bool universesReceived[maxUniverses];
bool sendFrame = 1;
int previousDataLength = 0;

// connect to wifi – returns true if successful or false if not
boolean ConnectWifi(void)
{
  boolean state = true;
  int i = 0;

  WiFi.begin(ssid, password);
  Serial.println("");
  Serial.println("Connecting to WiFi");
  
  // Wait for connection
  Serial.print("Connecting");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    if (i > 20){
      state = false;
      break;
    }
    i++;
  }
  if (state){
    Serial.println("");
    Serial.print("Connected to ");
    Serial.println(ssid);
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());
  } else {
    Serial.println("");
    Serial.println("Connection failed.");
  }
  
  return state;
}

void initTest()
{
  for (int i = 0 ; i < numLeds ; i++)
    leds.setPixelColor(i, 127, 0, 0);
  leds.show();
  delay(500);
  for (int i = 0 ; i < numLeds ; i++)
    leds.setPixelColor(i, 0, 127, 0);
  leds.show();
  delay(500);
  for (int i = 0 ; i < numLeds ; i++)
    leds.setPixelColor(i, 0, 0, 127);
  leds.show();
  delay(500);
  for (int i = 0 ; i < numLeds ; i++)
    leds.setPixelColor(i, 0, 0, 0);
  leds.show();
}

void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data)
{
  sendFrame = 1;
  // set brightness of the whole strip 
  if (universe == 15)
  {
    leds.setBrightness(data[0]);
    leds.show();
  }

  // Store which universe has got in
  if ((universe - startUniverse) < maxUniverses)
    universesReceived[universe - startUniverse] = 1;

  for (int i = 0 ; i < maxUniverses ; i++)
  {
    if (universesReceived[i] == 0)
    {
      //Serial.println("Broke");
      sendFrame = 0;
      break;
    }
  }

  // read universe and put into the right part of the display buffer
  for (int i = 0; i < length / 3; i++)
  {
    int led = i + (universe - startUniverse) * (previousDataLength / 3);
    if (led < numLeds)
      leds.setPixelColor(led, data[i * 3], data[i * 3 + 1], data[i * 3 + 2]);
  }
  previousDataLength = length;     
  
  if (sendFrame)
  {
    leds.show();
    // Reset universeReceived to 0
    memset(universesReceived, 0, maxUniverses);
  }
}

void setup()
{
  Serial.begin(115200);
  ConnectWifi();
  artnet.begin();
  leds.begin();
  initTest();

  // this will be called for each packet received
  artnet.setArtDmxCallback(onDmxFrame);
}

void loop()
{
  // we call the read function inside the loop
  artnet.read();
}

You should not need to re-upload the code each time, because it is stored in flash memory, and is not lost when power is removed.

But I can guess what is happening. At power-up, the esp chip is going into upload mode, or some other mode, instead of run mode. This mode is controlled by certain pins. What do you have connected to which pins on the board?

To enter run mode (boot from flash), both GPIO0 and GPIO2 must be HIGH and GPIO15 must be LOW. The feather has components onboard to achieve this, but only if no external circuit prevents it. Do you have anything connected to pins 0, 2 or 15 ?

yes, the data cable from the led strip is on pin 2. I'll change it to a different pin and see if that fixes it. Thank you!

Running the data from another pin causes the inittest to run but nothing else. The board doesn't communicate with my computer over wifi anymore after being unplugged and the powered up again.

What do you see on serial monitor?

When I upload my sketch I see the IP address. After the board has been powered down and turned back on the serial monitor doesn't show anything.

My issue is resolved!

MicheleFClark:
My issue is resolved!

What if someone else, in the future, with the same or similar problem to you, is searching the forum for an answer?