How to power MCU inside standard 120v AC device box? - Page 1
Forum section: electronics / projects

author: marcusone
author_rank: Contributor
timestamp: April 10, 2016, 08:56:32 pm
content: I'm trying to find the best way to put an MCU (so 3.3v or 5v powered device) inside of a 120v box so that the MCU is always powered on, and it can do "stuff" (control relay, etc), but also have a switch/power/light attached to the 120v AC.Ideally I want it to fit inside a 2 gang box (or 1 if i can, but likely I can't build that small of a device) with transformer for 3-5v DC.... see attached example of box.Ideally the one side of the box would have the transformer, relay(or whatever), and the MCU, and on the other side I can have the 120v AC device.Anyone have something like this? Can suggest small transformers that would be easy to put on through whole board with MCU?Thanks!

author: Wilksey
author_rank: Super Contributor
timestamp: April 10, 2016, 11:27:40 pm
content: If you want to go away from a transformer, you can use a capacitive dropper with perhaps a Zener, as per BigCliveDotCom videos on YT, I've seen something similar but with PoE rather than mains voltage, but that would require some re-wiring!

author: radar_macgyver
author_rank: Frequent Contributor
timestamp: April 10, 2016, 11:44:48 pm
content: Grab an AC/DC isolated power supply from ebay. They're not all created equal, it's important to look for decent build quality. I usually look for:Capacitors rated to 105 CCommon-mode choke on inputPTC thermistor in series with input to limit inrush, and act as a fuse when things go wrongSolder masked FR-4 circuit board (instead of paper phenolic)Here'sa good unit that is identical to a bunch I bought. They all work flawlessly in my applications. Others are available too, with other output voltages and currents.

author: uncle_bob
author_rank: Unknown
timestamp: April 11, 2016, 12:36:50 am
content: HiOne caution:If the box will be directly wired into the main house wiring, there are rules about what you can and can not do. Check them out if that is what you plan to do.Bob

author: marcusone
author_rank: Contributor
timestamp: April 11, 2016, 12:45:14 am
content: Quote from: radar_macgyver on April 10, 2016, 11:44:48 pmThanks... what about these?http://www.digikey.ca/scripts/DkSearch/dksus.dll?Detail&itemSeq=194209848&uq=635959140431979194

author: radar_macgyver
author_rank: Frequent Contributor
timestamp: April 11, 2016, 02:20:16 am
content: Quote from: uncle_bob on April 11, 2016, 12:36:50 amAgreed. In general, no mixing of low- and high-voltage. If the low-voltage device has any user-accessible parts (controls, connectors, etc), then they need to be isolated in another enclosure.Quote from: marcusone on April 11, 2016, 12:45:14 amSorry - the link doesn't work for me (just takes me to the category list). Could you post the DK part number?

author: ajb
author_rank: Super Contributor
timestamp: April 11, 2016, 02:49:31 am
content: Quote from: Wilksey on April 10, 2016, 11:27:40 pmA crucial caveat is that this method makes the MCU mains-referenced, which is fine if it's only controlling a mains load, but presents a problem if you need to interface with any other circuitry or with a human being. The former will require isolating any signal wiring (including any connections for programming/debugging!), while the latter will require careful mechanical design so that the user can, for instance, press buttons without risking a shock.

author: amyk
author_rank: Super Contributor
timestamp: April 11, 2016, 09:30:06 am
content: We need to hear more about what the MCU will be doing to give any specific answers, but a capacitive dropper is the standard solution for this application. I'm assuming it's wireless-related, in which case there is inherently isolation. Otherwise, an optocoupler will work.

author: Wilksey
author_rank: Super Contributor
timestamp: April 11, 2016, 09:58:24 am
content: Yeah, I'm not suggesting the OP should use a Capacitive Dropper, just saying he could if he wanted to go away from a transformer due to size etc.I used some pretty small trannys from Vigortronix in the past, might be worth looking at?http://www.vigortronix.com/ACDCConverters.aspx

author: tszaboo
author_rank: Super Contributor
timestamp: April 11, 2016, 10:02:02 am
content: I would say, none of the above. Get a Murata or Tracopower or Meanwell board mounted AC-DC switching supply. Place a stepdown DC-DC after it if the output voltage is too high.Dont buy chinese mains powered stuff from ebay.

author: Warhawk
author_rank: Frequent Contributor
timestamp: April 11, 2016, 10:47:07 am
content: Quote from: marcusone on April 10, 2016, 08:56:32 pmMaybe you can get inspiration from here:http://ww1.microchip.com/downloads/en/AppNotes/00954A.pdfhttp://ww1.microchip.com/downloads/en/AppNotes/00236a.pdfhttp://ww1.microchip.com/downloads/en/AppNotes/91094A.pdfetc.Good luck !

