I am interested in the idea of creating a smart light switch which I can control remotely. I would connect the switch to a relay which is also connected to a microcontroller (either ATMEGA328 or ATTINY85). I would like to put these components behind the switch, inside the wall. And I would like to power the chip directly from the wall power (120 VAC, 60 HZ).
My plan was to power the microcontroller like this:
120 VAC from wall >> 9 VAC via transformer >> 9 VDC via rectifier >> 9 VDC smoothed via capacitor >> 5 VDC via 7805 voltage regulator >> VCC pin on microcontroller
120 VAC from wall >> 5 VDC via AC Adapter module >> VCC pin on microcontroller
My problem is that I can't find any transformer or AC adapter module that will work. They must be fairly common since they are present inside of every wall wart and virtually every other electronic device. These components should be cheap since an entire wall wart assembly is often under $5.
Does anyone know where I can find a small, cheap 120 VAC to 9 VAC transformer, or 120 VAC to 5 VDC adapter module?
The problem is that the wall warts (new tiny ones anyway) don't use a stepdown transformer, they use a flyback transformer and a switching power supply. There are some step down transformers out there that are small, but not as small as you want. I went through this exact set of steps a while back and took apart a number of wall warts to see how they were actually constructed.
I suggest that you take a look for a small switching power supply to power the device. There are some of those in the marketplace, but they are much harder to find than DC-DC supplies. If you do some serious searching, you can turn up a few of them.
The other method is to come up with a supply that uses the AC input and reduces it to the 5v you need. The problem with this is that they are inherently unsafe to work on when the power is applied. Also, if a component fails, the entire thing goes up in blue smoke. It can be done though since X10 has been doing it for decades.
Thanks. I hadn't thought of using a flyback transformer with a switching power supply.
I guess I don't really care what I use or what type it is, as long as it is cheap, small and converts 120 VAC to 9 VDC (or 5 VDC regulated). I am having a very hard time finding a module of any type that fits these criteria.
I would be like to use the exact same module that would come in any standard 120 VAC to 9 VDC 500mA wall wart. Does anyone know where I can find the same components that go in a standard AC/DC wall adapter?
You can cannibalize a cheap usb wall charger, I've found a bunch on Amazon for $1-2 a piece.