ESP8266 NeoMethods

Michael Miller edited this page Dec 23, 2018 · 3 revisions

The esp8266 requires hardware support to be able to reliably send the data stream. Due to this and the restrictions on which pins are used by each hardware peripheral, only io pins GPIO1, GPIO2, and GPIO3 can be used.
The DMA method will use GPIO3.
The UART1 methods will use GPIO2.
The UART0 methods will use GPIO1.

NeoEsp8266Dma800KbpsMethod

The NeoEsp8266Dma800KbpsMethod is the underlying method that gets used if you use Neo800KbpsMethod on Esp8266 platforms. There should be no need to use it directly.

The NeoEsp8266Dma800KbpsMethod only supports the RDX0/GPIO3 pin. The Pin argument is omitted. See other esp8266 methods below if you don't have this pin available.

NOTE: Due to the varied board layouts for Esp8266, even though the pin maybe exposed, it may not be usable due to some custom feature on the board you use. If you find it not working, you should review the hardware schematic of your board and confirm the pin is not used for other purposes that interferes with it being used for NeoPixelBus.

This method uses very little CPU for actually sending the data to NeoPixels but it requires an extra buffer for the DMA to read from. Thus there is a trade off of CPU use versus memory use. The extra buffer needed is four times the size of the primary pixel buffer.

It also requires the use of the RDX0/GPIO3 pin. The normal feature of this pin is the "Serial" receive. Using this DMA method will not allow you to receive serial from the primary Serial object; but it will not stop you from sending output like this...

    serial.println("I can still debug using serial println");

Due to the pin overlap, there are a few things to take into consideration.
First, when you are flashing the Esp8266, some LED types will react to the flashing and turn on. This is important if you have longer strips of pixels where the power use of full bright might exceed your design.
Second, the NeoPixelBus::Begin() MUST be called after the Serial.begin(). If they are called out of order, no pixel data will be sent as the Serial reconfigured the RDX0/GPIO3 pin to its needs.

For more details on Serial and pins, refer to the Esp8266 Arduino Reference

Thanks to g3gg0.de for porting the initial DMA support from the original which led to this work. The original was located at github/cnlohr/esp8266ws2812i2s. The current work is no longer based on that but it gave me the direction I needed to provide a solution.

NeoEsp8266Dma400KbpsMethod

Same as NeoEsp8266Dma800KbpsMethod but running at the older and slower data rate.
The NeoEsp8266Dma400KbpsMethod is the underlying method that gets used if you use Neo400KbpsMethod on Esp8266 platforms. There should be no need to use it directly.

NeoEsp8266DmaWs2812xMethod & NeoEsp8266DmaWs2813Method

Same as NeoEsp8266Dma800KbpsMethod. The name is only more specific but they all use the longer delay as required by these chips.

NeoEsp8266Uart1800KbpsMethod & NeoEsp8266Uart0800KbpsMethod

Use this instead of Neo800KbpsMethod to force your sketch to use the UART to send data.
NeoEsp8266Uart1800KbpsMethod only supports the TXD1/GPIO2 pin. NeoEsp8266Uart0800KbpsMethod only supports the TXD0/GPIO1 pin. The Pin argument is ignored and can be omitted.

NOTE: Due to the varied board layouts for Esp8266, even though the pin maybe exposed, it may not be usable due to some custom feature on the board you use. If you find it not working, you should review the hardware schematic of your board and confirm the pin is not used for other purposes that interferes with it being used for NeoPixelBus.

These methods uses the CPU to manage a small hardware managed UART buffer to send the data to the NeoPixels. Thus it requires more CPU overhead than the Dma method but it does NOT require an extra buffer.

If CPU cycles are an issue in your project, see NeoEsp8266AsyncUart1800KbpsMethod below.

Due to using the hardware UART, the associated Serial or Serial1 objects can not be used. If you use UART1, the Serial is still available and if you use UART0 then Serial1 is still available.

NeoEsp8266Uart#400KbpsMethod

Same as 800Kbps Method but running at the older and slower data rate.
Use this instead of Neo400KbpsMethod to force your sketch to use the Uart to send data.

NeoEsp8266Uart#Ws2812xMethod & NeoEsp8266Uart#Ws2813Method

Same as NeoEsp8266Uart#800KbpsMethod but using a longer delay as required by these chips.

NeoEsp8266AsyncUart#800KbpsMethod

Use this instead of Neo800KbpsMethod to force your sketch to use a UART to send data asynchronously.
NeoEsp8266AsyncUart1800KbpsMethod only supports the TXD1/GPIO2 pin. NeoEsp8266AsyncUart0800KbpsMethod only supports the TXD0/GPIO1 pin. The Pin argument is ignored and can be omitted.

WARNING: With this method, Serial and Serial1 can not be used due to the ISR is not shareable.
CAUTION: With this method the Pixels() method will return alternating pointers after each call to Show(); so the pointer returned should not be cached or retained between calls of Show().

NOTE: Due to the varied board layouts for Esp8266, even though the pin maybe exposed, it may not be usable due to some custom feature on the board you use. If you find it not working, you should review the hardware schematic of your board and confirm the pin is not used for other purposes that interferes with it being used for NeoPixelBus.

These methods uses the UART interrupt to read from a secondary buffer to send the data to the NeoPixels. It requires very little CPU overhead but does require an extra buffer similar to the Dma method.

If memory is an issue for your project, see the NeoEsp8266Uart#800KbpsMethod above.

Thanks to unaiur for providing the original implementation.

NeoEsp8266AsyncUart#400KbpsMethod

Same as NeoEsp8266AsyncUart#800KbpsMethod but running at the older and slower data rate.
Use this instead of Neo400KbpsMethod to force your sketch to use the Uart to send data asynchronously.

NeoEsp8266AsyncUart#Ws2812xMethod & NeoEsp8266AsyncUart#Ws2813Method

Same as NeoEsp8266AsyncUart800KbpsMethod but using a longer delay as required by these chips.

NeoEsp8266BitBang800KbpsMethod

NeoEsp8266BitBang800KbpsMethod supports any available pin between 0 and 15.
This method uses only the CPU to send data to the NeoPixels. But due to WiFi interrupts it is not stable when used with WiFi features of the Esp8266.
It is not recommended to use this method except for comparing results with the other methods. For very short runs of pixels (no more than about 3) it maybe possible to use this method without ill effects. If it fails, the pixels may not be correctly set. Use this instead of Neo800KbpsMethod to force your sketch to use the Bit Banging to send data.

NeoEsp8266BitBang400KbpsMethod

Same as NeoEsp8266BitBang800KbpsMethod but running at the older and slower data rate.
Use this instead of Neo400KbpsMethod to force your sketch to use the Bit Banging to send data.

NeoEsp8266BitBangWs2812xMethod & NeoEsp8266BitBangWs2813Method

Same as NeoEsp8266BitBang800KbpsMethod but using a longer delay as required by these chips.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.