New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 + FastLED #504

Open
PhilColbert opened this Issue Sep 26, 2017 · 244 comments

Comments

Projects
None yet
@PhilColbert

PhilColbert commented Sep 26, 2017

Struggling to get this working ?

Have a setup with the 8266 working perfectly.

Using the same code and wiring setup, just the first 2 LED's light up white and the 3rd LED flickers.

Using 72 APA102 LED's and standard ESP32 dev board.

Wired directly to 5V, no level converter as it wasnt needed on the esp8266 board

Any ideas or anyone got this working yet ?

Thanks

@focalintent

This comment has been minimized.

Show comment
Hide comment
@focalintent

focalintent Sep 27, 2017

Member

@samguyer any thoughts for @PhilColbert? I don't have any esp32 based setups here to test with, so I'm mostly relying on sam's pull request :)

Member

focalintent commented Sep 27, 2017

@samguyer any thoughts for @PhilColbert? I don't have any esp32 based setups here to test with, so I'm mostly relying on sam's pull request :)

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer Sep 27, 2017

Contributor

@PhilColbert Which pin are you using? I have found that the ESP32 is very finicky about the pins.

Contributor

samguyer commented Sep 27, 2017

@PhilColbert Which pin are you using? I have found that the ESP32 is very finicky about the pins.

@PhilColbert

This comment has been minimized.

Show comment
Hide comment
@PhilColbert

PhilColbert Sep 27, 2017

Hi

Thanks for the reply, tried 13,14 and 25,26 so far....

Seemingly same result, first 2 leds on white, 3rd flashes....

Thanks

PhilColbert commented Sep 27, 2017

Hi

Thanks for the reply, tried 13,14 and 25,26 so far....

Seemingly same result, first 2 leds on white, 3rd flashes....

Thanks

@gnkarn

This comment has been minimized.

Show comment
Hide comment
@gnkarn

gnkarn Sep 27, 2017

You should try the level converter first , also in an ESP 8266 before anything else .

gnkarn commented Sep 27, 2017

You should try the level converter first , also in an ESP 8266 before anything else .

@PhilColbert

This comment has been minimized.

Show comment
Hide comment
@PhilColbert

PhilColbert Sep 27, 2017

Yes, will do :)

thanks

PhilColbert commented Sep 27, 2017

Yes, will do :)

thanks

@focalintent

This comment has been minimized.

Show comment
Hide comment
@focalintent

focalintent Sep 27, 2017

Member

Also, as a sanity check - make sure you haven’t gotten clock and data wired backwards (the behavior you’re describing is not dissimilar to what happens when the clock and data lines have been swapped)

Member

focalintent commented Sep 27, 2017

Also, as a sanity check - make sure you haven’t gotten clock and data wired backwards (the behavior you’re describing is not dissimilar to what happens when the clock and data lines have been swapped)

@PhilColbert

This comment has been minimized.

Show comment
Hide comment
@PhilColbert

PhilColbert Sep 27, 2017

:) Tried it both ways.... first thing to check that one, been there done that before several times, with them reversed, nothing comes out.

Thanks tho, will try Level converter soon first.

PhilColbert commented Sep 27, 2017

:) Tried it both ways.... first thing to check that one, been there done that before several times, with them reversed, nothing comes out.

Thanks tho, will try Level converter soon first.

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer Sep 27, 2017

Contributor

The code that I pushed for the ESP32 is mainly for clockless chips, like the WS2812 family. It was adapted directly from the ESP8266 code, with modifications mainly to handle interrupts. I would not expect to see problems with LEDs that have an explicit clock signal, but I'm pretty new to this stuff (and to hacking FastLED).

Contributor

samguyer commented Sep 27, 2017

The code that I pushed for the ESP32 is mainly for clockless chips, like the WS2812 family. It was adapted directly from the ESP8266 code, with modifications mainly to handle interrupts. I would not expect to see problems with LEDs that have an explicit clock signal, but I'm pretty new to this stuff (and to hacking FastLED).

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer Sep 27, 2017

Contributor

Also: the pins you're using should be fine, but there are so many weird exceptions on this processor. I have gotten things to work reliably on GPIO 18 and 19.

Contributor

samguyer commented Sep 27, 2017

Also: the pins you're using should be fine, but there are so many weird exceptions on this processor. I have gotten things to work reliably on GPIO 18 and 19.

@PhilColbert

This comment has been minimized.

Show comment
Hide comment
@PhilColbert

PhilColbert Sep 27, 2017

Ok, will give it a try , thanks.

PhilColbert commented Sep 27, 2017

Ok, will give it a try , thanks.

@PhilColbert

This comment has been minimized.

Show comment
Hide comment
@PhilColbert

PhilColbert Sep 27, 2017

Tried with level converter, works just the same on the 8266 with level converter.

With the esp32 and a level converter using pins 18 and 19, works exactly the same, first 2 led's are white and then third flickers.
( tried switching clock and data line to make sure its correct - no colour the other way )

Using FastLED version 3.001.006
"No hardware SPI pins defined. All SPI access will default to bitbanged output"

Any idea where to start looking for the issue ?

Thanks

PhilColbert commented Sep 27, 2017

Tried with level converter, works just the same on the 8266 with level converter.

With the esp32 and a level converter using pins 18 and 19, works exactly the same, first 2 led's are white and then third flickers.
( tried switching clock and data line to make sure its correct - no colour the other way )

Using FastLED version 3.001.006
"No hardware SPI pins defined. All SPI access will default to bitbanged output"

Any idea where to start looking for the issue ?

Thanks

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer Sep 27, 2017

Contributor

Do you have another strip, or a different kind of strip you can try?

Contributor

samguyer commented Sep 27, 2017

Do you have another strip, or a different kind of strip you can try?

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer Sep 29, 2017

Contributor

OK, I think I've made some improvements to the ESP32 support.
@focalintent: do you want me submit another pull request?

Contributor

samguyer commented Sep 29, 2017

OK, I think I've made some improvements to the ESP32 support.
@focalintent: do you want me submit another pull request?

@chrisparton1991

This comment has been minimized.

Show comment
Hide comment
@chrisparton1991

chrisparton1991 Sep 29, 2017

I'm able to drive my UCS1903 strips with an ESP32 (Specifically the DoIt ESP32 Devkit V1 model) without the need for logic level conversion, using the latest FastLED pulled from master (3.001.006).

I have a different issue with FastLED (can't use 3-pin strips and WiFi at the same time, probably due to interrupts). I'll be raising a separate issue or asking in the community about that one though.

chrisparton1991 commented Sep 29, 2017

I'm able to drive my UCS1903 strips with an ESP32 (Specifically the DoIt ESP32 Devkit V1 model) without the need for logic level conversion, using the latest FastLED pulled from master (3.001.006).

I have a different issue with FastLED (can't use 3-pin strips and WiFi at the same time, probably due to interrupts). I'll be raising a separate issue or asking in the community about that one though.

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer Sep 29, 2017

Contributor

@chrisparton1991 I have been working on the interrupt problem on the ESP32, and I think I have a more stable implementation.

Contributor

samguyer commented Sep 29, 2017

@chrisparton1991 I have been working on the interrupt problem on the ESP32, and I think I have a more stable implementation.

@PhilColbert

This comment has been minimized.

Show comment
Hide comment
@PhilColbert

PhilColbert Sep 29, 2017

Tried a set of SK6812 - bit better - one wire version, they light up just not the correct ones , i tried led 0 and 20 and led 0 and 15 lit up ?

Do you have the updated code somewhere ? Thanks

PhilColbert commented Sep 29, 2017

Tried a set of SK6812 - bit better - one wire version, they light up just not the correct ones , i tried led 0 and 20 and led 0 and 15 lit up ?

Do you have the updated code somewhere ? Thanks

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer Sep 29, 2017

Contributor

You can try my branch here: https://github.com/samguyer/FastLED
All you need is the new copy of FastLED/platforms/esp/32/clockless_esp32.h

Contributor

samguyer commented Sep 29, 2017

You can try my branch here: https://github.com/samguyer/FastLED
All you need is the new copy of FastLED/platforms/esp/32/clockless_esp32.h

@PhilColbert

This comment has been minimized.

Show comment
Hide comment
@PhilColbert

PhilColbert Sep 29, 2017

Thanks for the reply ! glad for the help.

Same , I have strip of SK6812 - its nearly working

Setting all the colours to Red, gives a full strip of 230 leds alternating between red - green - blue.

Changing the first 3 leds works, but incorrect colours, so it knows which LED is correct, just colours are out?

Is it worth trying the level converter again - this did nothing last time on all the esp boards.

Any ideas ? :)

Thanks.

PhilColbert commented Sep 29, 2017

Thanks for the reply ! glad for the help.

Same , I have strip of SK6812 - its nearly working

Setting all the colours to Red, gives a full strip of 230 leds alternating between red - green - blue.

Changing the first 3 leds works, but incorrect colours, so it knows which LED is correct, just colours are out?

Is it worth trying the level converter again - this did nothing last time on all the esp boards.

Any ideas ? :)

Thanks.

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer Sep 29, 2017

Contributor

I don't think it's a voltage level issue. My guess is that interrupts are coming in at bad times and causing the showPixels function in FastLED to bail out early. What else do you have running on the ESP32 besides the LED code?

Contributor

samguyer commented Sep 29, 2017

I don't think it's a voltage level issue. My guess is that interrupts are coming in at bad times and causing the showPixels function in FastLED to bail out early. What else do you have running on the ESP32 besides the LED code?

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer Sep 29, 2017

Contributor

Here's something you could try: find the following comment in clockless_esp32.h in the showRGBInternal function, and comment out the conditional below it:

// if interrupts took longer than 45µs, punt on the current frame

I'd be interested to hear how that goes!

Contributor

samguyer commented Sep 29, 2017

Here's something you could try: find the following comment in clockless_esp32.h in the showRGBInternal function, and comment out the conditional below it:

// if interrupts took longer than 45µs, punt on the current frame

I'd be interested to hear how that goes!

@PhilColbert

This comment has been minimized.

Show comment
Hide comment
@PhilColbert

PhilColbert Sep 29, 2017

Nothing, just the LED code - couple of for loops to change the colours, thats it.

I am more interested in the APA102 pixels really, these are for my project, these are interrupt free arent they ?

Wheres best to start looking why these dont work ? :)

Thanks

PhilColbert commented Sep 29, 2017

Nothing, just the LED code - couple of for loops to change the colours, thats it.

I am more interested in the APA102 pixels really, these are for my project, these are interrupt free arent they ?

Wheres best to start looking why these dont work ? :)

Thanks

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer Sep 29, 2017

Contributor

Huh. That's a drag. It seems like the APAs (and any chip with a separate clock line) should work without any special support (there actually isn't any special support). You say it works for you on an ESP8266?

Debugging the clockless chips is beyond my abilities -- I think you really need an oscilloscope to do it right. Here is an excellent article about how the signal works. One thing to try might be to check and tweak the timing numbers. They are passed in as template arguments T1, T2, and T3 to the ClocklessController template.

https://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/

One crazy idea that I got from this article is to enable interrupts during the transmission of 1 bits, since they can be arbitrarily long!

Contributor

samguyer commented Sep 29, 2017

Huh. That's a drag. It seems like the APAs (and any chip with a separate clock line) should work without any special support (there actually isn't any special support). You say it works for you on an ESP8266?

Debugging the clockless chips is beyond my abilities -- I think you really need an oscilloscope to do it right. Here is an excellent article about how the signal works. One thing to try might be to check and tweak the timing numbers. They are passed in as template arguments T1, T2, and T3 to the ClocklessController template.

https://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/

One crazy idea that I got from this article is to enable interrupts during the transmission of 1 bits, since they can be arbitrarily long!

@PhilColbert

This comment has been minimized.

Show comment
Hide comment
@PhilColbert

PhilColbert Sep 29, 2017

Code works perfectly on the 8266.

on the esp32 it just lights up the first 2 leds's white and flickers the 3rd whatever you send to it....

Just want to use the esp32 for the ble on board and the speed.... such a shame it doesnt work

I removed all the conditional code and same result .

Thaks

PhilColbert commented Sep 29, 2017

Code works perfectly on the 8266.

on the esp32 it just lights up the first 2 leds's white and flickers the 3rd whatever you send to it....

Just want to use the esp32 for the ble on board and the speed.... such a shame it doesnt work

I removed all the conditional code and same result .

Thaks

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer Sep 29, 2017

Contributor

My only thought is that it has something to do with the specific pin and/or pin configuration that you're using. Here's the setup code I'm using successfully:

pinMode(18, OUTPUT);
FastLED.addLeds<WS2812, 18, GRB>(g_LEDs, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness(g_Brightness);
fill_solid(g_LEDs, NUM_LEDS, CRGB::Blue);
FastLED.show();

Contributor

samguyer commented Sep 29, 2017

My only thought is that it has something to do with the specific pin and/or pin configuration that you're using. Here's the setup code I'm using successfully:

pinMode(18, OUTPUT);
FastLED.addLeds<WS2812, 18, GRB>(g_LEDs, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness(g_Brightness);
fill_solid(g_LEDs, NUM_LEDS, CRGB::Blue);
FastLED.show();

@PhilColbert

This comment has been minimized.

Show comment
Hide comment
@PhilColbert

PhilColbert Sep 29, 2017

Tried that, all leds light up, but alternating red/blue/green along the strip....

thanks anyway :)

PhilColbert commented Sep 29, 2017

Tried that, all leds light up, but alternating red/blue/green along the strip....

thanks anyway :)

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer Sep 29, 2017

Contributor

Oh, I forgot the call to pinMode. I assume you've got that in there, too.

Contributor

samguyer commented Sep 29, 2017

Oh, I forgot the call to pinMode. I assume you've got that in there, too.

@focalintent

This comment has been minimized.

Show comment
Hide comment
@focalintent

focalintent Sep 29, 2017

Member

1 bits can only be arbitrarily long for the first pixel - because of the signal reshaping that gets done, the hi gets dropped to low coming out of the first chip in the “expected” time and then you end up still running into the reset.

Member

focalintent commented Sep 29, 2017

1 bits can only be arbitrarily long for the first pixel - because of the signal reshaping that gets done, the hi gets dropped to low coming out of the first chip in the “expected” time and then you end up still running into the reset.

@focalintent

This comment has been minimized.

Show comment
Hide comment
@focalintent

focalintent Sep 29, 2017

Member

Tried that, all leds light up, but alternating red/blue/green along the strip

Sounds like what I would expect to happen if you plugged an RGBW strip in and tried to drive it as an RGB strip

Member

focalintent commented Sep 29, 2017

Tried that, all leds light up, but alternating red/blue/green along the strip

Sounds like what I would expect to happen if you plugged an RGBW strip in and tried to drive it as an RGB strip

@hamid-elaosta

This comment has been minimized.

Show comment
Hide comment
@hamid-elaosta

hamid-elaosta Apr 10, 2018

@focalintent Right, I forget about @samguyer fork. I got a little sidetracked having to compile my Logic Analyser software from source because there has been no recent release (time to get a new one I think).

The code I'm compiling is the CalibrateRGB sketch I linked on 22nd March, 22:59 GMT (I'm in the UK).
The only change was the ones listed in that post, I'll link the complete sketch in the next day or two when I'm home.

I'll also test those changes you've suggested for clocking.

hamid-elaosta commented Apr 10, 2018

@focalintent Right, I forget about @samguyer fork. I got a little sidetracked having to compile my Logic Analyser software from source because there has been no recent release (time to get a new one I think).

The code I'm compiling is the CalibrateRGB sketch I linked on 22nd March, 22:59 GMT (I'm in the UK).
The only change was the ones listed in that post, I'll link the complete sketch in the next day or two when I'm home.

I'll also test those changes you've suggested for clocking.

@hamid-elaosta

This comment has been minimized.

Show comment
Hide comment
@hamid-elaosta

hamid-elaosta Apr 11, 2018

@focalintent Ok, now the interesting part.

So,

  • First I got hold of @samguyer fork, ran that, just to be sure, doesn't work.
  • Next I edited the platform.txt for my board and turned off optimisations, still doesn't work.
  • I restored the platform.txt to -Os and added the lo() in the bitbang file and it works. Tested Calibrate and DemoReel100, both working.
  • I restored the bitbang file and set the volatile in _GPB0 which did not work.

hamid-elaosta commented Apr 11, 2018

@focalintent Ok, now the interesting part.

So,

  • First I got hold of @samguyer fork, ran that, just to be sure, doesn't work.
  • Next I edited the platform.txt for my board and turned off optimisations, still doesn't work.
  • I restored the platform.txt to -Os and added the lo() in the bitbang file and it works. Tested Calibrate and DemoReel100, both working.
  • I restored the bitbang file and set the volatile in _GPB0 which did not work.
@focalintent

This comment has been minimized.

Show comment
Hide comment
@focalintent

focalintent Apr 11, 2018

Member

Ok - so doing two hi pin sets adjacent to each other is getting optimized out by the compiler for the esp32, even when the compiler has optimizations turned off - and more aggressively marking the involved statements as volatile doesn't appear to help with that. Good to know (if a little annoying).

Member

focalintent commented Apr 11, 2018

Ok - so doing two hi pin sets adjacent to each other is getting optimized out by the compiler for the esp32, even when the compiler has optimizations turned off - and more aggressively marking the involved statements as volatile doesn't appear to help with that. Good to know (if a little annoying).

@focalintent

This comment has been minimized.

Show comment
Hide comment
@focalintent

focalintent Apr 11, 2018

Member

Ok - so that write bit method should be set to something like this for now - there may be other ways to tweak how this is handled, but not having a setup that I can actually run and test in, there's a limit to how much experimenting I can do.

	// write the BIT'th bit out via spi, setting the data pin then strobing the clcok
	template <uint8_t BIT> __attribute__((always_inline, hot)) inline static void writeBit(uint8_t b) {
		//cli();
		if(b & (1 << BIT)) {
			FastPin<DATA_PIN>::hi();
#ifdef ESP32
                        FastPin<CLOCK_PIN>::lo(); // kick a different register, block premature optimizations?
#endif
			FastPin<CLOCK_PIN>::hi(); CLOCK_HI_DELAY;
			FastPin<CLOCK_PIN>::lo(); CLOCK_LO_DELAY;
		} else {
			FastPin<DATA_PIN>::lo();
			FastPin<CLOCK_PIN>::hi(); CLOCK_HI_DELAY;
			FastPin<CLOCK_PIN>::lo(); CLOCK_LO_DELAY;
		}
		//sei();
	}
Member

focalintent commented Apr 11, 2018

Ok - so that write bit method should be set to something like this for now - there may be other ways to tweak how this is handled, but not having a setup that I can actually run and test in, there's a limit to how much experimenting I can do.

	// write the BIT'th bit out via spi, setting the data pin then strobing the clcok
	template <uint8_t BIT> __attribute__((always_inline, hot)) inline static void writeBit(uint8_t b) {
		//cli();
		if(b & (1 << BIT)) {
			FastPin<DATA_PIN>::hi();
#ifdef ESP32
                        FastPin<CLOCK_PIN>::lo(); // kick a different register, block premature optimizations?
#endif
			FastPin<CLOCK_PIN>::hi(); CLOCK_HI_DELAY;
			FastPin<CLOCK_PIN>::lo(); CLOCK_LO_DELAY;
		} else {
			FastPin<DATA_PIN>::lo();
			FastPin<CLOCK_PIN>::hi(); CLOCK_HI_DELAY;
			FastPin<CLOCK_PIN>::lo(); CLOCK_LO_DELAY;
		}
		//sei();
	}
@mitchsf

This comment has been minimized.

Show comment
Hide comment
@mitchsf

mitchsf Apr 18, 2018

I don't think you will see the problem with the APA102 and ESP32, unless you test with an active WiFi connection.

I'm using pin 19 for clock, 15 for data, and a DotStar strip. Also a smaller strip of 12 LEDs.

I was never able to get FastLED to work, so I experimented with both the DotStar library, and a small set of hard coded functions. Both worked perfectly without WiFi, and both had the identical flicker issue with an active WiFi connection. After reading this thread, I remembered that I had to add microsecond delays after the data write, and between clock states, to reliably clock data to HV5530 chips. So I just added 20 microsecond delays before and after setting the clock pin high in the DotStar library, and it is now working perfectly, with no flicker. I'd like to switch back to FastLED, so at some point I'll test the suggested changes. Thanks for the help with this!

mitchsf commented Apr 18, 2018

I don't think you will see the problem with the APA102 and ESP32, unless you test with an active WiFi connection.

I'm using pin 19 for clock, 15 for data, and a DotStar strip. Also a smaller strip of 12 LEDs.

I was never able to get FastLED to work, so I experimented with both the DotStar library, and a small set of hard coded functions. Both worked perfectly without WiFi, and both had the identical flicker issue with an active WiFi connection. After reading this thread, I remembered that I had to add microsecond delays after the data write, and between clock states, to reliably clock data to HV5530 chips. So I just added 20 microsecond delays before and after setting the clock pin high in the DotStar library, and it is now working perfectly, with no flicker. I'd like to switch back to FastLED, so at some point I'll test the suggested changes. Thanks for the help with this!

@Cysign

This comment has been minimized.

Show comment
Hide comment
@Cysign

Cysign May 8, 2018

Didn't get it at all. What do I have to change to make my ESP32 runninf FastLED properly?

At the moment I get:

C:\Program Files (x86)\Arduino\libraries\FastLED-3.1.0/led_sysdefs.h:22:2: error: #error "XTENSA-architecture microcontrollers are not supported."

#error "XTENSA-architecture microcontrollers are not supported."

Cysign commented May 8, 2018

Didn't get it at all. What do I have to change to make my ESP32 runninf FastLED properly?

At the moment I get:

C:\Program Files (x86)\Arduino\libraries\FastLED-3.1.0/led_sysdefs.h:22:2: error: #error "XTENSA-architecture microcontrollers are not supported."

#error "XTENSA-architecture microcontrollers are not supported."

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer May 8, 2018

Contributor

@Cysign First, make sure you have ESP32 support installed in your Arduino IDE. Then get my branch of FastLED. (We are hoping to merge it into the main branch soon.)

Contributor

samguyer commented May 8, 2018

@Cysign First, make sure you have ESP32 support installed in your Arduino IDE. Then get my branch of FastLED. (We are hoping to merge it into the main branch soon.)

@Cysign

This comment has been minimized.

Show comment
Hide comment
@Cysign

Cysign May 8, 2018

Thanks for your reply. I could manage to compile FastLED, now. But my oscilloscope doesn't show proper results on my FastLED pin.
Have to have a closer look tomorrow ;)

Cysign commented May 8, 2018

Thanks for your reply. I could manage to compile FastLED, now. But my oscilloscope doesn't show proper results on my FastLED pin.
Have to have a closer look tomorrow ;)

@Cysign

This comment has been minimized.

Show comment
Hide comment
@Cysign

Cysign May 8, 2018

Looks like it compiled and uploaded well, maybe there's another difference to casual Arduino boards. At the moment I didn't use a level converter, but 3.3V should be fine as high level for WS2812:

C:\Users<username>\Documents\Arduino\hardware\espressif\esp32/tools/esptool.exe --chip esp32 --port COM8 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 C:\Users<username>\Documents\Arduino\hardware\espressif\esp32/tools/partitions/boot_app0.bin 0x1000 C:\Users<username>\Documents\Arduino\hardware\espressif\esp32/tools/sdk/bin/bootloader_qio_80m.bin 0x10000 C:\Users<username>\AppData\Local\Temp\arduino_build_460389/DemoReel100.ino.bin 0x8000 C:\Users<usernams>\AppData\Local\Temp\arduino_build_460389/DemoReel100.ino.partitions.bin
esptool.py v2.3.1
Connecting......
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 8192 bytes to 47...

Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 21845.2 kbit/s)...
Hash of data verified.
Compressed 14320 bytes to 9327...

Writing at 0x00001000... (100 %)
Wrote 14320 bytes (9327 compressed) at 0x00001000 in 0.1 seconds (effective 916.5 kbit/s)...
Hash of data verified.
Compressed 167344 bytes to 86784...

Writing at 0x00010000... (16 %)
Writing at 0x00014000... (33 %)
Writing at 0x00018000... (50 %)
Writing at 0x0001c000... (66 %)
Writing at 0x00020000... (83 %)
Writing at 0x00024000... (100 %)
Wrote 167344 bytes (86784 compressed) at 0x00010000 in 1.5 seconds (effective 886.6 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 134...

Writing at 0x00008000... (100 %)
Wrote 3072 bytes (134 compressed) at 0x00008000 in 0.0 seconds (effective 4915.1 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

Cysign commented May 8, 2018

Looks like it compiled and uploaded well, maybe there's another difference to casual Arduino boards. At the moment I didn't use a level converter, but 3.3V should be fine as high level for WS2812:

C:\Users<username>\Documents\Arduino\hardware\espressif\esp32/tools/esptool.exe --chip esp32 --port COM8 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size detect 0xe000 C:\Users<username>\Documents\Arduino\hardware\espressif\esp32/tools/partitions/boot_app0.bin 0x1000 C:\Users<username>\Documents\Arduino\hardware\espressif\esp32/tools/sdk/bin/bootloader_qio_80m.bin 0x10000 C:\Users<username>\AppData\Local\Temp\arduino_build_460389/DemoReel100.ino.bin 0x8000 C:\Users<usernams>\AppData\Local\Temp\arduino_build_460389/DemoReel100.ino.partitions.bin
esptool.py v2.3.1
Connecting......
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 8192 bytes to 47...

Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds (effective 21845.2 kbit/s)...
Hash of data verified.
Compressed 14320 bytes to 9327...

Writing at 0x00001000... (100 %)
Wrote 14320 bytes (9327 compressed) at 0x00001000 in 0.1 seconds (effective 916.5 kbit/s)...
Hash of data verified.
Compressed 167344 bytes to 86784...

Writing at 0x00010000... (16 %)
Writing at 0x00014000... (33 %)
Writing at 0x00018000... (50 %)
Writing at 0x0001c000... (66 %)
Writing at 0x00020000... (83 %)
Writing at 0x00024000... (100 %)
Wrote 167344 bytes (86784 compressed) at 0x00010000 in 1.5 seconds (effective 886.6 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 134...

Writing at 0x00008000... (100 %)
Wrote 3072 bytes (134 compressed) at 0x00008000 in 0.0 seconds (effective 4915.1 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

@Cysign

This comment has been minimized.

Show comment
Hide comment
@Cysign

Cysign May 8, 2018

Well, didn't know I do not have to use a resistor between my controller and WS2812.
Now it seems to work - in some degree.

Just connected two LEDs using DemoReel100.
Fading from red to orange works fine. But then there seems to be a hickup while blue is blinking for just a single time and back to red. Might this be a known issue?

Cysign commented May 8, 2018

Well, didn't know I do not have to use a resistor between my controller and WS2812.
Now it seems to work - in some degree.

Just connected two LEDs using DemoReel100.
Fading from red to orange works fine. But then there seems to be a hickup while blue is blinking for just a single time and back to red. Might this be a known issue?

@phrfpeixoto

This comment has been minimized.

Show comment
Hide comment
@phrfpeixoto

phrfpeixoto May 10, 2018

Hello, I'm struggling to this lib work with some ESP32 dev kits I've got. They have no brand, just say Devkit v1

Here's the simplest skecth possible:
https://gist.github.com/phrfpeixoto/2e7bf3813c039b0191f0eb231cc52d2f

I'm using Arduino IDE 1.8.5 and FastLED 3.1.6. The chip hangs and reboots as soon as the show() is executed.

configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
modeGuru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1)
Core 1 register dump:
PC : 0x400853b9 PS : 0x00060334 A0 : 0x8008108b A1 : 0x3ffca690
A2 : 0x3ffc1024 A3 : 0x00000000 A4 : 0x00000000 A5 : 0x00000001
A6 : 0x400d0d34 A7 : 0x3ffc22ac A8 : 0x0000abab A9 : 0x0000abab
A10 : 0xb33fffff A11 : 0x0000cdcd A12 : 0x00060322 A13 : 0x00000001
A14 : 0x00060322 A15 : 0x00000000 SAR : 0x0000000e EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0xffffffff

Backtrace: 0x400853b9:0x3ffca690 0x40081088:0x3ffca6b0 0x400e3dba:0x3ffca6d0

Core 0 register dump:
PC : 0x400d377e PS : 0x00060734 A0 : 0x8008593d A1 : 0x3ffc6df0
A2 : 0x00000008 A3 : 0x00000000 A4 : 0x00000001 A5 : 0x3ffc7434
A6 : 0x00000000 A7 : 0x00000001 A8 : 0x3ffc29e4 A9 : 0x3ffc29c8
A10 : 0x00000000 A11 : 0x00000001 A12 : 0x800869b8 A13 : 0x3ffc6cf0
A14 : 0x00000000 A15 : 0x3ffc6aa0 SAR : 0x00000000 EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000

Backtrace: 0x400d377e:0x3ffc6df0 0x4008593a:0x3ffc6e10

Rebooting...

I'm a beginner here, so bear with me. Can you help me?

phrfpeixoto commented May 10, 2018

Hello, I'm struggling to this lib work with some ESP32 dev kits I've got. They have no brand, just say Devkit v1

Here's the simplest skecth possible:
https://gist.github.com/phrfpeixoto/2e7bf3813c039b0191f0eb231cc52d2f

I'm using Arduino IDE 1.8.5 and FastLED 3.1.6. The chip hangs and reboots as soon as the show() is executed.

configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
modeGuru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1)
Core 1 register dump:
PC : 0x400853b9 PS : 0x00060334 A0 : 0x8008108b A1 : 0x3ffca690
A2 : 0x3ffc1024 A3 : 0x00000000 A4 : 0x00000000 A5 : 0x00000001
A6 : 0x400d0d34 A7 : 0x3ffc22ac A8 : 0x0000abab A9 : 0x0000abab
A10 : 0xb33fffff A11 : 0x0000cdcd A12 : 0x00060322 A13 : 0x00000001
A14 : 0x00060322 A15 : 0x00000000 SAR : 0x0000000e EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0xffffffff

Backtrace: 0x400853b9:0x3ffca690 0x40081088:0x3ffca6b0 0x400e3dba:0x3ffca6d0

Core 0 register dump:
PC : 0x400d377e PS : 0x00060734 A0 : 0x8008593d A1 : 0x3ffc6df0
A2 : 0x00000008 A3 : 0x00000000 A4 : 0x00000001 A5 : 0x3ffc7434
A6 : 0x00000000 A7 : 0x00000001 A8 : 0x3ffc29e4 A9 : 0x3ffc29c8
A10 : 0x00000000 A11 : 0x00000001 A12 : 0x800869b8 A13 : 0x3ffc6cf0
A14 : 0x00000000 A15 : 0x3ffc6aa0 SAR : 0x00000000 EXCCAUSE: 0x00000006
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000

Backtrace: 0x400d377e:0x3ffc6df0 0x4008593a:0x3ffc6e10

Rebooting...

I'm a beginner here, so bear with me. Can you help me?

@phrfpeixoto

This comment has been minimized.

Show comment
Hide comment
@phrfpeixoto

phrfpeixoto May 10, 2018

Just noticed that Arduino IDE reported installed version as 3.1.6, which was latest.
Code was actually reporting 3.1.7. Just installed 3.1.8 and still with the same issue.

phrfpeixoto commented May 10, 2018

Just noticed that Arduino IDE reported installed version as 3.1.6, which was latest.
Code was actually reporting 3.1.7. Just installed 3.1.8 and still with the same issue.

@phrfpeixoto

This comment has been minimized.

Show comment
Hide comment
@phrfpeixoto

phrfpeixoto May 10, 2018

Managed to get it working on the sandbox sketch. I forced a complete recompile after reinstalling esp32 board libs and fastled master branch from https://github.com/samguyer/FastLED.

phrfpeixoto commented May 10, 2018

Managed to get it working on the sandbox sketch. I forced a complete recompile after reinstalling esp32 board libs and fastled master branch from https://github.com/samguyer/FastLED.

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer May 11, 2018

Contributor

@phrfpeixoto That's great! Let us know if you run into other problems. Also, there is a really cool plugin for the Arduino IDE that will decode those ESP call stacks and show you where the crash is. Check it out:

https://github.com/me-no-dev/EspExceptionDecoder

Contributor

samguyer commented May 11, 2018

@phrfpeixoto That's great! Let us know if you run into other problems. Also, there is a really cool plugin for the Arduino IDE that will decode those ESP call stacks and show you where the crash is. Check it out:

https://github.com/me-no-dev/EspExceptionDecoder

@phrfpeixoto

This comment has been minimized.

Show comment
Hide comment
@phrfpeixoto

phrfpeixoto May 11, 2018

@samguyer Thanks for the tip. I hope that fix from you fork make to the origin soon.

phrfpeixoto commented May 11, 2018

@samguyer Thanks for the tip. I hope that fix from you fork make to the origin soon.

@mitchsf

This comment has been minimized.

Show comment
Hide comment
@mitchsf

mitchsf May 30, 2018

@focalintent WIth your modification below, FastLED went from not working at all, to working perfectly. I"m using APA102 LEDs with the ESP32 and latest Arduino core. Thanks.

#ifdef ESP32
FastPin<CLOCK_PIN>::lo(); // kick a different register, block premature optimizations?
#endif

mitchsf commented May 30, 2018

@focalintent WIth your modification below, FastLED went from not working at all, to working perfectly. I"m using APA102 LEDs with the ESP32 and latest Arduino core. Thanks.

#ifdef ESP32
FastPin<CLOCK_PIN>::lo(); // kick a different register, block premature optimizations?
#endif

@HorstBaerbel

This comment has been minimized.

Show comment
Hide comment
@HorstBaerbel

HorstBaerbel Aug 10, 2018

@samguyer: Have been trying out your fork on the ESP32 with WS2812Bs and parallel output does not seem to work (my code works on the ESP8266).

#define LED_PIN_STRIP1 23 // LED data port pin for upper half strip
#define LED_PIN_STRIP2 19 // LED data port pin for lower half strip
#define NUM_STRIPS 2 // We have two strips, one for the upper half, one for the lower
#define NUM_LEDS_WIDTH 30
#define NUM_LEDS_HEIGHT 18
#define NUM_LEDS (NUM_LEDS_WIDTH*NUM_LEDS_HEIGHT) // Number of LEDs (my configuration is 30*18=540)
#define NUM_LEDS_PER_STRIP (NUM_LEDS/NUM_STRIPS) // 30*18/2=270 LEDs per strip
CRGB leds[NUM_LEDS];

void setupLEDs() {
  FastLED.addLeds<WS2812B, LED_PIN_STRIP1, GRB>(leds, 0, NUM_LEDS_PER_STRIP); // first half starts at array index 0
  FastLED.addLeds<WS2812B, LED_PIN_STRIP2, GRB>(leds, NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP); // second half starts at array index 270
}

Only the first half of the strips it lit correctly, the other randomly. Swapping pin 19 / 23 does not change anything, so I guess it must be the library. Am I doing something wrong?

HorstBaerbel commented Aug 10, 2018

@samguyer: Have been trying out your fork on the ESP32 with WS2812Bs and parallel output does not seem to work (my code works on the ESP8266).

#define LED_PIN_STRIP1 23 // LED data port pin for upper half strip
#define LED_PIN_STRIP2 19 // LED data port pin for lower half strip
#define NUM_STRIPS 2 // We have two strips, one for the upper half, one for the lower
#define NUM_LEDS_WIDTH 30
#define NUM_LEDS_HEIGHT 18
#define NUM_LEDS (NUM_LEDS_WIDTH*NUM_LEDS_HEIGHT) // Number of LEDs (my configuration is 30*18=540)
#define NUM_LEDS_PER_STRIP (NUM_LEDS/NUM_STRIPS) // 30*18/2=270 LEDs per strip
CRGB leds[NUM_LEDS];

void setupLEDs() {
  FastLED.addLeds<WS2812B, LED_PIN_STRIP1, GRB>(leds, 0, NUM_LEDS_PER_STRIP); // first half starts at array index 0
  FastLED.addLeds<WS2812B, LED_PIN_STRIP2, GRB>(leds, NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP); // second half starts at array index 270
}

Only the first half of the strips it lit correctly, the other randomly. Swapping pin 19 / 23 does not change anything, so I guess it must be the library. Am I doing something wrong?

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer Aug 10, 2018

Contributor

@HorstBaerbel That is strange. Let me try out your code, and I'll get back to you soon.

Contributor

samguyer commented Aug 10, 2018

@HorstBaerbel That is strange. Let me try out your code, and I'll get back to you soon.

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer Aug 14, 2018

Contributor

@HorstBaerbel I was not able to reproduce the problem on my setup. Can you tell me about the hardware you're using?

Contributor

samguyer commented Aug 14, 2018

@HorstBaerbel I was not able to reproduce the problem on my setup. Can you tell me about the hardware you're using?

@HorstBaerbel

This comment has been minimized.

Show comment
Hide comment
@HorstBaerbel

HorstBaerbel Aug 14, 2018

Thanks for trying. I use a WEMOS Lolin32 clone and a 30A 5V power supply. All 18 strips have 5V and GND individually fed in from the strip start. The script ran on an ESP8266 (ModeMCU clone), but it was flickering etc. like hell because of interrupts. I wanted to use WiFi / Websockets, so figured I should try with an ESP32 to get a stable display. I don't use a level converter, but all my other projects (that have less LEDs though and no parallel output) never needed one...
I have commented out everything except the LED driving code in my script.

// LED strip setup
#define CALIBRATION_TEMPERATURE TypicalLEDStrip
#define MAX_BRIGHTNESS 255 // 0-255
#define LED_PIN_STRIP1 19 // Define LED data port pin for upper half strip
#define LED_PIN_STRIP2 23 // Define LED data port pin for lower half strip
//initialise LED-array
#define NUM_STRIPS 2 // We have two strips, one for the upper half, one for the lower
#define NUM_LEDS_WIDTH 30
#define NUM_LEDS_HEIGHT 18
#define NUM_LEDS (NUM_LEDS_WIDTH*NUM_LEDS_HEIGHT) // Number of LEDs (my configuration is 30*18=540)
#define NUM_LEDS_PER_STRIP (NUM_LEDS/NUM_STRIPS) // 30*18/2=270 LEDs per strip
#define MAX_FRAME_RATE 30 // Maximum 30Hz update rate
CRGB leds[NUM_LEDS];

void setupLEDs() {
  // clear led color buffer to black
  memset(leds, 0, NUM_LEDS * sizeof(struct CRGB));
  // initialize FastLed library for the WS2812B strip
  FastLED.addLeds<WS2812B, LED_PIN_STRIP1, GRB>(leds, 0, NUM_LEDS_PER_STRIP); // first half is at pin 19 and starts at array index 0
  FastLED.addLeds<WS2812B, LED_PIN_STRIP2, GRB>(leds, NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP); // second half is at pin 23 and starts at array index 270
  FastLED.setTemperature(CALIBRATION_TEMPERATURE);
  FastLED.setBrightness(MAX_BRIGHTNESS);
  FastLED.setDither(DISABLE_DITHER);
}

void initialLEDflash() {
  LEDS.showColor(CRGB(127, 0, 0));
  delay(333);
  LEDS.showColor(CRGB(0, 127, 0));
  delay(333);
  LEDS.showColor(CRGB(0, 0, 127));
  delay(333);
  LEDS.showColor(CRGB(0, 0, 0));
}

void setup() {
  setupLEDs();
  initialLEDflash();
}

void loop() {
  // update display if new data arrived, but only with max. 30Hz
  EVERY_N_MILLISECONDS(1000 / MAX_FRAME_RATE) {
    LEDS.showColor(CHSV(led_color++, 255, 128));
  }
}

HorstBaerbel commented Aug 14, 2018

Thanks for trying. I use a WEMOS Lolin32 clone and a 30A 5V power supply. All 18 strips have 5V and GND individually fed in from the strip start. The script ran on an ESP8266 (ModeMCU clone), but it was flickering etc. like hell because of interrupts. I wanted to use WiFi / Websockets, so figured I should try with an ESP32 to get a stable display. I don't use a level converter, but all my other projects (that have less LEDs though and no parallel output) never needed one...
I have commented out everything except the LED driving code in my script.

// LED strip setup
#define CALIBRATION_TEMPERATURE TypicalLEDStrip
#define MAX_BRIGHTNESS 255 // 0-255
#define LED_PIN_STRIP1 19 // Define LED data port pin for upper half strip
#define LED_PIN_STRIP2 23 // Define LED data port pin for lower half strip
//initialise LED-array
#define NUM_STRIPS 2 // We have two strips, one for the upper half, one for the lower
#define NUM_LEDS_WIDTH 30
#define NUM_LEDS_HEIGHT 18
#define NUM_LEDS (NUM_LEDS_WIDTH*NUM_LEDS_HEIGHT) // Number of LEDs (my configuration is 30*18=540)
#define NUM_LEDS_PER_STRIP (NUM_LEDS/NUM_STRIPS) // 30*18/2=270 LEDs per strip
#define MAX_FRAME_RATE 30 // Maximum 30Hz update rate
CRGB leds[NUM_LEDS];

void setupLEDs() {
  // clear led color buffer to black
  memset(leds, 0, NUM_LEDS * sizeof(struct CRGB));
  // initialize FastLed library for the WS2812B strip
  FastLED.addLeds<WS2812B, LED_PIN_STRIP1, GRB>(leds, 0, NUM_LEDS_PER_STRIP); // first half is at pin 19 and starts at array index 0
  FastLED.addLeds<WS2812B, LED_PIN_STRIP2, GRB>(leds, NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP); // second half is at pin 23 and starts at array index 270
  FastLED.setTemperature(CALIBRATION_TEMPERATURE);
  FastLED.setBrightness(MAX_BRIGHTNESS);
  FastLED.setDither(DISABLE_DITHER);
}

void initialLEDflash() {
  LEDS.showColor(CRGB(127, 0, 0));
  delay(333);
  LEDS.showColor(CRGB(0, 127, 0));
  delay(333);
  LEDS.showColor(CRGB(0, 0, 127));
  delay(333);
  LEDS.showColor(CRGB(0, 0, 0));
}

void setup() {
  setupLEDs();
  initialLEDflash();
}

void loop() {
  // update display if new data arrived, but only with max. 30Hz
  EVERY_N_MILLISECONDS(1000 / MAX_FRAME_RATE) {
    LEDS.showColor(CHSV(led_color++, 255, 128));
  }
}
@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer Aug 14, 2018

Contributor

@HorstBaerbel Can you try something out for me? Instead of using showColor, can you call fill_solid to set the color, then call FastLED.show() separately.

Contributor

samguyer commented Aug 14, 2018

@HorstBaerbel Can you try something out for me? Instead of using showColor, can you call fill_solid to set the color, then call FastLED.show() separately.

@HorstBaerbel

This comment has been minimized.

Show comment
Hide comment
@HorstBaerbel

HorstBaerbel Aug 14, 2018

I found the problem using my (handheld, small and crappy) oscilloscope. I seem to have shorted out pin 19 to GND on the prototype board and were no signals on pin 19. Thanks for the help and sorry for the hassle!
Parallel mode with 540 LEDs is pretty smooth now on the ESP32. Without frame rate limiting (no "EVERY_N_MILLISECONDS") I see a flicker every ~20-30s, but at 60Hz it seems to be gone. Nice work!

HorstBaerbel commented Aug 14, 2018

I found the problem using my (handheld, small and crappy) oscilloscope. I seem to have shorted out pin 19 to GND on the prototype board and were no signals on pin 19. Thanks for the help and sorry for the hassle!
Parallel mode with 540 LEDs is pretty smooth now on the ESP32. Without frame rate limiting (no "EVERY_N_MILLISECONDS") I see a flicker every ~20-30s, but at 60Hz it seems to be gone. Nice work!

@samguyer

This comment has been minimized.

Show comment
Hide comment
@samguyer

samguyer Aug 15, 2018

Contributor

@HorstBaerbel That's great! Glad to hear you fixed the problem (and that it wasn't some terrible bug in the library!)

Contributor

samguyer commented Aug 15, 2018

@HorstBaerbel That's great! Glad to hear you fixed the problem (and that it wasn't some terrible bug in the library!)

@hamburgtech

This comment has been minimized.

Show comment
Hide comment
@hamburgtech

hamburgtech Aug 20, 2018

Hi guys,

I am working on a POV project, that is using 4 single strips of apa102 leds rotation around the core.
The used controller is a ESP32, because it's quite cheap and offers a good performance and Bluetooth + Wifi. We are using 4 different strips to display a 70 x 200 image, because of the 4 different stripes we can run at lower RPM and therefore have less noise, but still have a flicker free and bright image.

The issue that we are facing is, that we had to realise, that we can't display 70 x 200 at around 320 RPM, we were only getting to 109 columns displayed. We checked everything to find the reason for this. Then we found out that we had only 6 MHz speed for updating the LEDs... The SPI for the ESP32 seems not to be supported by the FastLED library :-(

With other ways it was possible to get a high SPI rate with the ESP32, but we would still like to use the FastLED library, because we are used to it and it makes things more easy :-)

Is there any chance that the SPI support for the ESP32 will be added?

Thanks a lot.

Cheers,
Nils

hamburgtech commented Aug 20, 2018

Hi guys,

I am working on a POV project, that is using 4 single strips of apa102 leds rotation around the core.
The used controller is a ESP32, because it's quite cheap and offers a good performance and Bluetooth + Wifi. We are using 4 different strips to display a 70 x 200 image, because of the 4 different stripes we can run at lower RPM and therefore have less noise, but still have a flicker free and bright image.

