Story
No need for any SMPS or PSU, transformerless power supply can be used in low power projects such as data acquisition, ESP cameras and data sharing IoT platforms
Its capacitor is a critical part of the circuit's safety. It withstands continuous high AC voltages and if a short circuit occurs, the "5 V" output is at mains voltage and the parts may catch fire. This is the job of an X-rated capacitor. You'll see them mostly labeled X1 or X2, with X1 being able to withstand higher voltage spikes. Either will do, just make sure it's rated X and specified for your mains voltage level.
A transformerless power supply (TPS) is basically just a voltage divider that takes 115 or 220 VAC voltage from the wall and divides it into whatever voltage you want.
Typically, a DC voltage divider is made from a pair of resistors. Combined, they define the current flowing through the path, and the top resistor can then be selected to reduce the difference between the input voltage and the desired output.
After passing through the capacitor, the passing alternating current needs to be rectified into direct current. An ordinary half-wave or full-wave rectifier can be used here: a few diodes and a large value filter capacitor.
Finally, note that there are many possible configurations for this circuit. It is also possible to connect our device directly to the live wire, with the capacitor in the lower leg of the voltage divider, instead of reducing most of the voltage between the live wire and our device - the same circuit reversed.
Components required
105/104/474K capacity
1Mohm,100ohm/10k resistor
1N4007 Diodes
Preferred Zener diode (5v to 18v)
220uF/470uF electrolytic capacitor
Circuit description
AC power from the first connector is supplied to the capacitor and the diode with a resistance of 100 ohms. This 100 ohm resistor acts like a fuse for the circuit, preventing overvoltage and overcurrent problems. There is always a resistor in parallel with the capacitor so the circuit can be discharged when not in use. A full-bridge rectifier with electrolytic capacitors acts as a filter to provide the DC output. The function of the Zener diode in the circuit is to regulate the power and provide an appropriate and stable DC voltage to the circuit.