unable to control neopixels with ESP 01 board

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
ark
Posts: 2
Joined: Wed May 19, 2021 9:54 am

unable to control neopixels with ESP 01 board

Post by ark » Wed May 26, 2021 7:33 pm

I'm running esp8266-1m-20210418-v1.15.bin on my ESP 01

I have a cheap ws2812 strip and a ESP-01 module and LED adapter.

I can control the LEDs just fine using nodemcu / lua

But if I flash my ESP01 with micropython v1.15 (for 1M flash) I'm unable to control the LEDs at all. The first shows brite white and the second green which is how they regularly are when you apply power. Here's the lua documentation.

I've tried

Code: Select all

import machine,neopixel
p = neopixel.NeoPixel(machine.Pin(2, machine.Pin.OUT), 8)
p.fill((255,0,0))
p.write()
or

Code: Select all

import machine,neopixel
p = neopixel.NeoPixel(machine.Pin(2), 3)
p[0] = (255,0,0)
p[1] = (0,0,255)
p[2] = (0,255,0)
p.write()
and also

Code: Select all

import esp, machine
esp.neopixel_write(machine.Pin(2, machine.Pin.OUT), bytearray([0, 0, 255]), True)
I'm using pin 2 since that's GPIO2 and that's what the lua ws2812 docs say it uses. But I've also tried passing 0,1,2,3 to Pin and none of those work either, neither does changing the last is800khz flag. I've verified that

Code: Select all

pin = machine.Pin(2, machine.Pin.OUT)
pin.value(1)
pin.value(0)
set the output voltage on pin 2 GPIO2 as expected.

I even had a go at trying to get this SPI code to work on an ESP01 and didn't have any luck with that.

Am I doing something obviously wrong? Thanks for your help.

My board ids as

Code: Select all

esptool.py --port $(jq -r .port .nodemcutool) flash_id
esptool.py v3.0
Serial port /dev/tty.usbserial-1420
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: f4:cf:a2:c8:37:e6
Uploading stub...
Running stub...
Stub running...
Manufacturer: 5e
Device: 6014
Detected flash size: 1MB
and I'm flashing it with

Code: Select all

FIRMWARE=../../thirdparty/esp8266/esp8266-1m-20210418-v1.15.bin
esptool.py --baud 460800 --port $(jq -r .port .nodemcutool) write_flash --flash_size=detect -fm dio 0 $FIRMWARE
repl works fine as does setting a pin's output to 0 or 1

ark
Posts: 2
Joined: Wed May 19, 2021 9:54 am

Re: unable to control neopixels with ESP 01 board

Post by ark » Tue Jun 01, 2021 7:49 pm

good news! I got this to work. I first set it all up with a ESP 12 board and it sometimes worked in REPL after a while. I then found if I did two

Code: Select all

esp.neopixel_write(machine.Pin(2, machine.Pin.OUT), bytearray([0, 0, 255]), True)
esp.neopixel_write(machine.Pin(2, machine.Pin.OUT), bytearray([0, 0, 255]), True)

# then I could do
p = neopixel.NeoPixel(machine.Pin(2, machine.Pin.OUT), 8)
p.fill((255, 0, 0))
p.write()
and finally I put it all into a main.py and that worked a treat right out of the bag! and it works with my ESP01 as well.

Post Reply