author: marcusone
author_rank: Contributor
timestamp: April 11, 2016, 11:36:17 am
content: Thanks for all the great feedback/comments.digikey code: 945-2212-ND is what I found that I think will work.The MCU will indeed have some kind of wireless link and control a relay, and possibly send amp and temp, motion, etc data; depends on how much space and where the module is (i plan to have several in different switch/plug locations for different monitoring needs).

author: uncle_bob
author_rank: Unknown
timestamp: April 11, 2016, 11:49:15 am
content: Quote from: marcusone on April 11, 2016, 11:36:17 amHiIn addition to the isolation rules mentioned by others, if you use that sort of box for direct mains connection, there are a number of other rules you need to look into. What you are doing is *not* what the box was designed for. Some of the rules will not make a lot of sense in your context. The gotcha is that the local code inspector (and the fire insurance people !!) *will* apply those rules.One way out of the silliness (in the US) ... plug it in with a normal cord. Fuse the cord. At that point the rules all change. Yes it's crazy. It's the same stupid box. It's the same voltages. Rules are rules ....Bob

author: Wilksey
author_rank: Super Contributor
timestamp: April 11, 2016, 08:34:47 pm
content: That digikey P/N is a 12V 4W converter, not 5 or 3.3V?The problem with transformers is size, which is why a lot of people want smaller solutions, of course, if you can fit a isolated tranny in the box then you should!

author: marcusone
author_rank: Contributor
timestamp: April 11, 2016, 10:40:02 pm
content: Quote from: Wilksey on April 11, 2016, 08:34:47 pmI know its a 12v (I have other ideas that may require the 12v, and I can simply use a voltage regulator to step it down for the MCU); there are 5 and 3.3v options... but how well do those work???

author: ThomasDK
author_rank: Regular Contributor
timestamp: April 11, 2016, 11:09:04 pm
content: Meanwell IRM-03 or IRM-05 series.Super small, cheap, 3 year warranty.Mouser stocks them.Forget the ebay crap

author: Wilksey
author_rank: Super Contributor
timestamp: April 12, 2016, 01:19:38 am
content: Well it depends on the voltage you actually need?I have used the Vigortronix ones in the past, and they work well, I have some cheap Chinese ones, which also work, the output seems stable enough for a micro anyway.I have seen some "smart home" devices which use just the live (in line with a light bulb for ex), not sure how they work without a neutral, presume they pray on the neutral earth return and pick up on an earth point, they use wireless for comms and such, and get good reviews.Presume you are just putting a blanking plate on the front or are you planning on putting a switch / socket on also? Once the sockets and switches are on the wall there is hardly any room with a standard 35mm box, even the slightly larger 45mm "in-wall" boxes doesn't give much more room when you have a ring main circuit.

author: uncle_bob
author_rank: Unknown
timestamp: April 12, 2016, 01:26:40 am
content: Quote from: marcusone on April 11, 2016, 10:40:02 pmHiHow do you plan on getting this device to meet the legal requirements involved ? It's not something you can simply ignore with a directly connected (hard wired) device.Bob

author: nowlan
author_rank: Frequent Contributor
timestamp: April 12, 2016, 01:38:43 am
content: https://www.itead.cc/sonoff-wifi-wireless-switch.html$5?

author: peter.mitchell
author_rank: Super Contributor
timestamp: April 12, 2016, 02:12:42 am
content: power integrations have a few non-isolated step down converters that are pretty decent for this purpose.if you're looking for a non-isolated 5v supply to run a micro with a wireless interface that drives a relay id say these are ideal.

author: amyk
author_rank: Super Contributor
timestamp: April 12, 2016, 10:51:08 am
content: Quote from: marcusone on April 11, 2016, 11:36:17 amWireless only? Nophysicalconnections except to the mains? Then you don't need to worry about isolation and a capacitive dropper will be the simplest and smallest solution.

author: marcusone
author_rank: Contributor
timestamp: April 12, 2016, 11:47:16 am
content: Thank you to those that are concerned about my safetly and well being; but I haven't asked about that (and assure you I'm looking into my local rules, and will seek out help should I need it on that topic).I would like someone to let me know how well these work:digikey code: 945-2210-ND, or these, 102-3112-ND.I will NOT touch any China/Ebay devices (as who knows if they meet safety standards or not) for this project.Which means the digikey items are my best/safest bet... yet are rather expensive. So I don't want to buy a few items just to test. Please comment on those, or provide digikey alternatives.Thanks!

author: uncle_bob
author_rank: Unknown
timestamp: April 13, 2016, 12:59:34 am
content: Quote from: marcusone on April 12, 2016, 11:47:16 amHiIt's not so much a safety issue. You *can* be very safe and still not do it the way the rules want you to do. The concern is your insurance. House fires are rare. If you happen to be unlucky *and* have a wiring issue .... in most cases you just lost your insurance check.Bob

author: Wilksey
author_rank: Super Contributor
timestamp: April 13, 2016, 01:35:02 am
content: I prefer the term...Natural Selection.. O0