WS2812 level translator

WS2812 LEDs are one of my favourite toys. Apart from all the things that you can do with them in terms of lighting, displays or even light painting you can also use them for your projects as indicator lights.

The great advantage comes from the fact that you can use a single pin to drive so many of them and it takes just 3 wires ran across the whole box for practically any number. This in turn comes with the disadvantage of more complex control and problems driving them(5V devices) from a 3.3V microcontroller.

Although the data sheet states that you would need at least 3.5V for them to recognize as HIGH level(70% of 5V), many seem to have no problem being driven from a 3.3V micro. With the signal regeneration that each does, it is only a problem for the first one in the chain. But, as I found out, some LEDs simply don’t work as the first device, and to be safe it is best to use a level translator. Unless you completely forget about it and find yourself in need of driving a display with WS2812 which does not like 3.3V signals.


Luckily there is a simple solution with parts that you have available: just another WS2812 LED (or two) and a diode. The trick is to power the first LED in the chain from 5V via a diode dropping its supply to 4.3V*. At this level the 3.3V signal from the microcontroller is within specifications to be recognized as a high level. As each LED does signal regeneration the output of the first LED will be at a 4.3V level which is in specification for the next LED powered at 5V. If you need a longer cable between the microcontroler board and the LEDs, a second one may be included in on the board which will be supplied by 5V in turn regenerating the control levels to 5V.

 Below you can see the original 3.3V signal and the 4.3V signal after the first LED. Also notice there is stronger ringing on the 3.3V control signal due to longer wire from the microcontroller.3v3_to_4v3

And now the original 3.3V signal and the 5V signal after the second LED:3v3_to_5v

*Datasheet doesn’t specifically say what is the normal supply range for these LEDs, although many specs are provided for 4.5 to 5.5V supply. I found no problem with them at 4.3V in normal ambient conditions.

Heatsink Tester


It’s quite a common problem when building electronics that some components need cooling which is usually done through some sort of heatsink and optional fans. Choosing the right cooling solution can be a difficult task because the real life behavior of the system is hard to predict or model. In my case I have faced the simple question quite a few times: how much heat can a cooling system dissipate? The thermal resistance of a particular heatsink may vary quite a lot depending on the surroundings or it can simply be unknown to start with. The aluminum side wall of an enclosure made me build this thing.


This is why I have made this little device: a thermometer, a transistor and a microcontroller with a simple command line interface. I could have answered my questions in quite a lot of simpler ways, but since I made a simple thermometer not much else is needed to control the transistor when a DAC is available in the microcontroller.

The device works in a simple way: a specific power is dissipated on a transistor while a DS18s20 temperature sensor measures the temperature on the heatsink as close as possible to the transistor. The circuit uses a serial connection and is controlled via the terminal. A few preset values are available for the power to be dissipated.

The micro at the center of the project is an ATXMEGA32A4U and I am using a small board I designed for another project and another proto board which contains a current sensing resistor and a voltage divider to measure the supply. A TL431 is used as a 2.5V reference. The circuit uses two supplies, one for the micro which also contains a 3.3V LDO and one for the dissipating transistor. The schematic is shown below:


The reason for leaving the supplies separate was to be able to use a wide range of supplies for the dissipating transistor; the circuit is designed to measure up to 52V input. Such a supply is too high for a normal regulator for the micro. If the allowed maximum is lowered, a regulator can power the micro as well. In practice it turned out the low power levels (0.5 – 5W) are regulated better when a low voltage supply is used for the transistor (3V). For higher output power (5W to 50W) a 19V laptop power supply worked just fine. The limit simply comes from the ADC precision and the value of the current sensing resistor.

An IRL540 transistor is chosen as the dissipating element due to its low threshold value. This is necessary to allow driving from a 3.3V DAC, considering the voltage drop on the current sensing resistor as well. This was chosen as 0.1 ohm, which corresponds to about 0.25V of drop while dissipating 50W from a 19V supply.


Due to the high thermal inertia of the system, a very simple regulating method was chosen: if the dissipated power is too low, the DAC output is increased, otherwise it is decreased. This produces some oscillations around the set value, but if the power is averaged over one second a very stable value is obtained. The control loop runs a few hundred times a second, data averaging and display is controlled by the RTC.

The microcontroller calculates the thermal resistance of the heatsink assuming that the start of the experiment is at ambient temperature. The circuit needs to run until the temperature of the heatsink stabilizes to the new value. The time required depends on the system, but in practice I found 1h to be sufficient.

The software allows for very simple functions, but I found it to be sufficient: choose the power to be dissipated and start and stop the experiment. The software is available for personal use. Data is sent out through the serial port and can be viewed in a terminal, the supply voltage, current, calculated power, DAC set, temperature and calculated thermal resistance are sent out.

NOTE: there is no protection for the overheating of the transistor, since its temperature is not measured directly. It is up to the user to make sure the dissipated power is chosen appropriately for the heatsink size. When mounting the temperature sensor it is important to have it thermally coupled to the heatsink and insulated from the ambient. 

Experiment 1

A small heatsink is placed in a small box and 5W are dissipated. Other components are added around to mimic airflow restrictions. After half an hour the temperature stabilizes around 72°C indicating a thermal resistance close to 10K/W. This is pretty good, considering that the manufacturer rates it at 14K/W.




Experiment 2

This experiment is actually the real value I was interested into. The side of the enclosure is made of aluminum and it allows for transistors to be easily mounted. But neither the seller nor the producer were able to say anything about the dissipating capabilities.  By dissipating 20W the final temperature reaches 52°C which indicates about 1.3K/W thermal resistance. In practice such a high temperature is uncomfortable to the touch but does not burn, so a circuit should dissipate lower, depending on the application. Plotting the data gives out a nice curve with the temperature variation. The output log is available here. 




Future work

The whole thing is build as fast as possible using a PCB I already had. A next iteration would include a dedicated PCB, with its own LCD and with a nice PC application. A case would also improve the project.

LED logger V2


The experiment is stopped. The Logger has malfunctioned and is in a location that I cannot access. I will fix it and resume as soon as possible.


I’ve previously wanted to know how much do cheap led strips last: turned out they don’t even pay for themselves over incandescent bulbs. I’ve decided to extend the experiment to more kinds of strips and address some concerns about the experiment expressed by the readers.

 LED logger V 2

In short:  8 channels, internet connected for live data visible by anyone. The experiment is trying to measure the light intensity variation over time, while maintaining the environment conditions constant.

Power supply: all strips are designed by their manufacturer to be powered from 12V. A 12V stabilized supply is used to power everything. In the first experiment I have periodically checked the voltage across the strip and found it to be constant. Now, the voltage is measured and plotted.

Temperature: all the strips together will dissipate around 2-3W and are placed on a big aluminum plate which is the box front panel. With what I have so far (4 working nonstop) the temperature of the panel raises 6 degrees C above ambient. The whole box is placed in a well-ventilated area inside the house, with an ambient temperature around 25 deg C, with small variations throughout the year. Therefore the strips are well cooled and operate in a rather constant temperature.

Sensor degradation: in order to verify that the sensor is still reporting correctly I have installed a strip that will only be lit for a short time at each measurement to check that the sensor has not changed. By measuring a strip identical to the first I have found that the sensor produces identical results, so there is no degradation over the 1400 hour time first experiment.

Current Data:

Here’s how the current data looks like: . For more information about the strips, see below.

NOTE: At the moment the software has 2 bugs: It sometimes stops updating, although the LEDs remain on. So the values for the LEDs are correct, but may be old; i’ll periodically reset the device to ensure fresh data is available. Also, the PSU voltage seems to have measurement errors at the first readout(I’ve checked with a voltmeter, there’s no fluctuation in the PSU). So, out of order values for PSU voltage should be ignored.

Meet the candidates

The control strip is identical to the strip used in the first experiment, except that is has not been used. It turns out that it produces the exact same readout as the first strip, meaning that the sensor has not been degraded over the 1400 hours of initial test. The control strip and the original strip are the best aligned to the sensor.

Strip 1 is the strip used in the first led logger. It starts with a 1400 hour usage.

Strip 2 is made by Optoflash, it’s similar to the others except that the light is cold white. It’s a bit more expensive, comes from TME and there are no details about lifetime in the datasheet, but at least there is some sort of datasheet.

Strip 3 is an Ikea ledberg strip. It’s rated at 20.000 hours, but without any info as to how this time is measured.

Strip 4 is actually a waterproof module from a local shop that I paid about 1 EUR for. I don’t know anything more.

Strips 5 to 7 will be determined and added later.

The logger

Its PCB is developed from that of the ego box, replacing the 7 segment drivers with 8 channel high power drivers. Everything is based on web client and someone has already done the task of making it work with Cosm (ex Pachube).

Schematic is quite trivial, you have your micro, your Ethernet chip and some MOS transistors to drive and control the LED strips.

Everything is built around the same box used in the previous project. The three wires in the middle are for three extra channels.

The data

The intensity of each channel is measured every hour by turing all channels OFF and then measuring each intensity. After that, all the strips except the control turn back on. Data is uploaded to Cosm and can be found here

Now it only needs time to add data points and check how these strips compare.