Friday, November 14, 2025

Led filament, a first look

For an index to all my stories click this text

This story is about the rigid led filament. There is also a flexible version which will be discussed in an upcoming story.

I saw on the internet something that looks like a small led strip. They have several names: Led Filament, Cob Led Filament and Edison bulb led parts.


They are meant as ledstrips for use inside filament-lamps like the one above. The yellow strips in the lamp is what I am talking about. They can be bought as tiny led strips.

These are actually really small led strips inside a tubing and have contacts at both sides.


The photo just shows the size of this filament compared to a normal led.
This clearly shows they are slim and long.


The filaments are available in several lengths. I have seen lengths up to 68mm (about 7cm)
For testing purposes I bought a batch of 3.8 cm. Well The advertisement said they were 3.8cm long. And that is correct. However that is inclusive the contacts.


The led filament itself is about 3cm.


And they can be bought in several colors. At the moment of this writing the following colors are available: white, warm white, red, pink, purple, green and blue. They are not like neo-pixels or ordinary led strips. Each strip has only 1 color.

If you are going to buy them just make sure you buy the right ones for your purpose as they are available in 3V and 12V and even higher voltage versions. For our purposes we will be working with the 3V versions. As that is the voltage most of our microcontrollers work with.

Fragile

The tubing that encapsulates the leds feels like plastic. It is not flexible but rigid. The tubing can handle some stress but be aware that it is fragile.


As i wanted to know if it was flexible I bend one of the filaments (a bit) and it broke immediately. So be careful when working with these.
Despite being broken it still worked, what amazed me. Only the leds after where the break was, were working as the picture shows.

VCC and GND

Like stated these are led strips. So they need power. And just like normal leds the power needs to be supplied at the right contacts.


Carefully look at the picture.
At the right side there is a small hole in the contact. That is the VCC side. The other side is GND.
Switching the VCC and GND contacts does not do any harm (yes I tried it) as they are leds. But they just do not work when the power is not connected right.

Current delimiting resistor.

As with all leds these need a current delimiting resistor. More on that later.

Power

On our favorite Chinese website there are several suppliers of these filaments. So I scrolled through a lot of them to find some good specifications.


Most of them stated that the maximum current that could be supplied was 100ma at 3V.

The problem is that no microcontroller that I own can supply that much power from it's IO pins. The Raspberry Pi Pico for example can supply 4ma per IO pin and a maximum of 50ma on all IO pins combined. So the current needed for this filament would fry it. The ESP32 can roll out 40ma maximum at a single IO pin but the total (maximum sum of all IO pins) it can supply is 120Ma. Next to that a prolonged delivery of 40ma on a single pin will overheat and damage the chip. Therefore powering the led filament from a microcontroller is no option.

So I am going to supply the power from a 5V USB phone adapter.
That is 5V so we need to reduce that to 3V. The easiest way to do that is by using a resistor.

To calculate what value the resistor should have we need the following formula.

voltage supplied - voltage desired
-------------------------------------------------------
                  milliamps


The voltage supplied = 5V
The voltage desired  = 3V
The milliamps we need is 50 ma

As you can see I am not powering the strip to the maximum 100Ma.
This gives the following formula:

5V - 3V
----------
50 ma


And 50ma is 0.050 Amps
So that gives 2V / 0,050A is 40 and that makes the value of the resistor 40 Ohm.

So the minimal resistor value is 40 Ohm
Any higher value will do.

Supplying the power.

It is obvious that our ESP8266, ESP32 or Raspberry Pi Pico can never supply such power. So we need an external component for that: a transistor.

The most common used transistor for supplying power is the BC547. This transistor can supply a maximum of 100ma. So we could attach a maximum of 2 led filament strips to 1 of these BC547's. The BC547 is dead cheap. You can get about 50 pieces for 1 USD if you shop around.

If you need more current then use the 2N2222. This transistor is pin compatible with the BC547 but capable of delivering 800ma. Beware that this is under ideal conditions. It would need cooling to achieve that much current. So aim for a lower current like 200-400ma maximum.

I opted for the 2N2222

In real life.

In real life I did some experiments and found that a 100ohm resistor already supplied so much current that the ledstrip was very bright and could even be seen in broad daylight.

Let me do the recalculations for you.

5V - 3V
----------
 X ma


This should equal 100 Ohm

So 5-3 / X ma = 100 this gives 2 / 100 = 0.02A = 20 Ma.

Using a 2N2222 transistor I should be able to attach easily 10 led filaments (10 x 20ma - 200ma) to 1 IO pin of the microcontroller.

There is one extra calculation and that is the calculation for the resistor that needs to be attached to the base of the 2N2222 and that defines how much the output will be. I will not bother you with these calculations. But if you mail me I will show these to you in a separate story on this weblog.

The combined calculations.

I will not bother you with the calculations for the base resistor (until you mail me and ask for it).  I needed a resistor of 1.5K to 2K for the base of the transistor and for each led filament a resistor of 100 ohm.

2N2222

The 2N2222 has 3 connections E, B and C which are emitter, base and collector.


The Base is connected to a 1.5K resistor and that determines (the gain) the amount of current that will flow from the Emitter (GND) to the Collector. Any load (like our led filament) gets connected to the collector.
So the GND of the led filament is connected to the collector using the current delimiting resistor of 100Ohm.
The Emitter is connected to GND.

I made a test setup first without using a Microcontroller.

Breadboard for the first test.

Here is the breadboard for the first test.


The setup is the same as discussed above.
A resistor of 1.5K is attached to the base of the 2N2222. It is connected to a pushbutton that is connected to VCC. When the pushbutton is pressed some current will flow to the base of the transistor.
The Emitter is just connected to GND.
The Collector is connected through a 100 Ohm current delimiting resistor and from that to GND of the led filament. The VCC of the filament is connected to VCC.
The project is powered by a USB wall adapter, the kind used for phones.

When you push the button, the led filament will light up.
If the filament does not light up, check your connections. Most likely the VCC and GND of the filament have been swapped. Remember that the side where there is a whole in the connection is the VCC side.

That is all.

Attaching a Microcontroller.

The resistor connected to the base of the transistor is calculated at a value that accepts 3.3V from a microcontroller. We can use any microcontroller we like: ESP8266, ESP32 or Raspberry Pi Pico.

For our example we will be using the Raspberry Pi Pico.
The only thing we need to do for our first test is to attach a GPIO pin to the base resistor.
And of course connect the GND of the Pico to the rest of the project.

The Pico will get powered from our computer so:
DO NOT CONNECT THE VCC FROM THE USB POWER ADAPTER TO THE PICO'S POWER RAIL.
CONNECTING BOTH THE PICO WITH THE COMPUTER AND THE EXTRA USB POWER ADAPTER WILL BLAST YOUR PICO AND YOUR COMPUTER TO KINGDOM COME.



The first test program.

This is a small test program that puts the pin GPIO16 at HIGH, waits a second and then puts the pin LOW. The ledstrip will go on for a second, then off for a second and that sequence repeats.

# -------------------------------------------
# simple test for setting filament on and off
# -------------------------------------------

from machine import Pin
import time

filament = Pin(16, Pin.OUT)

while True:
    filament.value(1)
    time.sleep(1)
    filament.value(0)
    time.sleep(1)

Make sure this works before trying the next step.

Dimming the led filament

Now let's see if we can dim the filament with our program.
We can fake the voltage output of a GPIO pin by using PWM.

If you are not aware on how this works I can recommend my books on the Raspberry Pi Pico with MicroPython which you can find at the bottom of this story.

Here is the program that sends a PWM signal to GPIO16.
The led filament is off at first and then slowly gets brighter. When the maximum brightness has been reached it slowly dims till its off again and then the sequence repeats.

# -------------------------------------
# test program for dimming led filament
# with PWM
# -------------------------------------

import machine
import time

filament = machine.PWM(machine.Pin(16))
filament.freq(1000)

while True:
    min = 0
    max = 65536
    for i in range(min,max):
        filament.duty_u16(i)
        time.sleep(.00015)
    time.sleep(1)
    for i in range(max,min,-1):
        filament.duty_u16(i)
        time.sleep(.00015)
    time.sleep(1)

You can adjust the minimum value and the time between steps to your own liking.

Now everything works as expected we can start some real projects with this led filament.

So have fun,
Till next time

Luc Volders