Rasperry
Posts: 22
Joined: Sun Jan 26, 2020 5:25 pm

Adressable RGB connected to GPIO pins on RPI4

Mon Mar 02, 2020 1:43 pm

I would like to connect adressable RGB LED strip (with 9 LEDs) to GPIO pins on RPI4 and am asking if this is even possible - is there enough power output from GPIO pins to power the LEDs?
Adressable rgb pins on the connector are: 5V, Digital, Empty (without pin) and Ground - so this should be OK?
Is there software already available to control A-RGB LEDs?

I would probably need these wires to connect everything
https://www.amazon.com/GenBasic-Female- ... 6b802f6e31
?

I cant find a topic with similar question so any help would be appreciated, thank you in advance.

scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: Adressable RGB connected to GPIO pins on RPI4

Mon Mar 02, 2020 3:28 pm

Depends on the type of LEDs.
Do you have a link to the type that you want to use?

Might be ok with a small number of low powered LEDs otherwise you'll need a seperate power supply
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

PhatFil
Posts: 1665
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Adressable RGB connected to GPIO pins on RPI4

Mon Mar 02, 2020 3:38 pm

look up the data sheet for your leds to check how much power they can draw, iirc each ws2812 led has 3 x 20 ma leds 1 x red 1 x blue and 1 x green so if similar your strip of 9x could draw upto 9 x 60ma at full power 540ma which should be ok for, you to draw from the +5v gpio header, and in my limited experience with similar leds they will respond to a 3.3v logic level without any problems so ...

Yes it should be ok,,

Rasperry
Posts: 22
Joined: Sun Jan 26, 2020 5:25 pm

Re: Adressable RGB connected to GPIO pins on RPI4

Tue Mar 03, 2020 7:34 am

The whole LED strip consumes 1,2 W (0,24A) and has this type of connector - left one on the picture from the link below:

https://i.imgur.com/PKSNRAl.jpg

LED type: WS2812B 5050

+5V /Digital /Empty/ Ground


I also use this transformator to convert 12 V to 5 V to power the 4x Raspberrys, so one way to power the LED strip would also be directly through this.
https://www.amazon.de/dp/B019GX3YP4/ref ... ers&sr=1-8

But still, i would (probably?) need to connect Digital and Ground pin with the Raspberry GPIO?

Also, is there maybe already some software to control the different ways of blinking of adressable RGBs for the Rasbian, that you would recommend?

Thank you for all the answers!

User avatar
joan
Posts: 14876
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Adressable RGB connected to GPIO pins on RPI4

Tue Mar 03, 2020 8:33 am

The APA102 based LED strips are much easier to drive from the Pi. You have very few choices with a WS28xx based strip.

Rasperry
Posts: 22
Joined: Sun Jan 26, 2020 5:25 pm

Re: Adressable RGB connected to GPIO pins on RPI4

Tue Mar 03, 2020 8:47 am

joan wrote:
Tue Mar 03, 2020 8:33 am
The APA102 based LED strips are much easier to drive from the Pi. You have very few choices with a WS28xx based strip.

Why easier?

Also, i can probably connect all three cables (these https://www.conrad.si/prikljucni-kabel- ... -rb-cb3-50) directly from GPIO to the LED strip connector without other accessories, and it should work (with 1.2 W draw from led strip)?

User avatar
joan
Posts: 14876
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Adressable RGB connected to GPIO pins on RPI4

Tue Mar 03, 2020 8:52 am

The WS28xx based strips have very tight timing constraints and are self-clocking. They need transitions in the microsecond range. The only way to achieve this on the Pi is with specialised use of one of the hardware peripherals which limits you to one or two pins on the expansion header and to dedicated software.

Rasperry
Posts: 22
Joined: Sun Jan 26, 2020 5:25 pm

Re: Adressable RGB connected to GPIO pins on RPI4

Tue Mar 03, 2020 9:30 am

Hm ... but this is a must to use those LEDs in my case (WS2812B ... 1.2W power usage at max.).


So it wouldnt work if i would connect it like this:

5V pin from LED strip to the GPIO 5V pin (PIN 2)
Digital pin from LED strip to the GPIO 14 (TXD) pin (PIN 8)
Ground pin from LED strip to the GPIO Ground pin (PIN 6)

??

Image
Image



If i understand you correctly i would need some additional hardware beside the wires to connect it?

User avatar
rpdom
Posts: 16967
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Adressable RGB connected to GPIO pins on RPI4

Tue Mar 03, 2020 10:27 am

The 5V from the Pi may not be enough (I'm running WS2812B LED strips from Pi zeros without problems. Up to 60 LEDs, but not all on at the same time).
I'd recommend using a biggish 5V PSU and taking the 5V to the Pi and to the LEDs on separate wires. The 0V should be commoned, of course.

There are two common drivers for those LEDs. One uses PWM which will disable a channel of the audio jack and can be a bit unreliable. The other uses SPI, which seems to work well.

I've previously used the PWM driver but am now looking at some code for SPI (which needs a bit of work as the example I found isn't quite right for the WS2812Bs that I've got)

You do need to use specific pins on the GPIO header for each of the drivers.
Unreadable squiggle

Rasperry
Posts: 22
Joined: Sun Jan 26, 2020 5:25 pm

Re: Adressable RGB connected to GPIO pins on RPI4

Tue Mar 03, 2020 11:05 am

But i have a really short LED strip that needs to be connected (about 10 cm) and i got information that it consumes max. 1.2W - so i think this should be enough to power directly from the Raspberry? Or at least worth trying?


If it wont be enough i can still use the 2. option from the picture below.
But i would like to connect everything as simple as possible, so everything connected to one of the four RPI in the the cluster i think would be the best option (to connect directly - option 1.):



Please also check, if the wires are in both cases connected OK, see picture below:

Image

12 to 5v transformator from the picture:
https://www.amazon.de/dp/B019GX3YP4/ref ... ers&sr=1-8

User avatar
rpdom
Posts: 16967
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Adressable RGB connected to GPIO pins on RPI4

Tue Mar 03, 2020 11:50 am

Option 1:
The 5V wire is correct.
The 0V/GND wire is correct.

A 10cm strip should be fine powered this way.

Option 2:
You will also need to connect the 0V/GND wire to the Pi.

The data wire is probably not correct. It depends on which driver you are using.
The SPI driver will probably use GPIO 10 (pin 19).
The PWM driver will probably use GPIO 12 (pin 32) or GPIO 18 (pin 12).

What software are you going to use to control the LEDs?
Unreadable squiggle

Rasperry
Posts: 22
Joined: Sun Jan 26, 2020 5:25 pm

Re: Adressable RGB connected to GPIO pins on RPI4

Tue Mar 03, 2020 12:51 pm

rpdom wrote:
Tue Mar 03, 2020 11:50 am

Option 2:
You will also need to connect the 0V/GND wire to the Pi.

You mean to connect wire from PI to the ground of the converter or from PI to the ground of the LED strip?
Sorry for asking n00b questions.


I intended to try software from tutorial here:
https://core-electronics.com.au/tutoria ... guide.html


Ok, so i will first try option 1 tomorrow and report back to you if it will work :)

Thank you again for help!

Rasperry
Posts: 22
Joined: Sun Jan 26, 2020 5:25 pm

Re: Adressable RGB connected to GPIO pins on RPI4

Tue Mar 03, 2020 12:54 pm

In the tutorial above he also connected with 3.3 V pin on Raspberry and he also used Logic level converter - but i am not sure why?

He says:
"The Raspberry Pi uses 3.3V Logic, So we will need to use a Logic Level Converter to convert it to the 5V logic that WS2812/Neopixels require. "

But doesnt he power LED with separate 5V adapter?

User avatar
rpdom
Posts: 16967
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Adressable RGB connected to GPIO pins on RPI4

Tue Mar 03, 2020 12:57 pm

Rasperry wrote:
Tue Mar 03, 2020 12:51 pm
You mean to connect wire from PI to the ground of the converter or from PI to the ground of the LED strip?
Both. The Ground wire must be connected to the ground of the converter, the ground of the LED strip and the ground of the Pi (unless there is already a ground from the converter to the Pi).
I intended to try software from tutorial here:
https://core-electronics.com.au/tutoria ... guide.html
That looks like it is a version of the PWM driver. It may well work fine. Note that the Data wire is connected to Pin 12 (GPIO 18).
Unreadable squiggle

Rasperry
Posts: 22
Joined: Sun Jan 26, 2020 5:25 pm

Re: Adressable RGB connected to GPIO pins on RPI4

Tue Mar 03, 2020 1:47 pm

OK, understood .. will get back when i test.

PhatFil
Posts: 1665
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Adressable RGB connected to GPIO pins on RPI4

Tue Mar 03, 2020 2:18 pm

having used ws2812 leds with 3.3v logic level control for lengths of 5m (300x leds) i would suggest trying your circuits and test code without a logic level converter to begin with as it may be totally unnecessary.

Rasperry
Posts: 22
Joined: Sun Jan 26, 2020 5:25 pm

Re: Adressable RGB connected to GPIO pins on RPI4

Tue Mar 10, 2020 1:43 pm

Everything worked no problem - thanks again! :)

Return to “Other projects”