Esp32 12 Universe successfully working !!! Could probably add 5 more .
BitBang is not 100% or as lossless as RMT .
Next challenge to turn the Esp32 into a dumb rgb controller .
/*
All credits to :
Shelby Merrick for his E131
&
Michael Miller for the NeoPixel_Bus
E131_Test.ino - Simple sketch to listen for E1.31 data on an ESP32
and print some statistics.
Project: ESPAsyncE131 - Asynchronous E.131 (sACN) library for Arduino ESP8266 and ESP32
Copyright (c) 2019 Shelby Merrick
http://www.forkineye.com
NeoPixelTest
https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
*/
#include <ESPAsyncE131.h>
#include <NeoPixelBus.h>
#include <WiFi.h>
#define UNIVERSE 1 // First DMX Universe to listen for
#define UNIVERSE_COUNT 12
#define CHANNEL_START 1
#define CHANNEL_START_B 1
#define CHANNEL_START_C 1
#define CHANNEL_START_D 1
#define CHANNEL_START_E 1
#define CHANNEL_START_F 1
#define CHANNEL_START_G 1
#define CHANNEL_START_H 1
#define CHANNEL_START_I 1
#define CHANNEL_START_J 1
#define CHANNEL_START_K 1
#define CHANNEL_START_L 1
const uint16_t PixelCount1 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin1 = 23; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount2 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin2 = 22; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount3 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin3 = 21; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount4 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin4 = 19; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount5 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin5 = 18; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount6 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin6 = 17; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount7 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin7 = 4; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount8 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin8 = 15; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount9 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin9 = 0; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount10 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin10 = 16; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount11 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin11 = 27; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount12 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin12 = 25; // make sure to set this to the correct pin, ignored for Esp8266
const char ssid[] = "SSID"; // Replace with your SSID
const char passphrase[] = "PASSWORD"; // Replace with your WPA2 passphrase
// ESPAsyncE131 instance with UNIVERSE_COUNT buffer slots
ESPAsyncE131 e131(12);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt0800KbpsMethod> strip1(PixelCount1, PixelPin1);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt1800KbpsMethod> strip2(PixelCount2, PixelPin2);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt2800KbpsMethod> strip3(PixelCount3, PixelPin3);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt3800KbpsMethod> strip4(PixelCount4, PixelPin4);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt4800KbpsMethod> strip5(PixelCount5, PixelPin5);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt5800KbpsMethod> strip6(PixelCount6, PixelPin6);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt6800KbpsMethod> strip7(PixelCount7, PixelPin7);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt7800KbpsMethod> strip8(PixelCount8, PixelPin8);
NeoPixelBus<NeoGrbFeature, NeoEsp32BitBang800KbpsMethod> strip9(PixelCount9, PixelPin9);
NeoPixelBus<NeoGrbFeature, NeoEsp32BitBang800KbpsMethod> strip10(PixelCount10, PixelPin10);
NeoPixelBus<NeoGrbFeature, NeoEsp32BitBang800KbpsMethod> strip11(PixelCount11, PixelPin11);
NeoPixelBus<NeoGrbFeature, NeoEsp32BitBang800KbpsMethod> strip12(PixelCount12, PixelPin12);
void setup() {
Serial.begin(115200);
delay(10);
// 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());
// this resets all the neopixels to an off state
strip1.Begin();
strip1.Show();
strip2.Begin();
strip2.Show();
strip3.Begin();
strip3.Show();
strip4.Begin();
strip4.Show();
strip5.Begin();
strip5.Show();
strip6.Begin();
strip6.Show();
strip7.Begin();
strip7.Show();
strip8.Begin();
strip8.Show();
strip9.Begin();
strip9.Show();
strip10.Begin();
strip10.Show();
strip11.Begin();
strip11.Show();
strip12.Begin();
strip12.Show();
// 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
}
void loop() {
// Parse a packet and update pixels
while (!e131.isEmpty()) {
e131_packet_t packet;
e131.pull(&packet); // Pull packet from ring buffer
uint16_t universe = htons(packet.universe);
if (universe == 1) {
for (int i = 0; i < PixelCount1; i++) {
int j = i * 3 + (CHANNEL_START);
strip1.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j] );
}
strip1.Show();
}
if (universe == 2) {
for (int i = 0; i < PixelCount2; i++) {
int j = i * 3 + (CHANNEL_START_B);
strip2.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip2.Show();
}
if (universe == 3) {
for (int i = 0; i < PixelCount3; i++) {
int j = i * 3 + (CHANNEL_START_C);
strip3.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip3.Show();
}
if (universe == 4) {
for (int i = 0; i < PixelCount4; i++) {
int j = i * 3 + (CHANNEL_START_D);
strip4.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip4.Show();
}
if (universe == 5) {
for (int i = 0; i < PixelCount5; i++) {
int j = i * 3 + (CHANNEL_START_E);
strip5.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip5.Show();
}
if (universe == 6) {
for (int i = 0; i < PixelCount6; i++) {
int j = i * 3 + (CHANNEL_START_F);
strip6.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip6.Show();
}
if (universe == 7) {
for (int i = 0; i < PixelCount7; i++) {
int j = i * 3 + (CHANNEL_START_G);
strip7.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip7.Show();
}
if (universe == 8) {
for (int i = 0; i < PixelCount8; i++) {
int j = i * 3 + (CHANNEL_START_H);
strip8.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip8.Show();
}
if (universe == 9) {
for (int i = 0; i < PixelCount9; i++) {
int j = i * 3 + (CHANNEL_START_I);
strip9.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip9.Show();
}
if (universe == 10) {
for (int i = 0; i < PixelCount10; i++) {
int j = i * 3 + (CHANNEL_START_J);
strip10.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip10.Show();
}
if (universe == 11) {
for (int i = 0; i < PixelCount11; i++) {
int j = i * 3 + (CHANNEL_START_K);
strip11.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip11.Show();
}
if (universe == 12) {
for (int i = 0; i < PixelCount12; i++) {
int j = i * 3 + (CHANNEL_START_L);
strip12.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j + 1] );
}
strip12.Show();
}
}
}
Pixels , rgb channels easily controlled at the same time with multi Universe configuration .
Thoroughly tested using Unicast and works excellently.
Note: I found it wise to add a 10k resistor from gate to gnd on each of the N-channel mosfets .
Example sketch enjoy !
/*
All credits to :
Shelby Merrick for his E131
&
Michael Miller for the NeoPixel_Bus
E131_Test.ino - Simple sketch to listen for E1.31 data on an ESP32
and print some statistics.
Project: ESPAsyncE131 - Asynchronous E.131 (sACN) library for Arduino ESP8266 and ESP32
Copyright (c) 2019 Shelby Merrick
http://www.forkineye.com
NeoPixelTest
https://github.com/Makuna/NeoPixelBus/wiki/ESP8266-NeoMethods
*/
#include <ESPAsyncE131.h>
#include <NeoPixelBus.h>
#include <WiFi.h>
#define UNIVERSE 1 // First DMX Universe to listen for
#define UNIVERSE_COUNT 3
#define CHANNEL_START 1
#define CHANNEL_START_A 1
#define RPIN 15 //R pin for analog LED strip
#define GPIN 13 //G pin for analog LED strip
#define BPIN 12 //B pin for analog LED strip
const uint16_t PixelCount1 = 6; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin1 = 27; // make sure to set this to the correct pin, ignored for Esp8266
const uint16_t PixelCount2 = 6; // Should be set to no less than 4 for R,G,B channels
const uint8_t PixelPin2 = 15; //Use a r,g,b Pin to satisfy the NeoPixelBus Instance
const char ssid[] = ""; // Replace with your SSID
const char passphrase[] = "!"; // Replace with your WPA2 passphrase
// ESPAsyncE131 instance with UNIVERSE_COUNT buffer slots
ESPAsyncE131 e131(UNIVERSE_COUNT);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt0800KbpsMethod> strip1(PixelCount1, PixelPin1);
NeoPixelBus<NeoGrbFeature, NeoEsp32Rmt1800KbpsInvertedMethod> strip2(PixelCount2, PixelPin2);
void setup() {
Serial.begin(115200);
delay(10);
// 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());
ledcSetup(0, 5000, 8);
ledcAttachPin(RPIN, 0);
ledcSetup(1, 5000, 8);
ledcAttachPin(GPIN, 1);
ledcSetup(2, 5000, 8);
ledcAttachPin(BPIN, 2);
// this resets all the neopixels to an off state
strip1.Begin();
strip1.Show();
// 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
}
void loop() {
int val;
int val1;
int val2;
// Parse a packet and update pixels
while (!e131.isEmpty()) {
e131_packet_t packet;
e131.pull(&packet); // Pull packet from ring buffer
uint16_t universe = htons(packet.universe);
uint8_t *data = packet.property_values + 1;
if (universe == 1) {
for (int i = 0; i < PixelCount1; i++) {
int j = i * 3 + (CHANNEL_START);
strip1.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j + 2])));
//Serial.println(packet.property_values[j] );
}
strip1.Show();
}
if (universe == 2) {
/* channel selection ; if not in sequential order you may get lag*/
val = map((packet.property_values[(CHANNEL_START_A)]), 0, 255, 0, 255); // You change the channels here
val1 = map((packet.property_values[(CHANNEL_START_A + 1)]), 0, 255, 0, 255);
val2 = map((packet.property_values[(CHANNEL_START_A + 2)]), 0, 255, 0, 255);
if (val <= 255 || val > 1) {
ledcWrite(0, val); //RPIN;
}
if (val1 <= 255 || val1 > 1) {
ledcWrite(1, val1); //GPIN
}
if (val2 <= 255 || val2 > 1) {
ledcWrite(2, val2); //BPIN
}
}
}
}
E131 WS 2801 FastLed Esp8266 Nodemcu
This will work on Wemos too !
#include "FastLED.h"
#include <ESP8266WiFi.h>
#include <E131.h>
#define NUM_LEDS 6
#define DATA_PIN 2
#define CLOCK_PIN 3
#define UNIVERSE 1 // First DMX Universe to listen for
#define CHANNEL_START 1
const char ssid[] = "0000000000"; /* Replace with your SSID */
const char passphrase[] = "00000000000"; /* Replace with your WPA2 passphrase */
CRGB leds[NUM_LEDS];
E131 e131;
void setup() {
Serial.begin(115200);
while (!Serial); // wait for serial attach
Serial.println();
Serial.println("Initializing...");
Serial.flush();
/* Choose one to begin listening for E1.31 data */
//e131.begin(ssid, passphrase); /* via Unicast on the default port */
e131.beginMulticast(ssid, passphrase, UNIVERSE); /* via Multicast for Universe 1 */
FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
}
void loop() {
/* Parse a packet and update pixels */
if (e131.parsePacket()) {
if (e131.universe == UNIVERSE, 1) {
for (int i = 0; i < NUM_LEDS; i++) {
int j = i * 3 + (CHANNEL_START -1 );
leds[i] = (i, (CRGB(e131.data[j], e131.data[j + 1], e131.data[j + 2])));
}
FastLED.show();
}
}
}
Esp8266 hwSPI ... test and works very clean and fast .
Ws 2801 pixels used .
Thanks to Copyright (c) 2015 David Ogilvy (MetalPhreak)
You can source -> https://github.com/MetalPhreak/ESP8266_SPI_Driver
#include "spi.c" <<<<<<
#include "driver/spi.h" <<<<<< (these are required to be in the .ino folder )
#include "spi_register.h" <<<<<< ( for copy & paste to work )
int RED[4];
int GREEN[4];
int BLUE[4];
//
//setup code
void setup()
{
spi_init(HSPI);
spi_tx8(HSPI, 0x7A); //send 8 bits of data
spi_tx16(HSPI, 0x7A43); //send 16 bits of data
spi_tx32(HSPI, 0xCAFEFEED); //send 32 bits of data
spi_txd(HSPI, 9, 0b101101110); //send 9 bits of data (useful for driving LCDs with 9bit commands).
for (int i = 0; i < 4; i++)
{
RED[i] = 0;
BLUE[i] = 0;
GREEN[i] = 0;
}
}
void updatestring()
{
for (int i = 0; i < 4; i++)
{
spi_tx8(HSPI, RED[i]);
spi_tx8(HSPI, GREEN[i]);
spi_tx8(HSPI, BLUE[i]);
}
}
//
void loop()
{
for (int i = 0; i < 4; i++)
{
RED[i] = 255; GREEN[i] = 0; BLUE[i] = 0;
updatestring();
RED[i] = 0; GREEN[i] = 0; BLUE[i] = 0;
delay(200);
}
}
Ws 2801pixels Esp - 01 NeoPixelBus ESPAsyncE131
----------------------------------------------------------
#include <ESP8266WiFi.h>
#include <NeoPixelBus.h>
#include <ESPAsyncE131.h>
#define UNIVERSE 1 // First DMX Universe to listen for
#define UNIVERSE_COUNT 8 // Total number of Universes to listen for, starting at UNIVERSE
#define CHANNEL_START 1
const uint16_t PixelCount1 = 4; // this example assumes 4 pixels, making it smaller will cause a failure
// make sure to set this to the correct pins
const uint8_t DotClockPin = 0;
const uint8_t DotDataPin = 2;
const char ssid[] = ""; // Replace with your SSID
const char passphrase[] = ""; // Replace with your WPA2 passphrase
// ESPAsyncE131 instance with UNIVERSE_COUNT buffer slots
ESPAsyncE131 e131(UNIVERSE_COUNT);
NeoPixelBus<NeoRgbFeature, NeoWs2801Method> strip1(PixelCount1, DotClockPin, DotDataPin);
void setup() {
Serial.begin(115200);
delay(10);
// 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
Serial.println(F("Listening for data..."));
else
Serial.println(F(" e131.begin failed "));
}
void loop() {
// Parse a packet and update pixels
if (!e131.isEmpty()) {
e131_packet_t packet;
e131.pull(&packet); // Pull packet from ring buffer
uint16_t universe = htons(packet.universe);
if (universe == 1) {
for (int i = 0; i < PixelCount1; i++) {
int j = i * 3 + (CHANNEL_START);
strip1.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j +2])));
//Serial.println(packet.property_values[j]);
}
strip1.Show();
}
}
}
