I have an esp32-s2-saola-1 which has an addressable RGB LED (WS2812), driven by GPIO18 as described here:
https://docs.espressif.com/projects/esp ... -v1.2.html
Problem is I haven't yet found an Arduino compatible library to drive the RGB led correctly.
As an example, using FastLED ( http://fastled.io/ ) the code below turns the led green (when it should turn it red) and then generates the following error:
Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0)
and then reboots.
I suspect the led may be a GRB device, and not a RGB device as advertised, but that's not as much of a concern as the reboot.
#define LED_PIN 18
#define NUM_LEDS 1
#define BRIGHTNESS 10
#define LED_TYPE WS2812
#define FASTLED_ALLOW_INTERRUPTS 0
#include "FastLED.h"
CRGB leds[NUM_LEDS];
void setup()
{
Serial.begin(115200);
Serial.println("Starting");
delay(5000); // saftey delay
Serial.println("Started");
FastLED.addLeds<WS2812, LED_PIN, RGB>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS );
}
void loop() {
Serial.println("Red");
leds[0] = CRGB::Red;
FastLED.show(); // << failes here; have also tried FastLED.delay(100); as well as following FastLED.show(); with yield();
delay(1000);
Serial.println("Green");
leds[0] = CRGB::Green;
FastLED.show();
delay(1000);
Serial.println("Blue");
leds[0] = CRGB::Blue;
FastLED.show();
delay(1000);
}
A bunch of research and trials has me thinking the problem is tied to the esp32-s2-saola-1 being based on a single core chip, but I cannot confirm.
Would appreciate either:
a) knowing if I am missing something above
or
b) know another Arduion compatible library that allows the LED to be driven correctly.
With thanks
driving a RGB LED (WS2812) on an esp32-s2-saola-1
Re: driving a RGB LED (WS2812) on an esp32-s2-saola-1
FastLED does not look like it has been updated for ESP32-S2, with a lot of allowed pin assignments and hardware capabilities hard-coded to the original ESP32. For example, the default clockless driver uses 8 RMT channels, though the ESP32-S2 has only 4 RMT channels.
The core panic error means necessary task switching interrupts (to deal with WiFi tasks, for example) are not being processed in a timely manner: try removing the FASTLED_ALLOW_INTERRUPTS line. With the default RMT driver, I think FastLED should be able to drive the WS2812 lines even while the chip deals with other processes (WiFi).
If that doesn't work, looking at the ESP32 header files in FastLED, specifically the clockless RMT driver, gives some suggestions for altering the driver behavior. Try adding some of the following define statements (one at a time) before including FastLED.h:
For red appearing as green, you can try using GRB instead of RGB in the initialization line to see if it just a color ordering issue:
The core panic error means necessary task switching interrupts (to deal with WiFi tasks, for example) are not being processed in a timely manner: try removing the FASTLED_ALLOW_INTERRUPTS line. With the default RMT driver, I think FastLED should be able to drive the WS2812 lines even while the chip deals with other processes (WiFi).
If that doesn't work, looking at the ESP32 header files in FastLED, specifically the clockless RMT driver, gives some suggestions for altering the driver behavior. Try adding some of the following define statements (one at a time) before including FastLED.h:
Code: Select all
#define FASTLED_RMT_MAX_CHANNELS 1
#define FASTLED_RMT_BUILTIN_DRIVER 1
#define FASTLED_INTERRUPT_RETRY_COUNT 1
Code: Select all
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
Re: driving a RGB LED (WS2812) on an esp32-s2-saola-1
Thank you, but adding:
In any combination did not resolve the rebooting problem.
Adding
did turn the LED red when it was supposed to, but then in further testing starting off with green the LED turned blue.
Changing to use:
did correct the LED colour problem, but only if not also using:
In all cases, the rebooting continued.
I am not overly hung up on using the FastLED library, but like I said others I tried didn't work either.
Still looking for either a solution that will work with FastLED, or in fact any other library usable in the Arduino IDF for the esp32-s2-saola-1.
Code: Select all
#define FASTLED_RMT_MAX_CHANNELS 1
#define FASTLED_RMT_BUILTIN_DRIVER 1
#define FASTLED_INTERRUPT_RETRY_COUNT 1
Adding
Code: Select all
#define FASTLED_RMT_BUILTIN_DRIVER 1Changing to use:
Code: Select all
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS)Code: Select all
#define FASTLED_RMT_BUILTIN_DRIVER 1I am not overly hung up on using the FastLED library, but like I said others I tried didn't work either.
Still looking for either a solution that will work with FastLED, or in fact any other library usable in the Arduino IDF for the esp32-s2-saola-1.
-
luk.matuska
- Posts: 2
- Joined: Wed Dec 09, 2020 4:31 pm
Re: driving a RGB LED (WS2812) on an esp32-s2-saola-1
Hello,
I also got into this proble, and the solution:
did worked for just a bit...
using Fastled example named ColorPalette did light up the led strip, but after a second or so, it crashed.
Dump from serial connection:
Glad to see someone trying to solve this problem.
Thanks
I also got into this proble, and the solution:
Code: Untitled.txt Select all
#define FASTLED_RMT_MAX_CHANNELS 1
#define FASTLED_RMT_BUILTIN_DRIVER 1
#define FASTLED_INTERRUPT_RETRY_COUNT 1using Fastled example named ColorPalette did light up the led strip, but after a second or so, it crashed.
Dump from serial connection:
Code: Untitled.txt Select all
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x40081071 PS : 0x00060031 A0 : 0x80026529 A1 : 0x3ffbfaa0
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x3ffc186c A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000001 A8 : 0x8002b0a5 A9 : 0x3ffbfaa0
A10 : 0x00060023 A11 : 0x00000001 A12 : 0x00060021 A13 : 0x80000000
A14 : 0x3ffbfdd8 A15 : 0x00000c94 SAR : 0x00000020 EXCCAUSE: 0x0000001c
EXCVADDR: 0x0000001c LBEG : 0x00060021 LEND : 0x80000000 LCOUNT : 0x40027501
Core 0 was running in ISR context:
EPC1 : 0x40081071 EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x00000000
Backtrace:0x4008106e:0x3ffbfaa0 0x40026526:0x3ffbfad0 0x4002761e:0x3ffbfb20 0x4009a6eb:0x3ff9f950 |<-CORRUPTED
Thanks
-
luk.matuska
- Posts: 2
- Joined: Wed Dec 09, 2020 4:31 pm
Re: driving a RGB LED (WS2812) on an esp32-s2-saola-1
Hello, i think i found some solution or alternative (that doesn't glitches randomly or sets the first LED to green all the time)
But first, i have to confess, this solution is for board esp32-s2 wrover, that i have programmed separately using programmer - so not exactly the saola-1 board. Anyway, this shoud work for the board because it(as esp32-s2 wroom) board is just lacking the psram - which i'm not using anyway, so all the specs should be same
To the point, i found library called ws2812fx from arduino library manager thingy.
You can control the RMT channels here - in example named ws2812fx_esp32.
The maybe downside is that it may be more advanced than Fastled, buf i you take a look at some examples, you should be able to use it.
if it is laggy, decerase speed parameter (i have something like 40 or so)
Hope this helped someone somehow
Thanks for all the help in this thread
But first, i have to confess, this solution is for board esp32-s2 wrover, that i have programmed separately using programmer - so not exactly the saola-1 board. Anyway, this shoud work for the board because it(as esp32-s2 wroom) board is just lacking the psram - which i'm not using anyway, so all the specs should be same
To the point, i found library called ws2812fx from arduino library manager thingy.
You can control the RMT channels here - in example named ws2812fx_esp32.
The maybe downside is that it may be more advanced than Fastled, buf i you take a look at some examples, you should be able to use it.
if it is laggy, decerase speed parameter (i have something like 40 or so)
Hope this helped someone somehow
Thanks for all the help in this thread
Who is online
Users browsing this forum: Bing [Bot], ChatGPT-User, YisouSpider and 5 guests