The issue that we are facing is, that we had to realise, that we can't display 70 x 200 at around 320 RPM, we were only getting to 109 columns displayed. We checked everything to find the reason for this. Then we found out that we had only 6 MHz speed for updating the LEDs... The SPI for the ESP32 seems not to be supported by the FastLED library :-(

With other ways it was possible to get a high SPI rate with the ESP32, but we would still like to use the FastLED library, because we are used to it and it makes things more easy :-)

Is there any chance that the SPI support for the ESP32 will be added?

Thanks a lot.

Cheers,
Nils

@focalintent

This comment has been minimized.

Show comment
Hide comment
@focalintent

focalintent Aug 20, 2018

Member

Adding hardware SPI for esp32 is on the “will eventually get done” list - but I don’t have a timeframe for it yet (and no one has submitted support for it)

Member

focalintent commented Aug 20, 2018

Adding hardware SPI for esp32 is on the “will eventually get done” list - but I don’t have a timeframe for it yet (and no one has submitted support for it)

@hamburgtech

This comment has been minimized.

Show comment
Hide comment
@hamburgtech

hamburgtech Aug 20, 2018

Adding hardware SPI for esp32 is on the “will eventually get done” list - but I don’t have a timeframe for it yet (and no one has submitted support for it)

@focalintent Thanks for your quick reply.
Okay sad to hear that it's officially not supported. Is there any known branch that have SPI support for the ESP32?
The ESP32 is a perfect platform for POV project, it's cheap, has a lot of performance, BT and Wifi and so on. But without that SPI support it can't be used like that with FastLED.

Well I will try to get into it and create some ESP32 solution for FastLED, but I think I could need some support for this.

Thanks so far.

Cheers,
Nils

hamburgtech commented Aug 20, 2018

Adding hardware SPI for esp32 is on the “will eventually get done” list - but I don’t have a timeframe for it yet (and no one has submitted support for it)

@focalintent Thanks for your quick reply.
Okay sad to hear that it's officially not supported. Is there any known branch that have SPI support for the ESP32?
The ESP32 is a perfect platform for POV project, it's cheap, has a lot of performance, BT and Wifi and so on. But without that SPI support it can't be used like that with FastLED.

Well I will try to get into it and create some ESP32 solution for FastLED, but I think I could need some support for this.

Thanks so far.

Cheers,
Nils

@hamid-elaosta

This comment has been minimized.

Show comment
Hide comment
@hamid-elaosta

hamid-elaosta Aug 20, 2018

@hamburgtech I tried to add hardware SPI but FastLED is a big project and I'm not familiar with its code base. I ended up writing a simple sketch for ESP32 to take advantage of hardware SPI for my purposes (Hyperion) as the APA102s I'm using are really simple to control over SPI.

hamid-elaosta commented Aug 20, 2018

@hamburgtech I tried to add hardware SPI but FastLED is a big project and I'm not familiar with its code base. I ended up writing a simple sketch for ESP32 to take advantage of hardware SPI for my purposes (Hyperion) as the APA102s I'm using are really simple to control over SPI.

@focalintent

This comment has been minimized.

Show comment
Hide comment
@focalintent

focalintent Aug 20, 2018

Member

From https://github.com/FastLED/FastLED/blob/master/PORTING.md

== Porting fastspi.h ==

This is where you define the low level interface to the hardware SPI system (including a writePixels method that does a bunch of housekeeping for writing led data). Use the fastspi_nop.h file as a reference for the methods that need to be implemented. There are ofteh other useful methods that can help with the internals of the SPI code, I recommend taking a look at how the various platforms implement their SPI classes.

The AVR example of how to do this is presets straightforward and can be used as a reference - https://github.com/FastLED/FastLED/blob/master/platforms/avr/fastspi_avr.h - also the teensy 3.2’s support, though that’s a bit more complex - https://github.com/FastLED/FastLED/blob/master/platforms/arm/k20/fastspi_arm_k20.h

The biggest part will be getting the control registers for configuring the SPI output and determining the right register settings for various clock speeds and then writing data into the registers.

As far as I know, no one has done this for the esp’s yet.

Member

focalintent commented Aug 20, 2018

From https://github.com/FastLED/FastLED/blob/master/PORTING.md

== Porting fastspi.h ==

This is where you define the low level interface to the hardware SPI system (including a writePixels method that does a bunch of housekeeping for writing led data). Use the fastspi_nop.h file as a reference for the methods that need to be implemented. There are ofteh other useful methods that can help with the internals of the SPI code, I recommend taking a look at how the various platforms implement their SPI classes.

The AVR example of how to do this is presets straightforward and can be used as a reference - https://github.com/FastLED/FastLED/blob/master/platforms/avr/fastspi_avr.h - also the teensy 3.2’s support, though that’s a bit more complex - https://github.com/FastLED/FastLED/blob/master/platforms/arm/k20/fastspi_arm_k20.h

The biggest part will be getting the control registers for configuring the SPI output and determining the right register settings for various clock speeds and then writing data into the registers.

As far as I know, no one has done this for the esp’s yet.

@NZSmartie

This comment has been minimized.

Show comment
Hide comment
@NZSmartie

NZSmartie Aug 30, 2018

I got myself a strip of 150 SK9822 LEDs and this #504 (comment) fixed the issue for me

// write the BIT'th bit out via spi, setting the data pin then strobing the clcok
	template <uint8_t BIT> __attribute__((always_inline, hot)) inline static void writeBit(uint8_t b) {
		//cli();
		if(b & (1 << BIT)) {
			FastPin<DATA_PIN>::hi();
#ifdef ESP32
                        FastPin<CLOCK_PIN>::lo(); // kick a different register, block premature optimizations?
#endif
			FastPin<CLOCK_PIN>::hi(); CLOCK_HI_DELAY;
			FastPin<CLOCK_PIN>::lo(); CLOCK_LO_DELAY;
		} else {
			FastPin<DATA_PIN>::lo();
			FastPin<CLOCK_PIN>::hi(); CLOCK_HI_DELAY;
			FastPin<CLOCK_PIN>::lo(); CLOCK_LO_DELAY;
		}
		//sei();
	}

NZSmartie commented Aug 30, 2018

I got myself a strip of 150 SK9822 LEDs and this #504 (comment) fixed the issue for me

// write the BIT'th bit out via spi, setting the data pin then strobing the clcok
	template <uint8_t BIT> __attribute__((always_inline, hot)) inline static void writeBit(uint8_t b) {
		//cli();
		if(b & (1 << BIT)) {
			FastPin<DATA_PIN>::hi();
#ifdef ESP32
                        FastPin<CLOCK_PIN>::lo(); // kick a different register, block premature optimizations?
#endif
			FastPin<CLOCK_PIN>::hi(); CLOCK_HI_DELAY;
			FastPin<CLOCK_PIN>::lo(); CLOCK_LO_DELAY;
		} else {
			FastPin<DATA_PIN>::lo();
			FastPin<CLOCK_PIN>::hi(); CLOCK_HI_DELAY;
			FastPin<CLOCK_PIN>::lo(); CLOCK_LO_DELAY;
		}
		//sei();
	}
@haaslukas

This comment has been minimized.

Show comment
Hide comment
@haaslukas

haaslukas Sep 3, 2018

Same here. I'm working with SK9822 LEDs and #504 fixed the issue when using a LOLIN32. Interestingly, I didn't need to add this register kick-in hack when programing an LOLIN32 Lite. Maybe it's due to a different chip version?

haaslukas commented Sep 3, 2018

Same here. I'm working with SK9822 LEDs and #504 fixed the issue when using a LOLIN32. Interestingly, I didn't need to add this register kick-in hack when programing an LOLIN32 Lite. Maybe it's due to a different chip version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment