Friday, December 16, 2022

0000 0000 1011 0100

A mosfet and a string of LEDs

I have previously confessed that I did not manage organise my Christmas lights in time this year. Following Mr PileOfStuff's example I should have grabbed an ESPixelStick, downloaded software, hooked it all up to my lights and network, and then kicked back with some eggnog (whatever that is) and enjoyed the festive season.

But no - my extreme laziness and disorganisation sees me instead just grabbing an ESP8266 (ESP-01 version) from the buckets, loading up the old (but stable) V3.2 ESPixelStick software, and then hooking up the WS2811 lights and adding power. The result? Fizzing and spluttering nonsense!

After a fair bit of head scratching and reading I came to the realisation that the 3.3V data signal coming out of the ESP8266 was not talking to the 5V tolerant WS2811 chip. The voltage mismatch had resulted in illogical confusion. Thus began a bit of a deep dive into voltage level shifting.

Thus, following on from last week's blog and video about voltage level shifting for data lines, I did some more experimentation with various chips, modules and circuits and eventually settled on a very common solution as shown in the following diagram. Low voltage (LV) is 3.3V and High Voltage (HV) is 5V in my case. I will only need one way data transmission across this level shifter, but it does in fact work both ways.

There are a lot of mosfet transistors that would admirably perform the switching, I settled on the BS170 as per the diagram - I have a few and it seemed most likely to easily meet the 800(k)Hz data switching speed required of the circuit. In fact it can switch well into the MHz range.

The commercial version is almost always based on a BSS138 mosfet, and as well I tried the 2N7000 with success.

I also upgraded the ESP-01 from 1Mb to 4Mb as has been done before, solely to try and squeeze the new version of the ESPixelStick software onto the device.

I successfully tested the hardware and software with the level shifter doing the translation, and also tried different software (WLED). Despite my initial bumblings, it seems that Christmas will be well served by festive lights after all!



No comments:

Post a Comment