Esp Code for variou...
 
Notifications
Clear all

Esp Code for various modules

35 Posts
5 Users
0 Reactions
34.7 K Views
Posts: 8517
Topic starter
(@angus40)
Illustrious Member
Joined: 15 years ago

LPD 6803 Esp-01 ESPAsyncE131 Fastled

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


#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();
    }
  }
}

Reply
Posts: 8517
Topic starter
(@angus40)
Illustrious Member
Joined: 15 years ago

Esp-01 APA 102 pixels ESPAsyncE131


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

Reply
Posts: 8517
Topic starter
(@angus40)
Illustrious Member
Joined: 15 years ago

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


Reply
Posts: 59
(@lateraliz)
Trusted Member
Joined: 7 years ago

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?


Reply
Posts: 8517
Topic starter
(@angus40)
Illustrious Member
Joined: 15 years ago

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 .


Reply
Page 4 / 7
Share: