NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.


January 26, 2012
by met_fredrik
met_fredrik's Avatar


I am currently doing a home automation project and for that I need a small power supply to drive my attiny85 from the mains. I have started building a capacitive one, but I get to much ripple and I am wondering if someone has some good advice!


This is the values I am using now. Will switching places between C1 and R1 have any effect? (I think it shouldn't as R1 will limit the current no matter what, but maybe it can interfere with C1's reactance?)

With this specs I get approx. 0.7@120Hz volts ripple on Vout on the oscilloscope at school. I tried putting another 470uF cap in parallel with C2 but it didn't change anything, so I am a bit confused. I am using a 4.3 zener at D1 in the lack of the right one.

Any help would be greatly appreciated! I am living in Norway and the mains are 240V@50Hz

(Will post pictures of the project when I get a little further!)

January 26, 2012
by sask55
sask55's Avatar


Am I missing something here?

This looks to be a very dangerous circuit to me. Since the neutral is tied to earth ground back at the service the entire thing is hot. Vout will be 240VRMS above earth ground and the circuit ground is only 5 volts below that. It looks to me like the entire circuit board will be caring paternally lethal voltage to earth ground. R1 limits the current back on the natural but there is nothing limiting current back to earth ground other then the line power circuit breaker or fuse. Personally I would not even consider this circuit as an option. Small transformer type power supplies are inexpensive and wildly available. There are no doubt ways to insolate the board from earth ground but why take the change?

January 26, 2012
by JimFrederickson
JimFrederickson's Avatar


I don't really have a problem with 'polarized power connections' IF we are dealing with low power.

That is not all that dangerous, and if you skipped the addition of an appropriate diode then you only run the risk of damaging your circuit.

For AC connections I am a HUGE FAN, whenever possible of making it 'safe'. (Even 'a non-polarized power connection' when possible.)

The circuit you have like the majority of tranformer-less power supplies, but not one I would advice using...

I think this link will provide much better detail as well as it's final design being a much better approach...

(I have included a link to the picture which I think will be displayed. Following that is the text associated it the circuit, finally if you want to read then entire, albiet short, article that is the last link.)


The last circuit shown is perhaps the most efficient among the above discussed. It is quite similar to the second circuit i.e. it is spike protected, but, the addition of

another capacitor C2 at the input terminal, makes it sure that the entry of the AC mains voltage into the circuit is sealed of and remains totally isolated. Therefore, this design may be considered as the ultimate transformerless power supply which is very cheap to build, satisfies most of the needs, is spike free and is safely isolated from AC mains.

Building these circuits does not need much of explanation as it's just a matter of procuring the shown components and fixing them correctly over a general purpose PCB,or the circuit may be simply built over the PCB of the electronic circuit itself which is being powered through this power supply.

January 27, 2012
by Rick_S
Rick_S's Avatar

I don't know if you've seen it or not, but there is a library project using a attiny85 to drive a triac directly from mains power. Here is the link in case you didn't see it. It seems his project could be similar to what you are trying to do.


January 27, 2012
by sask55
sask55's Avatar

Ok; these circuits look safer to me for two reasons. The original schematic had the Vout directly connected to the AC power line with absolutely no provision to limit voltage or current to earth ground in the event of an accidental short. As a result of the Vout tied to the line all of the voltage, regulation of the output was done by raising the effective voltage of the ground to just under the line voltage.

All of the other circuits including the one that Rick referenced take the opposite approach. They have at minimum, a resistor and a diode in series with the hot AC supply line. These components would somewhat limit the current available at Vout, and in fact may fail (burn out) in the event of a low resistance short to ground. Secondly and more relevant to safety most or all of the voltage AC voltage regulation is done by reducing the line side of the AC to near neutral voltage levels. This is the case in the switch circuit that Rick referenced from the Nerdkit library. The circuit GND is tied to neutral and the VCC is about 5 Voltes above that. It seams to me that this is a much better approach then VCC being tied to line voltage and the Ground being 5volts below the line.

Keeping in mind that it only takes a few milliamps to cause serious injury or death, with the relatively high Line voltage a person must be very careful. With these changes I can see uses for this kind of supply.

. Interesting thread


February 04, 2012
by met_fredrik
met_fredrik's Avatar

Hi! Sorry for my lack of presence, I have a lot do to at school. Thanks for all the answers!

@sask55, @JimFrederickson, It doesn't matter how dangerous it is as long as it's working. I will add a fuse, and the whole thing is going to be put inside a box with the uC. No human contact, which makes it pointless to add security don't you think? I am not mocking your concerns of security, just trying to strip unnecessary parts.

@Rick_S, yes I've seen it! He based his powersupply from the same document I pasted my circuit from! :)

Post a Reply

Please log in to post a reply.

Did you know that multiple MOSFETs can be used in parallel to switch bigger currents on and off? Learn more...