1

Before I start, I should note that I have never used a Raspberry Pi before, so my only experience is trying to get this project to work.

I recently bought ALITOVE WS2811 12mm (5 V) LED lights in the hopes that I could hang them in my room and control the colors. I want to control the colors through a Raspberry Pi by using the Neopixels python library. I was able to create an ssh connection to the Raspberry Pi with my computer and run python files on the pi. However, I have been struggling to control the colors of the LEDS using a GPIO pin. Specifically, I have been using the GPIO18 pin. I am following this tutorial and am using this circuit:

enter image description here

When I plug everything in with a 5V 10A power supply, nothing turns on, even when I run the code. However, if I unground the Pi, then the LED lights start flashing randomly.

The current steps that I have taken to try and fix the error are: I checked my circuit and made sure the level shifter was properly oriented and the pins of the level shifter were correct according to the tutorial. I also tried directly connecting the DI line to the LEDs and was able to control the lights properly (obviously the LEDs were very dim, but it was a proof of concept).

I was hoping someone could help me as I am completely lost at this point. I have exhausted every idea to fix the error and can't seem to find answers online that don't already match the circuit above.

I also have a side question about powering my pi. Can I power the pi using the power supply too, or do I need to power it through a micro USB cable? Thank you.

When I directly connected the DI line to the Pi, I did not use an external power source. I just wired the pi's power, GPIO18 pin, and ground directly to the LEDs. This allowed me to control the lights, but the pi does not provide anywhere close to the necessary output, so the one light I had it turn on was dim. I just tried directly connecting the DI line to GPIO18 without level-shifting, but I am still connecting the LEDs to an external power source and am having the same issue as before. This time, when I unground the pi, the lights are all white, even though I am telling them to be red and green ((0, 255, 0) and (255, 0, 0)). Here is the code I am running:

import board
import neopixel

pixels = neopixel.NeoPixel(board.D18, 50, auto_write=True)
pixels.fill((0, 255, 0))
pixels[0] = (255, 0, 0)
pixels[1] = (255, 0, 0)

I also tried out the other two sets of the same LEDs I got, and when I ran the code with the circuit above, except I added a 3K ohm resistor in series with the pi ground, the first LED randomly changed colors, and a couple of LEDs, not necessarily adjacent, went to a couple of random colors. Every time I ran the code, a new set of LEDS would light up with a couple of random colors.

I tried connecting the unused /OE and inputs of the level-shifter, and it did not seem to work. However, it definitely did something. I checked the voltage of the data line output, and without the added connections, the voltage was 3.3 V. With the connections, I got 0.15 V. The black lead was on the GND of the level-shifter and the red lead was on pin three of the level-shifter. I investigated what would happen if I unplugged the GND of the pi and the voltage went to 1.5 V. I also tested the power supply and got 5 V as expected, so my multimeter seems to be working. I might just choose a different way to transform the voltage. I should also note that I did check that the input was going in from the correct direction.

Here is a picture of my circuit:

https://ibb.co/nnkQPZG https://ibb.co/LdNtmyy

Here is an image of directly connecting the pi and LEDs: https://ibb.co/SwpzNHz

4
  • The Pi needs 5V. If your power supply provides 5V you can use it to power the Pi via the 5V and ground pins on the expansion header. Saying some WS2812 is not helpful. You need to update your question with exactly what you bought and its datasheet.
    – joan
    Jan 24, 2021 at 9:07
  • I bought ALITOVE WS2811 12mm (5V) LEDs, which have one data line. Jan 24, 2021 at 10:10
  • 74H125 is not a level shifter it is a tri-state buffer
    – Milliways
    Jan 25, 2021 at 6:35
  • Does that mean it will not work for its intended purpose? I bought it from Adafruit and they called it a "quad level shifter" and said it is good at converting 3V inputs to 5V outputs. Jan 25, 2021 at 6:45

2 Answers 2

1

The 74HCT125 is a tri-state buffer, but you can use it as a level shifter. If you look at the datasheet page 3, you will see that the minimum voltage for a high input is 2V, which is lower than the 3.3V the Pi provides.

Are you using a breadboard like the drawing? Have you checked your wiring? Note that there are two pins on the 125 that is connected to ground. One for power supply and one for enabling the output.

Things to try:

  1. Power off, use measure all connections using a multimeter using the continuity test. Put one lead on the negative of the battery and check connection to GND on the pi, pin 1 and 7 on the 125, GND on the strip. On the pi, measure the pin from the backside of the pi. Do not take the wires off the pis connector. Check the rest of the connections in the same way

  2. Going back to the datasheet, it states that /OE should be connected to VCC through a pullup resistor, so try doing that

  3. Do you have an arduino or some other devices that runs on 5V? If so, try using that for testing the LED strip.

  4. Also in the datasheet, page 3, note 4 under the table: "All unused inputs of the device must be held at VCCor GND to ensure proper device operation". Connect all other inputs (2A, 3A and 4A) to GND. Connect the /OE2,3 and 4 to VCC to turn off the outputs.

13
  • I am using a solderless breadboard. I checked the connections using a multimeter and to my knowledge everything was connected as expected. Unfortunately, I do not have an Arduino, but I will try connecting the /OE pins to the VCC and other pins to the GND tomorrow. I am also going to test out another pin on the pi to make sure its not an issue with the GPIO18 pin. Jan 26, 2021 at 1:47
  • Remember /oe should connect through a resistor, not directly
    – jkp
    Jan 26, 2021 at 6:16
  • I edited my post because my message was slightly too long Jan 27, 2021 at 8:20
  • If you could control the LEDs with the pi connected directly, I think that we can say that the code, the pi and the LEDs are working and that it is the setup around the buffer that is the problem. Could you maybe post a picture of your setup? Plase make sure it's sharp and that we can see all the wires on the breadboard
    – jkp
    Jan 27, 2021 at 12:08
  • I retried directly connecting the pi to the lights it did not work. I attached two images of the level-shifter circuit and one image of me directly connecting the pi to the LEDs. Let me know if the picture is too confusing as there are a lot of wires on the breadboard Jan 27, 2021 at 20:48
0

I was having an issue with getting GPIO18 to work as well. It turns out I had to disable sound.

Instructions were given at the top of an article shared by jkp in the comments.

https://learn.adafruit.com/neopixels-on-raspberry-pi/python-usage

Sound must be disabled to use GPIO18. This can be done in /boot/config.txt by changing dtparam=audio=on to dtparam=audio=off and reboot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.