If you ever need a simple, low-cost, 5V to 12V, up to 100 mA with an input of 120 or 240 VAC, 60 Hz, the Cap Drop Power Supply is the circuit for you. But be warned, it is not isolated from the AC power line and it can therefore, be dangerous with a shock and electrocution hazard. This is a popular circuit in many modern electronic devices these days for low-voltage DC power to run a small MCU circuit with a relay (or a Triac) for computerized control of AC circuits with very low cost, minimum parts count, as well as in smart power meters and LED strings. This this circuit cannot be used when a human can touch any part of the circuit. To be safe, the entire circuit must be insulated from human touch, including any pots or other controls. This circuit can be easily simulated using LTSPICE (or your favorite SPICE simulator) and it's inexpensive to build.
One good thing about this circuit is that it's minimally dissipative. Although it uses the voltage dividing principal to drop and regulate the DC output, the majority of it is done using lossless capacitive reactance and not dissipative resistance. I'll explain the circuit operation as follows. R1 functions to both limit the inrush current of C1 and limits damage if C1 ever shorted. C1 must be an X1 or X2 rated cap, which is made for putting across the AC line. C1 drops most of the AC voltage across it by it's reactance, which can be computed as: 1/(2*π*F*C) = 1/(2*π*60*470E-9) = 5.64 KΩ. C1 forms a voltage divider along with D1, the 5.6V Zener Diode. On the positive half-cycle of the AC line, D1-Cathode will be positive and peak at about 5.6V, this gets dropped by about 0.6V by D2, a 1N4007 Diode. For 120 VAC, a 1N4004 can be used, for a 240 VAC input, I recommend at least using a 1N4005. But 1N4007 (a 1,000 PIV, 1 amp Diode) is inexpensive and the extra voltage margin can hold up to power line spikes without damage. The AC Line current flows thru the cathode of D2 and gets smoothed by C2 and can supply the load up to 50 to 100 mA typically. This Cap Drop circuit is often followed by a DC-DC Converter or a 3-terminal regulator for a higher-quality output. If a linear post-regulator is to be used, be sure to increase the D1 Zener voltage so that the post regulator will have enough headroom to regulate and that's often a couple of volts. For example, an LM78L05 three-terminal, 5V, 0.1 Amp regulator needs a full 7V minimum to guarantee its 5V output. In that case, the Zener diode would need to be at least 7.6V and the closest standard Zener voltage above that is 8.2V. The 8.2V Zener voltage gets dropped by D2 for an output voltage of 7.6 VDC, which will work well with an LM78L05.
I must stress that this circuit can be hazardous to humans, particularly if the hot and neutral sides are reversed such that the hot side connects to the circuit GND node. In that case, anyone touching any part of this power supply's load with one hand, and chassis ground or earth ground with the other will have the full AC line voltage across their body and that can kill, particularly at 240 VAC input voltage.
So, when working with this circuit, be sure to use an isolation transformer for safety and when you're ready to button-up your project that uses this circuit, make sure there's no way a person can touch any part of the circuit. If a metal chassis is used, connect it to earth ground using the green, ground wire and do not use any external circuit controls that are exposed and can be touched with the chassis' cover on.
The exact value of R1 isn't critical, but it shouldn't be so high that significant power is dissipated in it under normal load conditions. It simply limits the inrush current into C1. The value of C1 and hence, the Xc reactance of C1 should be high enough that most of the voltage division from the 120V RMS AC line is dropped across C1. But it can't be so high that the desired load current cannot be realized. That is a simple calculation as follows: C1 Xc < 120*√2/(lneeded load current). For example, if 30 mA load current is needed, then the C1 reactance must be less than or equal to: Xc<120*√2/0.03 = 5.66KΩ. It needs to be less than the computed value as there's additional series resistance that further limits the load current. The values shown in the schematic below should support about 20-25 mA DC load. The value of C2 is primarily determined by the amount of acceptable ripple or droop requirement. Values in the 100uF to 1,000uF are typical. What I mean by droop is that the circuit only provides load current from the AC line on the positive half cycle. But on the negative half cycle, only the C2 cap is providing current to the load. Therefore, C2 can be computed as follows: C = i*dt/dV), where C is the capacitance value, dt is the time duration of the negative half cycle (8.33 mS for 60 Hz, and 10 mS for 50 Hz), dV is the ripple voltage, and i is the load current. If a ripple voltage of 500mV for a 25 mA DC load is desired, then C2 >= 25E-3 * 8.33E-3/0.5 = 416 uF.