Tutorial: https://learn.sparkfun.com/tutorials/sp … shield/all
I’m trying to get this product to work with LED strips, but I’m having difficulties. Wireshark shows output to the correct IP, the LEDs are receiving the input, but it’s not what’s being sent from Resolume. It’s random-ish lights that skip every other LED. Wiring is correct (I verified this like 20 times), I’ve tried the ESP by itself as well as with the DMX shield and I get the same result. Code below.
/*
Read the 5 Channels of DMX Data coming from an ESP32 shield running Example 1
By: Andy England
SparkFun Electronics
Date: , 2018
License: GNU. See license file for more information but you can
basically do whatever you want with this code.
This example runs two servos and a number of LED's off of 5 DMX channels
Feel like supporting open source hardware?
Buy a board from SparkFun! https://www.sparkfun.com/products/15110
Hardware Connections:
Connect pan/tilt servos to pins DATA1 and DATA2, connect LEDs to CLOCK and DATA0. Connect a DMX XLR-3 Cable in between the Output and Input shields
*/
#include <WiFi.h>
#include <WiFiUDP.h>
#include <ArtnetWifi.h> //https://github.com/rstephan/ArtnetWifi
#include <FastLED.h>
// WiFi network name and password:
const char * ssid = "redacted";
const char * password = "redacted";
// Internet domain to request from:
const char * hostDomain = "example.com";
const int hostPort = 80;
const int BUTTON_PIN = 0;
const int LED_PIN = LED_BUILTIN;
// Artnet settings
ArtnetWifi artnet;
WiFiUDP UDPSend;
const int startUniverse = 1;
const int endUniverse = 1;//end Universe should be total channels/512
bool sendFrame = 1;
int previousDataLength = 0;
//Pin Definitions for ESP32 WROOM
#define CLOCK 5
#define DATA0 19
#define DATA1 18
#define DATA2 27
//Channel and Peripheral Definitions
#define NUM_LEDS 64
#define NUM_LED_CHANNELS NUM_LEDS * 3 //Ends up being 360 channels
CRGB leds[NUM_LEDS];
uint8_t hue = 0;
// connect to wifi – returns true if successful or false if not
boolean connectWifi(void)
{
int ledState = 0;
boolean state = true;
int i = 0;
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
Serial.println("Connecting to WiFi network: " + String(ssid));
while (WiFi.status() != WL_CONNECTED) {
// Blink LED while we're connecting:
digitalWrite(LED_PIN, ledState);
ledState = (ledState + 1) % 2; // Flip ledState
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)
{
// read universe and put into the right part of the display buffer
//DMX data should be sent with the first LED in the string on channel 0 of Universe 0
for (int channel = 0; channel < length; channel++)
{
if (channel < NUM_LED_CHANNELS && channel % 3 == 0) //Only write on every 3rd piece of data so we correctly parse things into our RGB array
{
leds[channel / 3] = CRGB(data[channel], data[channel + 1], data[channel + 2]);
}
}
previousDataLength = length;
if (universe == endUniverse) //Display our data if we have received all of our universes, prevents incomplete frames when more universes are concerned.
{
FastLED.show();
UDPSend.flush();
}
}
void setup()
{
Serial.begin(115200);
//Fixture Hardware Declarations
FastLED.addLeds<LPD8806, DATA0, CLOCK, BGR>(leds, NUM_LEDS);
if (connectWifi())
{
Serial.println("Connected to WiFi network: " + String(ssid));
}
artnet.begin();
artnet.setArtDmxCallback(onDmxFrame);
}
void loop()
{
artnet.read();
}