I've been struggling with this for a while : am looking for a way to power an ESP32 microcontroller (at 3.3V, or 2.6-3.6V) from a 220V line.

I am trying to do this using only my home'e electrical wires (no plug, so can't use a USB charger).

The question I'm looking an answer for could be reformulante to : What composent is used in USB chargers to produce a 5 or 3.3V signal from 110 or 220 V line at home ?

Apologies if this is a duplicate, I've tried googling and reasearching on this site but keep coming up with irrelevant subjects. Ideally, I'd find a ready made (black box type) component I can buy. It is important this composent be very small.

  • 4
    \$\begingroup\$ Just use a wall wart? You don't want to be messing with mains power if you don't have a very good idea of what you're doing, that stuff's deadly. \$\endgroup\$
    – Hearth
    Aug 27 '19 at 20:28
  • 2
    \$\begingroup\$ "... can't use a USB charger ..." and then you want to know what components are in one so you can make one! You won't build one as cheaply, small and, in most cases, as safe as one you can purchase. Vote to close as "too broad". \$\endgroup\$
    – Transistor
    Aug 27 '19 at 20:33
  • 1
    \$\begingroup\$ What problem are you really trying to solve? This sounds like an XY Problem. \$\endgroup\$
    – TimWescott
    Aug 27 '19 at 20:38
  • 1
    \$\begingroup\$ The "component" used in a USB charger is really several components - a Switch Mode Power Supply (SMPS). As @Transistor says, you can't make one as small, cheap, and safe, as buying a ready-made one. \$\endgroup\$ Aug 27 '19 at 20:43
  • 3
    \$\begingroup\$ Suggest we leave this question here as a signpost to the discussion on transformerless power supply (and why it is such a hazardous, dangerous approach): electronics.stackexchange.com/questions/359107/… \$\endgroup\$
    – MarkU
    Aug 27 '19 at 21:09

A typical USB charger will use a reduced-size version of a switch-mode power supply (SMPS). This kind of power supply has an isolated, low-voltage output called a SELV, or Safety Extra Low Voltage. Supplies of this type are 'touch-safe', meaning their isolation and low voltage means that contact with the secondary poses almost no hazard (leakage is below 3mA.)

Wall-wart DC supplies are also SELV type. These can be SMPS or traditional step-down transformer type.

As to "what's inside", an off-the-line SMPS is a collection of components. The main ones are the input bridge to make DC, a switching controller, a flyback pulse transformer, and an output circuit. The transformer is key to making it safe to use, as it provides isolation for the secondary.

Pre-made modules that accept 110/220V on wires and make 3.3V output are available and common, which meet SELV isolation limits.

But I recommend another approach. Use a step-down transformer (12 ~ 24VAC) to supply a pig-tailed AC-DC 5V regulator. This kind of low voltage AC wiring is popular for controls like thermostats, doorbells, sprinkler valves, patio lights, etc., so it's cheap and easy to find. It's popular for home automation stuff.

Why do it this way? You avoid the issue of running 220V to your system. This will be safer to work with than using straight off-the-line to your power supply board.

This kind of 12 ~ 24V AC transformer is a common item called a 'bell transformer'. There are even versions that mount directly onto a junction box in place of a cover plate, so it does double duty of covering over the primary voltage wiring, and providing the safe, low-voltage secondary for your use.

  • \$\begingroup\$ Thank you! SELV type SMPS modules are exactly the answer I was looking for! Not sure why others gave me irrelevant answers or marked this as off topic (if you don’t know the name of what you’re looking for where else would you ask ?) \$\endgroup\$
    – kmn
    Aug 28 '19 at 12:20

Some USB chargers uses a transformer, rectifier (4 diodes) and and LDO (or DC to DC converter). Doubly insulated power supplies might only use a rectifier and a switched power supply. The problem is several of these components use high voltage and need to be built to regulatory standards or they are likely violate local fire code. It would also be much more costly to buy the components separately and try and build your own power supply.

It would be less difficult to add a receptacle for a power supply and use a regular off the shelf power supply.

  • 2
    \$\begingroup\$ "Some USB chargers uses a transformer, rectifier (4 diodes) and and LDO" - I'm highly sceptical of that. Can you show an example of an actual USB charger that has a linear power supply? \$\endgroup\$
    – marcelm
    Aug 27 '19 at 21:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.