Pycom LoPy4 & WS2812 LEDs

I cannot get the WS2812/Neopixel code working. It does turn on some of the LEDs but in a quite random way. Even with something very simple like

data = [(0,255,255)] * numLed

  • whatever I set for RGB it shows green.

    If i change the code I end up with random blue and white LEDs.

    I checked the number of LEDs so not sure what else to check.

Hi Ed,

Are you using a logic level shifter as shown in the Tutorial? This sounds like your LEDs aren’t getting a strong enough data signal.

Thanks for the quick reply.

I was just using 3.3V from the Pycom Expansion Board.

I did read that I could limit the code to a few LEDs to test the logic out.

If that is the case, would the following work - or do you have to define the full number (i.e. 59) of LEDs for the code to work ?

numLed = 2 #59 LEDs on the strip

chain = WS2812( ledNumber=numLed, brightness=10, dataPin=‘P11’ )

data = [(255,0,0)] * 2

The above actually lights up 5 LEDs - 3xblue, 1xwhite, 1 green !



I am now using a separate 4.5v battery supply, and have a 330 Ohm resistor on the signal Pin.
I am running very basic code - as below, but the results are just random illumination of the LEDs (and more than 4)- it changes every time I press Run.

numLed = 4
chain = WS2812( ledNumber=4, brightness=10, dataPin=‘P11’ )
data = [
(255, 0, 0), # red
(0, 255, 0), # green
(0, 0, 255), # blue
(85, 85, 85) # white

1 Like

Hi Ed,

Are you using a logic level shifter?

1 Like

I wasn’t initially as I had read I could drive it with 3v3 (it would be dimmer).
Now I have purchased a Level Shifter and wired up as per your diagram, but still getting random results.
Or rather now I just see 58 out of the 59 LEDs illuminated (1st one not), some light blue, the rest white. The latest simpler code is

numLed = 59 #59 LEDs
chain = WS2812( ledNumber=numLed, brightness=10, dataPin=‘P11’ )
data = [(255, 0, 0)] * numLed

The only difference is that I did not connect Lopy VIN to the 4.5V battery supply as I have the Lopy connected via USB.

Hi Ed,

Could you please provide a photo of your setup (as clear as possible),

and perhaps a diagram of how you have everything connected? Are you using a Lopy4 or a Lopy?


Thanks again for your help with this.

I am using a Lopy4 on a Pycom/Makr Expansion Board 3.1

I have attached 2 photos - let me know if you need to see any close-ups.

The diagram is exactly as you have here:

The only difference is that I did not use a +5V connection from the power supply to VIN on the Lopy4 - because I am powering it via USB whilst testing.

I checked the voltage output from the battery pack (show on the photo - 3 batteries so assuming 4.5V) but it was in fact around 3.7V.

So, I switched that for a 4-battery pack using NiMH - as suggested in this article:

That was showing a more healthy 5V and the lights did look brighter.

However I still have the problem of random results whenever I run the simplest of code.

Out of interest - is there a library available ?

That’s where I started off, looking at examples on the Adafruit website and other example projects such as this one:

(my project is similar to this)

Allexamples I have read suggest that you can just “import neopixels” - but I have not been able to find a library file,or rather one that you can just copy and it works. The Adafruit site talks about installing a whole ton of libraries, but whilst that may work on a PC, I don’t see how you can get that onto a LoPy4. The Adafruit site does say that their examples will run on MicroPython, but I always end up reading that I need CircuitPython.

My preference is for simplicity and the examples you posted seem very clear.

I just need to get them working !

Best regards



I was looking at the specification for the AdaFruit LED strip we have , which is here:

It states that “it will not work with the Basic Stamp, NETduino, any other interpreted/virtual machine microprocessor or any processor slower than 8 MHz”

I looked at the Lopy4 Spec sheet but cannot find any reference to the processor speed

Is the processor speed part of the problem ?


Hi Ed,

There are no NeoPixel libraries for Pycom boards, thats why I created this tutorial. This definitely works with the LoPy4 and WiPy with the expansion 3.x board. I tested it with both setups when writing the code, and it worked as expected.

It sounds like your LED strip has a bad data input still. The key thing about driving NeoPixels is the difference between the data input and the power input (to the LED strip). You can control NeoPixels with 0.7 * Vin.

Can you verify that your level shifter is working properly? I’m not sure what one you are using, but it’s different than the one I’ve used in the tutorial. I see that there is an RX and TX on each side. If I was a betting man I’d say you need to connect your blue data wire to RX0 for this to work.

Hopefully that sorts it out!


Thanks again.

Glad to hear you got it working with the same board; is the actual LED strip a factor ?

Is my Logic Shifter working properly ?

Hard to say as I am not sure how to test that.

My soldering skills are reasonable, but to be sure I soldered the pins to a 2nd Shifter and used that - but just the same.

Regarding the TX/RX - I am fairly sure the wiring is correct - mainly becuase it is the exactly same as you have.

Please see attached.

The only difference on the pins is that your HV and GND are the other way round.

From what I have read you have to connect TXI to TXO (or RXI to RXO if dropping down voltage).

One example reference:

I did take your advice and put the blue wire from TXI to RXO but the LEDs just don’t light up at all.

This is in line with what I would expect given the above - TXI (Low voltage signal in) has to be connected to TXO (High voltage signal out).

I will solder another Logic Shifter up just in case I have created 2 bad shifters, but if you have advice on how I can test this please let me know.


Logic Shifter Connection as per Core Electronics.pdf (72.6 KB)

It’s electronics, so it could be anything. Testing the data signal is more of a “half split” to look up/down the circuit.

Also worth noting that I’m not sure about the wiring within your logic level converters, though I can’t see a common ground between the battery pack and the USB (LoPy4).

It’s also not likely that 3 AA batteries in series will be enough to power a high density strip of RGB LEDs.

I’ve moved this to a new topic, as the project/issue is related to parts/hardware/power that are not used in @Stephen’s tutorial.