For one of my projects, I plan to have a custom PCB with an ESP32 (or something similar), in a wall box. I'm not entirely sure how I can power this, but I was thinking main's voltage since a line will be near where I want it to go. My question is, how do I get mains voltage to become 5v DC? Am I being stupid and is there a better more recommended way to power my circuit board? Can this even be up to code for inspections?
Last edited: