I wrote a sketch to receive E1.31 data over the serial port from an

I wrote a sketch to receive E1.31 data over the serial port from an ESP8266. The ESP8266 is receiving the data over WIFI and then sending it out over serial. The code works fine when I comment out FastLED.show() but when I leave it uncommented, it doesn’t work. I’ve been trying to debug and it looks like the packet is not being received properly when FastLED is outputting. Possibly a timing issue? Any ideas?
http://pastebin.com/Mtnxk5Bu

sounds like an interrupts thing - try putting in #define FASTLED_ALLOW_INTERRUPTS 0 right at the start, you might run into other problems but it’s one line and takes no time to test!

You have it backwards Pete, the problem is that the ws2811 driver for FastLED has to disable interrupts which means that any serial data that is sent during FastLED.show() will be lost because the interrupt handler won’t be allowed to fire.

The solutions include switching to 4-wire LEDs that aren’t timing based, find a way to detect receiving a partial frame and discard it and wait for the next one, try running on a teensy3.1 where interrupts can work, etc…

Thanks for the quick reply. Is there a different communications protocol I could use between the ESP8266 and the Mega that doesn’t use interrupts?

Not really, you can change how you’re getting data from the esp8266, however. Instead of having it send data whenever it wants, instead have it send data only when asked. Then you can ask for data in between writing led data out.

(Or, alternatively, switch to using dotstar/apa102 leds)

Thank you. I will look into that. I have a lot invested in WS2811 strings and don’t want to change them if I can help it.

A $20 Teensy 3.1 is probably your least expensive solution. Or $30 if you get the octo28 buffer board. If not, don’t forget to factor in buying a 74HCTxxx chip to increase the 3V signal to 5V for the WS2812. On the plus side, Teensy 3.1 is a huge step up in performance from Arduino Mega!

Thanks. I’ll look into the Teensy