Setup SPI pins on ESP32 (ESP-WROOM-32)
Closed this issue · 1 comments
Dear @nickovs,
For my following ESP-32 board below, i have not succeeded to write on first 10 leds as shown in the code below. When i connect data out of WS2812b led strip to Mosi(Pin23), led strip completely turns White. Then, when i connect data out of WS2812b to SCK(Pin18), first pixel of the strip turns Green. I will be glad if you let me know about your opinion. (MicroPython v1.9.3-533-g4ff05ae4 on 2018-04-10; ESP32 module with ESP32 installed to the board)
from machine import Pin, SPI
import time
from neoSPI import NeoPixel
NUM_PIXELS = 18
mosi = Pin(23, mode = Pin.OUT)
miso = Pin(19, mode = Pin.IN)
sck = Pin(18, mode = Pin.OUT)
spi = SPI(-1, baudrate=3200000, polarity=0, phase=0, sck = sck, mosi = mosi, miso = miso)
np = NeoPixel(spi, NUM_PIXELS)
np[0:10] = (0,0,40)
np.write()
Hi,
I haven't tried this library yet and i'm working on an ESP8266 but it seems you're using the software implementation of the SPI in your code:
spi = SPI(-1, baudrate=3200000, polarity=0, phase=0, sck = sck, mosi = mosi, miso = miso)
I saw similar results to what you describe when I did that, I think the SW SPI can't handle the 3.2M baudrate, try using the hardware SPI:
spi = SPI(1, baudrate=3200000, polarity=0, phase=0)
This requires that you connect to the designated SPI pins on your board but worked much better for me,
at least up to 80 leds.