Thought I would start a thread for sharing working sketches .
This is for esp8266 wemos . Uses FastLed & older E131
May also work on Esp-01, not tested
This is for esp8266 wemos . Uses FastLed & older E131
May also work on Esp-01, not tested
Code:
/*
E131_Test.ino - Simple sketch to listen for E1.31
Project: E131 ESP8266 and FastLed
Copyright (c) Shelby Merrick
http://www.forkineye.com
This program is provided free for you to use in any way that you wish,
subject to the laws and regulations where you are using it. Due diligence
is strongly suggested before using this code. Please give credit where due.
The Author makes no warranty of any kind, express or implied, with regard
to this program or the documentation contained in this document. The
Author shall not be liable in any event for incidental or consequential
damages in connection with, or arising out of, the furnishing, performance
or use of these programs.
*/
#include <ESP8266WiFi.h>
#include <E131.h>
#include <FastLED.h>
#define UNIVERSE 1 // First DMX Universe to listen for
#define CHANNEL_START 1
#define DATA_PIN 2
#define NUM_LEDS 170
CRGB newLeds[NUM_LEDS];
const char ssid[] = "SSID"; // Replace with your SSID
const char passphrase[] = "PASSWORD"; // Replace with your WPA2 passphrase
// ESPAsyncE131 instance with UNIVERSE_COUNT buffer slots
E131 e131;
void setup() {
Serial.begin(115200);
delay(10);
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(newLeds, NUM_LEDS);
// Make sure you're in station mode
WiFi.mode(WIFI_STA);
Serial.println("");
Serial.print(F("Connecting to "));
Serial.print(ssid);
if (passphrase != NULL)
WiFi.begin(ssid, passphrase);
else
WiFi.begin(ssid);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print(F("Connected with IP: "));
Serial.println(WiFi.localIP());
// Choose one to begin listening for E1.31 data
//if (e131.begin(E131_UNICAST)) // Listen via Unicast
//if (e131.begin(E131_MULTICAST, UNIVERSE, UNIVERSE_COUNT)) // Listen via Multicast
e131.beginMulticast(ssid, passphrase, UNIVERSE);
Serial.println(F("Listening for data..."));
}
void loop() {
if (e131.parsePacket()) {
if (e131.universe == 1) {
for (int i = 0; i < NUM_LEDS; i++) {
int j = i * 3 + (CHANNEL_START - 1);
newLeds[i] = (i, (CRGB(e131.data[j], e131.data[j + 1], e131.data[j + 2])));
}
FastLED.show();
}
}
}
Last edited: