Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: Esp Code for various modules

  1. #11
    Join Date
    Dec 2011
    Posts
    6,371
    Post Thanks / Like

    Default Re: Esp Code for various modules

    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 .

    Code:
    /*
      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();
         }
      }
    }

  2. #12
    Join Date
    Dec 2011
    Posts
    6,371
    Post Thanks / Like

    Default Re: Esp Code for various modules

    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 !

    Code:
    /*
      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);  //RPIN
          }
          if (val2 <= 255 || val2 > 1) {
            ledcWrite(2, val2);
          }
        }
      }
    }
    Last edited by angus40; 03-08-2020 at 05:08 AM.

  3. #13
    Join Date
    Dec 2011
    Posts
    6,371
    Post Thanks / Like

    Default Re: Esp Code for various modules

    E131 WS 2801 FastLed Esp8266 Nodemcu

    This will work on Wemos too !


    Code:
    #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();
        }
      }
    }
    Last edited by angus40; 03-22-2020 at 05:34 PM.

  4. #14
    Join Date
    Dec 2011
    Posts
    6,371
    Post Thanks / Like

    Default Re: Esp Code for various modules

    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


    Code:
    #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);
      }
    }
    Last edited by angus40; 03-22-2020 at 12:17 AM.

  5. #15
    Join Date
    Dec 2011
    Posts
    6,371
    Post Thanks / Like

    Default Re: Esp Code for various modules

    Ws 2801pixels Esp - 01 NeoPixelBus ESPAsyncE131


    Code:
    ----------------------------------------------------------
    #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();
        }
      }
    }
    Last edited by angus40; 03-31-2020 at 06:51 PM.

  6. #16
    Join Date
    Dec 2011
    Posts
    6,371
    Post Thanks / Like

    Default Re: Esp Code for various modules

    LPD 6803 Esp-01 ESPAsyncE131 Fastled

    Will probably work on CCR as they are just renamed from Lpd6803 I believe.

    Code:
    #include "FastLED.h"
    #include <ESP8266WiFi.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
    #define NUM_LEDS 5
    #define DATA_PIN 2
    #define CLOCK_PIN 0
    
    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);
    
    CRGB leds[NUM_LEDS];
    
    void setup() {
        // sanity check delay - allows reprogramming if accidently blowing power w/leds
        delay(2000);
     Serial.begin(115200);
        delay(10);
        
        FastLED.addLeds<LPD6803, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);  // GRB ordering is typical
    
        // 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 < NUM_LEDS; i++) {
            int j = i * 3 + (CHANNEL_START);
            leds[i] = (i, (CRGB(packet.property_values[j], packet.property_values[j + 1], packet.property_values[j +2])));
            //Serial.println(packet.property_values[j]);
          }
          FastLED.show();
        }
      }
    }
    Last edited by angus40; 03-31-2020 at 07:06 PM.

  7. #17
    Join Date
    Dec 2011
    Posts
    6,371
    Post Thanks / Like

    Default Re: Esp Code for various modules

    Esp-01 APA 102 pixels ESPAsyncE131


    Code:
    /*
    * 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
    *
    *  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 <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 PixelCount = 72; // 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<DotStarBgrFeature, DotStarMethod> strip(PixelCount, 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());
    
     /* Initialize output */
        pinMode(DotDataPin, OUTPUT);
        digitalWrite(DotDataPin, LOW);
     
     // this resets all the neopixels to an off state
        strip.Begin();
        strip.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() {
      if (!e131.isEmpty()) {
        e131_packet_t packet;
        e131.pull(&packet);     // Pull packet from ring buffer
      uint16_t universe = htons(packet.universe);  
      if (universe == 1) { 
         if (packet.property_values[(CHANNEL_START - 1)] < PixelCount) {
          for (int i = 0; i < PixelCount; i++) {
                int j = i * 3 + (CHANNEL_START );
                  strip.SetPixelColor(i, (RgbColor(packet.property_values[j], packet.property_values[j+1], packet.property_values[j+2])));        
                Serial.println(packet.property_values[j] );;
                }
                strip.Show();
         }
      }
      }
    }

  8. #18
    Join Date
    Dec 2011
    Posts
    6,371
    Post Thanks / Like

    Default Re: Esp Code for various modules

    Thanks much for the E131 Test .ino . It was fun to test these sketches and learn a little along the way .
    I managed to kill a few Esp modules in this process and have finally learned the value of protection diodes !

    Just maybe some of you will find 1 or 2 of these useful.

    Cheers

  9. #19
    Join Date
    Oct 2019
    Location
    SoCal
    Posts
    59
    Post Thanks / Like

    Default Re: Esp Code for various modules

    You sir, are a saint for sharing this. So happy to see someone else (who is more knowledgable than I) diving deep into figuring out how to drive neopixels from multiple gpio on the Esp8266 with FastLED! This is amazing! Thank you.

    I'll be going through everything you posted in this thread for a while, but so far I notice that you changed up the hardware used at various points. Would you mind sharing your setup?

  10. #20
    Join Date
    Dec 2011
    Posts
    6,371
    Post Thanks / Like

    Default Re: Esp Code for various modules

    Many here will say and I have to agree , I am no saint . More of a cantankerous character better suited !
    This site and member here have given me loads of guidance over the years so this is my way of giving back .

    As far as setup , do you mean Arduino IDE ?
    If yes , I use the 1.8.12 version .
    I have to switch the esp8266 board version from most recent to -> 4.2 from time to time and the ArduinoJason
    from most recent to -> 5.1 or 5.0 when it complains .

    Also as I experimented with this I had to vary the Fastled lib version as I did not realize I was not current .
    The ws2801 was a bit of frustration and found Wled was best for them .

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •