DIY Mains LED Panel

DIY Mains LED Panel

CAUTION! This project works with mains voltage! This can be lethal, so do not attempt unless you are familiar with the necessary safety precautions and understand the risk!

To help with taking higher quality pictures, I thought I should improve my lighting in my workspace so I decided to see how hard it would be to make some LED lights that get power from ordinary mains voltage.

I want to start with saying that I would not leave these plugged in or unsupervised as they lack many safety features. I put this together for use in taking photos, so they are only plugged in while supervised, and for that they serve their purpose just fine. If you are interested in putting together a light of your own that can be used for ordinary lighting, it would be best to implement some basic safety features, which we will go over later in this post.

Build Process and Design

The design for this circuit is quite simple, it is made up of a rectifier, a smoothing capacitor, and a load (the LEDs). To make things a bit better and safer, we add current limiting resistors to save our LEDs, an inrush current limitor to prevent blown breakers, and a capacitor discharging resistor to prevent any unexpected shocks after removing power from the device. Alright, so the general design is out of the way, how should you determine what values to use or how many LEDs you need? Let's start with the LEDs and what we know about basic white LEDs.

White LEDs have a voltage drop of 3-3.7 volts, generally take from 5-150mA, and produce about the equivalent of an ordinary light bulb with every 10 watts of power put in. So to get a decently bright light we want to make an array of LEDs that can handle 10 watts. How much current can the LEDs you use handle? Mine are rated for 150mA so I should use about 10/0.15= ~66 of them, but my board only fit 44, so I did that. It's more to see how well it would work anyways.

In addition to considering total number needed, you'll need to consider how you will arrange them. If you arrange them such that the voltage drop is near your source voltage (~170VDC for rectified 120VAC) your current limiting resistor will be held responsible for dropping a very small voltage, which means if the source voltage fluctuates, the current will fluctuate more. Take for example if your LEDs dropped 150 volts and your smoothing capacitor was able to limit ripple to about 3 volts, the voltage dropped by your current limiting resistor would fluctuate from 17-20 volts, this is considerable but not excessive. If your LEDs dropped 160 volts and your smoothing capacitor was the same, you would be dropping 7-10 volts, so you would have fluctuations of 30%, that is substantial. Because the load is primarily resistive, fluctuations in voltage across the resistor are proportional to fluctuation in current, which for an LED means fluctuation in brightness. More LEDs in series mean less power wasted in the resistor and less waste heat, but also means it will be more sensitive to ripple.

Alright, so we know a bit more about LEDs and the implications of how we decide to arrange them. What value should we use for the current limiting resistor? That depends. For the resistor, take a look at the datasheet for your LEDs, what current do you need through them and how much voltage is dropped by the array at that current? If you use 40 LEDs in series and need 100mA and they drop 3.5 volts each at 100mA then they will drop 40*3.5=140 volts. So we need our ~170VDC to be reduced to 100mA after dropping 140 volts on our lights, so we need to drop 170-140=30 volts across our resistor at 100mA. Time for a little math.

 Recall our formula V=IR 
 So we have 30=0.1*R
 R=30/0.1=300 Ohms

Not too bad, we've got most of our design done. Now we need to decide on a value for our capacitor. We first make sure it's voltage rating is good for at least 170VDC plus some room to accommodate brief surges, so say a minimum of 250 volts. Now what capacity to use? As much as I would like to be able to give you a formula for this, it is much easier to use a tool online alongside the information we gathered above.Come up with what ripple you are comfortable with personally, lets say 5% for the sake of simplicity (also the threshold for changes in brightness that can be perceived). If we go with our design with 40 LEDs, we have a voltage drop of 30 volts at our full 170VDC, and we want that to never drop beneath 30*0.95, that is 95% brightness. In order to do this, our smoothing capacitor needs to be able to prevent the voltage from dropping any more than 1.5 volts, to find out how to achieve this we will turn to an online tool. We have a starting voltage of 170VDC, a load of 100mA at that voltage, and a frequency of 120Hz when using a full bridge rectifier, so we need to be able to sustain a load of 100mA for 83 milliseconds. To get that current, I approximate our load as a 1700 Ohm resistor. But with these requirements, we would need a large 550μF capacitor, so you can either go with that or lower your current, number of LEDs, or increase your ripple tolerance.

See this example plugged in at Must Calculate it's a tool I have used for years now.
Now we have our components, just wire everything according the schematic and add your high value resistor across the capacitor terminals and the project is complete! To make mine a bit safer to handle, I designed and printed an enclosure and coated the exposed components in silicon modified conformal coating to prevent accidental shock. Happy building!

What components are needed:

  • LEDs, anywhere from ~30 up to 50 or so
  • Resistors, a couple in the 1kOhm range, and 1 in the 200kOhm range
  • Thermistor for inrush limiting (can use low value resistor ~10 ohm)
  • High voltage capacitor (I used a flash capacitor from a disposable camera)
  • 4 generic diodes or a full bridge rectifier, can use just 1 or 2 diodes as well
  • some wire
  • Perf board
  • Basic tools (iron, solder, wire cutter)
ESP8266 01 Light Dimmer

ESP8266 01 Light Dimmer

Note: Although I do have some useful things here, I never did get around to assembling a dimmer using the mini-version of this board. School came around and other hobbies took my interest away, but I plan to revisit this in the near future!
CAUTION! This project works with mains voltage! This can be lethal, so do not attempt unless you are familiar with the necessary safety precautions and understand the risk!

I purchased some of these little wifi enabled microcontrollers some time back, but until recently haven't known what to do with them. While working on my e-bike and spot welder, I had the thought of making the ebike controller wifi enabled. This got me started on making some test projects to learn with. The goal here is to use to cheapest variation of the esp8266 and still accomplish a reasonably complex task without needing to purchase I2C add on boards. Now, on to the details on how to do this project and what you'll need.

Parts for this project

  • A dimmable light and socket
  • Triac (I used a BTA08)
  • Driver IC (moc3023 or similar)
  • AC optocoupler or DC optocoupler with diodes (H11AA1 or generic)
  • (Optional) Breadboard and jumper wires
  • Appropriate tools (soldering iron, solder, wire cutter)
  • ESP8266 variant, we'll use the 8266 01 for its small size
  • FTDI serial adapter (if using the 8266 01 or an arduino pro mini)
  • AC-DC supply (may need a regulator depending on what you have available)
  • A variety of resistors

A neat trick for the tiny board

This little block of code here will be used to repurpose our TX and RX pins since GPIO 0 and 2 are required to stay high during boot. The problem with the pins being high at boot has to do with the fact that one is supposed to take an input from the zero cross detection circuit, and the other needs to use a high signal to trigger the lights, that way in case of an error with the board or the power supply, our lights or other load (like a motor) aren't stuck on.

//GPIO 1 (TX) swap the pin to a GPIO.
pinMode(1, FUNCTION_3); 
//GPIO 3 (RX) swap the pin to a GPIO.
pinMode(3, FUNCTION_3);

By doing this, we keep our design safer and only lose functionality which wouldn't be used here anyway. If your use case does require TX and RX functionality, it can be done, but may require additional boot attempts if it happen to boot at time of zero crossing, it will briefly pulse the output on at boot, and will be stuck on if it fails.