{"id":55,"date":"2013-07-14T20:13:00","date_gmt":"2013-07-14T20:13:00","guid":{"rendered":"https:\/\/blafaselblub.wordpress.com\/2013\/07\/14\/frankensockets"},"modified":"2018-01-09T14:01:05","modified_gmt":"2018-01-09T13:01:05","slug":"frankensockets","status":"publish","type":"post","link":"https:\/\/blog.alexander-tuxen.de\/index.php\/2013\/07\/14\/frankensockets\/","title":{"rendered":"Frankensockets"},"content":{"rendered":"<p>I hate tinkering with AC mains. But if you want to get &#8220;real&#8221; things done around the house there is no way around it. So before this goes any further, here is the disclaimer:<\/p>\n<p><b>AC mains power is dangerous. It can kill you and\/or burn your house down if you are not careful. Unless you know exactly what you are doing, DON&#8217;T TRY THIS AT HOME!<\/b><br \/>\n<b><br \/>\n<\/b>That being said, AC mains is no rocket surgery either and probably no one in their right mind would call a union electrician to hook up a lamp.<\/p>\n<p>So, what is there to switching mains? Not much, actually, it&#8217;s just a sufficiently rated relay to switch the hot or neutral wire (it doesn&#8217;t matter which, either will break the circuit and prevent current from flowing).<\/p>\n<p>There is a variety of readily made hardware available that will accomplish this but from my point of view all these products are flawed: The ones that work reliably are expensive and the cheap ones are unreliable.<\/p>\n<p><b>Hardware:<\/b><\/p>\n<p>I had a few very cheap and extremely unreliable ones around, so the obvious solution was to gut them and use the enclosures for my own design.<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_140939.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-140\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_140939-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_140939-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_140939-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_140939-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">I got these about 20 years back, as you can tell by the grime.. The set of four was about 30 DM, back in the day.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_140954.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-142\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_140954-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_140954-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_140954-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_140954-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">All those certifications&#8230; Must be good stuff inside&#8230;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141051.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-143\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141051-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141051-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141051-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141051-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">The enclosure looks quite nicely engineered. But what is it with that crappy and kind of burned looking circuit board?<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141123.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-144\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141123-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141123-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141123-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141123-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">Yuck! This isn&#8217;t even a cap dropper, this is basically just a resistor on a mains wire, and it looks fried up pretty good. How did they get all those safety stickers with this?<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"separator\" style=\"clear: both; text-align: center;\"><\/div>\n<p>The design itself is simple: Just hook up a relay to an Atmega with an RFM12B. If there wasn&#8217;t the issue of a power supply. Looking at commercially available solutions there seem to be mainly two options: Go with a full blown switch mode power supply or implement some sort of ultra cheap non isolated <a href=\"http:\/\/www.bitsbox.co.uk\/infocontent\/capdropper.html\">cap dropper<\/a> type power supply. Both have a list of pros and cons:<\/p>\n<p>SMPS pros:<\/p>\n<ul>\n<li>isolated from mains<\/li>\n<li>efficiency<\/li>\n<\/ul>\n<div>SMPS cons:<\/div>\n<div>\n<ul>\n<li>size<\/li>\n<li>price<\/li>\n<\/ul>\n<div>Cap Dropper pros:<\/div>\n<\/div>\n<div>\n<ul>\n<li>size<\/li>\n<li>price<\/li>\n<\/ul>\n<div>Cap Dropper cons:<\/div>\n<\/div>\n<div>\n<ul>\n<li>not isolated from mains<\/li>\n<li>inefficiency<\/li>\n<\/ul>\n<div>Looking at the pros and cons it&#8217;s obvious why most commercial products have cap droppers. They are dirt cheap to produce and the producer or vendor really doesn&#8217;t give a crap about their efficiency. After all it&#8217;s your power that&#8217;s wasted, not theirs. Mains isolation is irrelevant, since the whole circuit is safely tucked away inside the enclosure.<\/div>\n<\/div>\n<div><\/div>\n<div>To me as a hobbyist priorities are a little different. Efficiency totally outweighs initial cost. What good is a power supply that takes only 50 cents to build if it eats up 10 \u20ac in electricity a year. Not to mention mains isolation. I&#8217;ve known myself for quite some time now and I know that (probably like everyone else) with growing routine and confidence I tend to get sloppy. And that&#8217;s when I get hurt or accidentally blow up my gear. So no cap dropper for me.<\/div>\n<div><\/div>\n<div>An SMPS on the other hand would have to be reasonably cheap and, even more importantly, small. Given the simplicity of my overall design and the overwhelming choice in available SMPS, choosing a suitable one proved to be the most challenging part of this project.<\/div>\n<div>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a style=\"margin-left: auto; margin-right: auto;\" href=\"https:\/\/media4.rsdelivers.cataloguesolutions.com\/LargeProductImages\/R7065969-01.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/media4.rsdelivers.cataloguesolutions.com\/LargeProductImages\/R7065969-01.jpg\" width=\"320\" height=\"240\" border=\"0\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">These are really nice. But also very expensive<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<\/div>\n<div>\n<p>There are SMPS-Modules that would be ideal for this project, but unfortunately those cost about 30 \u20ac a piece, which is about three times of what I intended to be the cost of a completed socket, so those are out.<\/p>\n<\/div>\n<div>Then there are those really <a href=\"https:\/\/www.google.com\/search?q=euro+apple+iphone+charger&amp;safe=off&amp;source=lnms&amp;tbm=isch&amp;sa=X&amp;ei=DQvjUe2iBs3HtAbb9IGQAg&amp;ved=0CAkQ_AUoAQ&amp;biw=1600&amp;bih=741\">slim iPhone chargers<\/a>, but those also cost about 20 \u20ac (used to be 30 a few months ago) and my religion forbids the purchase of apple products anyway, so those are out, too. But then there are those fake Apple lookalikes, which cost only 2-4 \u20ac. Couldn&#8217;t I just use those? I decided to give it a try and ordered a bunch from Ebay or Amazon or so. Of the six I got one blew up right away, so I sent them all back the same day.<\/div>\n<div>\n<p>&nbsp;<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120606_225620.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-145\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120606_225620-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120606_225620-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120606_225620-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120606_225620-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">The switching transistor bent over to the secondary side was the reason this<br \/>\none was rejected<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>After ordering a few more similar, but slightly more expensive types, cutting them open and discussing the pictures on the net I finally found\u00a0<a href=\"http:\/\/www.amazon.de\/gp\/product\/B007V2Q4D2\/ref=oh_details_o05_s00_i00?ie=UTF8&amp;psc=1\">this one<\/a>:<\/div>\n<div><\/div>\n<div>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120614_221119.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-146\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120614_221119-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120614_221119-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120614_221119-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120614_221119-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">Almost as tiny as the &#8220;Apple&#8221; chargers<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>It&#8217;s cheap, small and at first sight not too dangerous. At least there were no reviews about these things blowing up all the time.<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120614_215452.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-149\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120614_215452-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120614_215452-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120614_215452-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120614_215452-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">This looks more like it. A nice big slot between primary and secondary side and no parts hanging over from the dangerous side.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\n<p>With this out of the way I was finally set to go. To make the PSU fit the enclosure I hat to cut it along the slot that was already there.<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_151837.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-150\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_151837-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_151837-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_151837-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_151837-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">Nice fit. The mains side of the PSU is on the left<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Space <b>was<\/b>\u00a0an issue with this project. I could have easily thrown those old sockets out and gotten new ones with bigger enclosures, but where would be the fun in that?<\/p>\n<p>So, after I pulled out that deathtrap load of crap PCB I found inside, I went through the usual process of measuring the enclosure and designing a new board in Eagle.<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/Screenshot-from-2013-07-12-213323.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-161\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/Screenshot-from-2013-07-12-213323-1024x576.png\" alt=\"\" width=\"640\" height=\"360\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/Screenshot-from-2013-07-12-213323-1024x576.png 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/Screenshot-from-2013-07-12-213323-300x169.png 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/Screenshot-from-2013-07-12-213323-768x432.png 768w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/Screenshot-from-2013-07-12-213323.png 1600w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"font-size: 13px;\">Boring.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/Screenshot-from-2013-07-12-212123.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-162\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/Screenshot-from-2013-07-12-212123-1024x576.png\" alt=\"\" width=\"640\" height=\"360\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/Screenshot-from-2013-07-12-212123-1024x576.png 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/Screenshot-from-2013-07-12-212123-300x169.png 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/Screenshot-from-2013-07-12-212123-768x432.png 768w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/Screenshot-from-2013-07-12-212123.png 1600w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"font-size: 13px;\">Also quite boring. This is hand routed, and I needed six jumpers. Lame.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>To accommodate the PSU, the relay and my controller board I had to make two PCBs: One for the controller and RFM12B, the &#8220;cold board&#8221;, and one for the relay and the PSU, the &#8220;hot board&#8221;.<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141312.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-151\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141312-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141312-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141312-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141312-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">The &#8220;hot board&#8221;. This will only contain the relay and mains connections for the PSU. This isn&#8217;t its final form. The leftover copper at the lower edge of the board was of course removed. At the left lower edge I hat already removed a bit too much.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_150450.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-152\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_150450-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_150450-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_150450-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_150450-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">To connect the PSU to my adapter board, I just bent two regular pin headers and soldered the PSU&#8217;s mains contacts to them.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141329.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-153\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141329-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141329-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141329-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120627_141329-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">The &#8220;cold board&#8221;: This will contain the RFM12B and the Atmega<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_152225.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-154\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_152225-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_152225-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_152225-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_152225-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">The push button and the LED are still missing.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_152216.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-155\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_152216-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_152216-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_152216-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_152216-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">Note the absence of parts on the right hand side of the board. That will be on top of the mains side of the power supply.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The controller board would be on top of the PSU. To eliminate the risks of accidentally shorting anything to the mains side of the PSU I arranged all<br \/>\nparts on the controller board so they would be a safe distance from all the scary mains stuff.<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_183210.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-156\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_183210-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_183210-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_183210-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_183210-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">The hard part is done. Those heavy duty mains wires weren&#8217;t too much fun to work with.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_183322.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-157\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_183322-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_183322-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_183322-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120628_183322-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">Almost completed. Now only the wires from the PSU and to the relay need to be connected.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The prototype worked perfectly, so I was ready to go into production&#8230;<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120706_223359.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-158\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120706_223359-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120706_223359-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120706_223359-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120706_223359-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">Three more controller boards<span style=\"font-size: x-small;\">.\u00a0<span style=\"text-align: start;\">I was smart enough to put three boards on a panel, but not to think about routing the outlines of the boards. m(<\/span><\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120706_223535.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-159\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120706_223535-1024x765.jpg\" alt=\"\" width=\"640\" height=\"478\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120706_223535-1024x765.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120706_223535-300x224.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_20120706_223535-768x574.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">&#8230;and the PSU\/relay boards.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>There was some time between building the first prototype and finishing the rest of the bunch, so it slipped my mind, that I used a m168p on the prototype and m328ps on the other three, but it wouldn&#8217;t have changed anything, because I hat no 168s left. Well, now I have to have a type A and a type B in my Makefile. Never mind.<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_9680.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-165\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_9680-1024x683.jpg\" alt=\"\" width=\"640\" height=\"427\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_9680-1024x683.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_9680-300x200.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_9680-768x512.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">The semi finished sockets on the &#8220;assembly line&#8221;.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>They work beautifully and the power supplies are quite efficient. With the relay idle they draw about 0.2W and with the relay active it&#8217;s about 0.6W. I vaguely remember, that the original circuit drew about 2.5W, no matter what. I could maybe reduce the active power consumption another bit by driving the relays with PWM, since they need a lot less power maintaining an active state than switching to it, but that&#8217;s for another day.<\/p>\n<table class=\"tr-caption-container\" style=\"margin-left: auto; margin-right: auto; text-align: center;\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_9703.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-large wp-image-164\" src=\"http:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_9703-1024x683.jpg\" alt=\"\" width=\"640\" height=\"427\" srcset=\"https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_9703-1024x683.jpg 1024w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_9703-300x200.jpg 300w, https:\/\/blog.alexander-tuxen.de\/wp-content\/uploads\/2013\/07\/IMG_9703-768x512.jpg 768w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td class=\"tr-caption\" style=\"text-align: center;\">I finally got around to adding the LEDs. The buttons are still missing, though.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><b>Software:<\/b><\/p>\n<p>On the code side there are a few things to mention:<\/p>\n<p>The sockets tie into my sensor and home automation infrastructure, I have yet to write a post about. Basically every type of device uses a separate rf12 node id, which is shared among all devices of that type, which in turn all have their own individual mcu ids, which are stored in eeprom and can be set dynamically.<\/p>\n<p>When a virgin socket is powered up for the first time its mcu id will be 0xFF, because that&#8217;s the default value of untouched eeprom. If the id is 0xFF, the controller will go into a loop where it sends a packet every second announcing that its id is unset. In this mode the only command it accepts is one that assigns it an mcu id, which is then written to eeprom.<\/p>\n<p>With the mcu id set, the controller will enter its normal mode in which it will listen for packets with matching node- and mcu id and do what it&#8217;s told. In this mode the relay can be turned on and off or queried for status.<\/p>\n<p><b>Conclusion:<\/b><\/p>\n<p>This was a fun project, but I wouldn&#8217;t go about it this way again. The power supply alone is way too much hassle. In the meantime I&#8217;ve learned about a nice sounding switching regulator for transformer less power supplies (and ordered a bunch), so I&#8217;d sacrifice mains isolation for simplicity, but I won&#8217;t play around with them without an isolation transformer. That would probably be really painful.<\/p>\n<p>I&#8217;ll probably stick to buying some cheap sockets and gutting them, because that&#8217;s the easiest and cheapest way to to get my hands on suitable enclosures, but I&#8217;d choose something nice and big, and maybe even a cheap brand name, to improve the odds that the same model will be around for a few years. After all, I don&#8217;t want to have to change my &#8220;Frankensocket&#8221; design around all the time.<\/p>\n<p>I&#8217;ll also make some with screw terminals or just wires sticking out, instead of sockets, that can be hooked up to ceiling fixtures. Those would easily fit in a small project box or maybe even a piece of heat shrink tube.<\/p>\n<p>I must add that I&#8217;m not the first one to do this. There is another, very similar project <a href=\"http:\/\/busware.de\/tiki-view_blog_post.php?blogId=1&amp;postId=8\">here<\/a>.<\/p>\n<p>As usual the <a href=\"https:\/\/github.com\/alibenpeng\/rf12socket\">code<\/a> and all <a href=\"https:\/\/github.com\/alibenpeng\/rf12_socket_1\">PCB design<\/a> files are available at github.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I hate tinkering with AC mains. But if you want to get &#8220;real&#8221; things done around the house there is no way around it. So before this goes any further, here is the disclaimer: AC mains power is dangerous. It &hellip; <a href=\"https:\/\/blog.alexander-tuxen.de\/index.php\/2013\/07\/14\/frankensockets\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,6,3,7],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.alexander-tuxen.de\/index.php\/wp-json\/wp\/v2\/posts\/55"}],"collection":[{"href":"https:\/\/blog.alexander-tuxen.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.alexander-tuxen.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.alexander-tuxen.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.alexander-tuxen.de\/index.php\/wp-json\/wp\/v2\/comments?post=55"}],"version-history":[{"count":7,"href":"https:\/\/blog.alexander-tuxen.de\/index.php\/wp-json\/wp\/v2\/posts\/55\/revisions"}],"predecessor-version":[{"id":245,"href":"https:\/\/blog.alexander-tuxen.de\/index.php\/wp-json\/wp\/v2\/posts\/55\/revisions\/245"}],"wp:attachment":[{"href":"https:\/\/blog.alexander-tuxen.de\/index.php\/wp-json\/wp\/v2\/media?parent=55"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.alexander-tuxen.de\/index.php\/wp-json\/wp\/v2\/categories?post=55"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.alexander-tuxen.de\/index.php\/wp-json\/wp\/v2\/tags?post=55"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}