Page 3 of 3 FirstFirst 123
Results 21 to 25 of 25

Thread: Esp Code for various modules

  1. #21
    Join Date
    Oct 2019
    Location
    SoCal
    Posts
    59
    Post Thanks / Like

    Default Re: Esp Code for various modules

    With regards to setup, I meant more along the lines of how you have everything connected, as in the esp, the pixels, power supply, pixels.

    I notice that the thread starts out with you using WS2812 and then moving on to the ws2801. Did you run into timing/interrupt issues with the ws2812? or were you trying different types for the sake of experimentation? I'm currently working with the ws2811 and ws2812 so figured id ask.

  2. #22
    Join Date
    Dec 2011
    Posts
    6,368
    Post Thanks / Like

    Default Re: Esp Code for various modules

    If you notice that the E131.h vs EspAsyncE131.h used , you will find a difference in how the sketches are worded.

    The EspAsyncE131.h can make it easier to work with as in less defines may be required .
    Last edited by angus40; 04-02-2020 at 04:08 PM.

  3. #23
    Join Date
    Oct 2019
    Location
    SoCal
    Posts
    59
    Post Thanks / Like

    Default Re: Esp Code for various modules

    Quote Originally Posted by angus40 View Post
    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();
         }
      }
    }
    forgive me if im missing something obvious, but in the beginning of this sketch where you're defining the pins, the comments mention "ignored for Esp8266" - what is ignored ??

  4. #24
    Join Date
    Dec 2011
    Posts
    6,368
    Post Thanks / Like

    Default Re: Esp Code for various modules

    Sorry , this sketch is for esp32 as defined .
    The Rmt method will only work with the esp32 .

    If you install the Makuna NeoPixelBus library , have a look at each example that is provide .
    You will see that in the header description that for the esp8266 the Gpio as a define is commonly ignored.
    I believe that is because the methods used for output are via Uart and pin restricted to either gpio 1,2 or 3.

    I can't remember exactly and should have documented the scripts better . Sorry for any confusion as I am not an EE that would probably do a much more proper documentation for this .

    I am just a full time apprentice lol

  5. #25
    Join Date
    Dec 2011
    Posts
    6,368
    Post Thanks / Like

    Default Re: Esp Code for various modules

    This is from the neopixelbus example sketch and should clear up the ignore statement .

    const uint16_t PixelCount = 4; // this example assumes 4 pixels, making it smaller will cause a failure
    const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266

    #define colorSaturation 128

    // three element pixels, in different order and speeds
    NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);
    //NeoPixelBus<NeoRgbFeature, Neo400KbpsMethod> strip(PixelCount, PixelPin);

    // For Esp8266, the Pin is omitted and it uses GPIO3 due to DMA hardware use.
    // There are other Esp8266 alternative methods that provide more pin options, but also have
    // other side effects.
    // for details see wiki linked here https://github.com/Makuna/NeoPixelBu...266-NeoMethods

    // You can also use one of these for Esp8266,
    // each having their own restrictions
    //
    // These two are the same as above as the DMA method is the default
    // NOTE: These will ignore the PIN and use GPI03 pin
    //NeoPixelBus<NeoGrbFeature, NeoEsp8266Dma800KbpsMethod> strip(PixelCount, PixelPin);
    //NeoPixelBus<NeoRgbFeature, NeoEsp8266Dma400KbpsMethod> strip(PixelCount, PixelPin);

    // Uart method is good for the Esp-01 or other pin restricted modules
    // for details see wiki linked here https://github.com/Makuna/NeoPixelBu...266-NeoMethods
    // NOTE: These will ignore the PIN and use GPI02 pin
    //NeoPixelBus<NeoGrbFeature, NeoEsp8266Uart1800KbpsMethod> strip(PixelCount, PixelPin);
    //NeoPixelBus<NeoRgbFeature, NeoEsp8266Uart1400KbpsMethod> strip(PixelCount, PixelPin);

    // The bitbang method is really only good if you are not using WiFi features of the ESP
    // It works with all but pin 16
    //NeoPixelBus<NeoGrbFeature, NeoEsp8266BitBang800KbpsMethod> strip(PixelCount, PixelPin);
    //NeoPixelBus<NeoRgbFeature, NeoEsp8266BitBang400KbpsMethod> strip(PixelCount, PixelPin);

    // four element pixels, RGBW
    //NeoPixelBus<NeoRgbwFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);

Page 3 of 3 FirstFirst 123

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
  •