Always take a actual size printout of your pcb before sending out to the manufacturer. That way you can try all the components and size any enclosure you want.
@@Mdsoebee there are many ways to do this. Most softwares for PCB design allow you to directly print your design into paper or PDF directly. Most also allow you to export the PCB to a 3D file which is what I do, and then you can 3D print the design to see if it will fit Personally, I always make the enclosure first then I design the PCB around the design. When I use Fusion 360 for PCB design they have an option to just select a sketch and turn it into a PCB outline. If you use any other PCB software such as KiCAD, you can export a fusion 360 sketch as an DFX file and then import it into KiCAD or other as the outline
Looks like a fun project. As a fellow EE, I do have a couple of things to recommend you consider to increase the life of your switch. First, as an aside, I am also working on a own project that includes an ESP32 - a ceramics Kiln remote temperature monitor. But, let's get back to you. Here is what I would consider. 1) The simplest solution would be to move from a relay to using an AC solid state relay. These always switch when the ac crosses zero so no nasty current transition issues. You could buy one but, I would expect that you would want to make you own one. 2) If you really want to stick with the relay, add a PTC thermistor in series. I expect that the high current you are seeing must be due to inrush, not the static current or the circuit would overload. Adding the PTC will limit the inrush current when you turn the relay on and hopefully prevent the contact from arcing. Have fun and stay creative!
2) you probably meant to say NTC instead of PTC? NTC (Negative Temperature Coefficient) start as high impedance as cold and then current flow dissipates power for them to warm up and become low impedance. A PTC is the opposite - useful to protect from battery overload, but WAY too slow to protect from inrush.
You could also add a snubber circuit over the relay-switch to prevent electrical interference noise and sparking. (I have had micro controllers reset because of electrical interference from switching relays)
I did something similar, twice. Parts: 4 gang outlet box, populate with 4 dual outlets and a 4 gang plate. Recycle a power cord from something heavy. Inside is an 8-relay board from SainSmart but any relay board will do. The brains is a Raspberry Pi using the Wiring Pi to switch the relays, which are connected to the outlets. Use a USB charger and a 6 inch usb cable to power the rPi. The pi has a USB wifi adapter for communication. Finally I use the web server on the pi and CGI scripts (and some SUID scripts) to turn outlets on and off. I use it for Christmas Lights, our lawn irrigation system, and to shut down an internet switch so the kids are not up all night. Putting it in a 4 gang outlet box means it is more like a chunky power strip than a single outlet. Very useful though and doesn't serve ads, require a subscription, or anything. Code can be found here: github.com/zettix/outlet
Hello mate I've been loving the content for years now, and have been watching since I was 16. I am now in my 2nd year of electronics engineering degree thanks to your content too! Please keep it up and I love the content!
One thing you may want to try to prevent inrush relay sticking is to use a dual inrush relay circuit. Basically you have two relays where the load contacts are in parallel. One relay has a current limiting in series (resistor will do for testing). You close the current limited relay first then the non-limited relay is energized and bypasses the current limiting. When turning off you open the non-limited relay contacts and then the current limited contacts.
This can be useful for really high loads, high switch frequency, or something which requires precise start timing, but is usually overkill for something like this IMHO. Much the same result can usually be achieved (much more easily) using something like a negative-temperature-coefficient (NTC) thermistor in series with the load... Also, a lot of the time, relay arcing is actually not because of inrush current, but occurs when _disconnecting_ due to back-EMF from things like motors (this doesn't usually result in relay sticking, but can result in contact degradation which ultimately leads to high resistance and relay failure (or worse, fire risk). For that sort of issue, adding a metal-oxide-varistor (MOV) can often reduce or eliminate the problem...
@@fodl4387 Some old electric trains use this system, they have massive DC motors connected to massive banks of resistors which are bypassed/put in parallel as the train speeds up and current reduces. But not all old trains use resistors, some use tapping contactors.
I'm really excited about the ESP32-C3 for projects like this, it feels more like the next evolution of the ESP8266 than it does the other ESP32 series chips. One nice feature about it is that it has a built-in USB Serial/JTAG port, so by simply connecting IO18/19 to USB D-/D+ you can connect it to a computer and program it without even having to mess with programming pins
@@zyghom Oh that's awesome! I've mostly been sticking to the chips on the lower end, so it's great to see this feature is now in one of the boards you can get for under $2 each
Another advantage of the ESP32 is the GPIO matrix which allows almost complete flexibility of which signal connects to which pin. The SPI wiring issue in this video could have been addressed without a hardware revision.
ESPs are great. I wanted to experiment with making a joystick a while ago, but it turned out none of my arduinos supported USB HID.. I remembered I had an ESP (not sure what model atm). It too didn't have USB HID either though, so I ended up creating a Bluetooth joystick instead 😅. I found a sketch online and was up and running in less than an hour. It did turn out that the only potentiometer I had was for audio volume, thus logarithmic/exponential, so didn't make for a precise input device. Still a cool experiment. The "joystick" was a single axis input for a mining throttle in Star Citizen.
@@chrisreynolds6331 That's awesome, Tasmota is really cool for tasks where you don't want to write your own application code from scratch. My builds are fairly specialized though so I'm writing code for them in Rust with ESP-IDF. I can deploy my code to the ESP32-C3 with a simple `cargo espflash --release` command
A cheaper relay can also be used, as long as a simple soft-start circuit is being used. Either with resistors or with a NTC, to bring down the inrush current. Downside is that it will take a little longer for the devices to get needed energy to power on.
Some people have solved this problem using one of the aforementioned relays, but also ensuring that the switching occurs at the zero crossing point in the AC waveform. Though with switch bounce being a factor, it might be worth measuring how long the bounce effect occurs for your given relay before trying it.
One thing I was surprised you didn't mention was proper derating for relays depending on anticipated load type. One of my pet peeves about these sorts of "smart switch" things is that they generally use the cheapest relays they can get away with, which means they are also not derating them properly. If the switch claims it supports, say, 10A, they actually mean that only for *purely resistive loads.* (and sometimes it may even say that somewhere in the fine print, but often not) For any other types of loads it will only be able to handle a fraction of that without eventually failing. If you are switching inductive loads (like something with a transformer), you really need your relay to have twice the current rating. If you're switching motors, it should be around 4 times. If you're switching "tungsten" loads, such as incandescent lamps, the relay should actually be rated for somewhere around *8 or 10 times* the nominal current in order to actually reliably function and last properly over time. Since these sort of "outlet switch" devices could theoretically have all kinds of different loads plugged into them, and you can't know what the user is going to try to switch, you really need to design conservatively, IMHO, and should usually be substantially oversizing your relay specs to be safe. You also really should design your circuit with some thermal protection to detect if the relay gets too hot (because somebody's plugged too big a load into it, or because its contacts have degraded over time so it can't support as high a load as it should be able to). Most commercial products place some sort of thermal fuse right next to the relay to detect problems and cut out before things get so toasty that they start melting things or burning your house down.
For the massive wall of text you wrote, it's weird that you end up contradicting yourself. A tungsten lamp is a purely resistive load. Meaning 25 regular bulbs would be what they expect you to use. Well in general these are intended to smarten up lamps. They don't expect people to use them on their ac or fans because they think you should normally have that installed and not plugged into an outlet. They're made in China they don't think people live in decades old buildings in Europe. I don't know what you're trying to control through these but it just wasn't intended for that, i don't think it's really the fault of the specs they report.
@@SquintyGears No, that's a common misunderstanding, but a tungsten lamp is *not* a purely resistive load (at least the way the term is typically used in electrical engineering). This is why if you look closely, many components like switches will have a separate "normal" wattage limit and a (much lower) "tungsten" wattage rating listed. The reason is that the materials that incandescent filaments are made out of actually have a resistance that varies depending on the temperature. When they are cold (right after turning on), they actually have a fairly low resistance, and it's only as they warm up (and start glowing) that they settle down to their nominal resistance/wattage. That means that at first, they will actually pull substantially higher current (10 times or more) when they're initially switched on than they do after they're fully "on". So any components designed for switching "tungsten" loads like incandescent bulbs really need to be designed to handle substantially higher instantaneous currents than one would expect from the nominal wattage of the bulbs themselves. (And in my experience, people often do put these sorts of switches on things like pumps, fans, even sometimes things like refrigerators, etc, and then usually get annoyed when they fail after a few months of use, even though they never exceeded the power ratings the thing claims it's supposed to be able to handle...)
@@foogod4237 a variable resistor is still only a resistor. I'm not confused about that part. I guess i see what you mean, they don't include the burst rating of the first 5s of short circuit current from turning on cold. That's the source of the arcs. That's why the contacts fuse. But shouldn't that only covers the material choice? because 5 bulbs doesn't trip anything pulling double breaker limit during the warm-up.
@@SquintyGears A typical "40 watt" tungsten filament bulb (120 volts) has a cold resistance of about 28 Ohms. If you apply 120VAC (0% THD) at 90deg phase angle, the peak applied voltage is ~170V. This means the peak power for a couple milliseconds (plenty of time for bouncing and sparks) is about 1kW. Averaged over the first half-cycle (8-10ms) it's still 500W. After many cycles the wire temperature and its resistance has increased to ~360 Ohm, so the average power dissipation is now 40W. Circuits don't "trip anything pulling double breaker limit during the warm-up" because breakers are designed with a time delay. Mechanical ones use a bi-metallic strip that (like the tungsten filament) takes time to warm up. Fancy new electronic breakers basically emulate this with a time-constant or i^2-t implementation.
@@SquintyGears I think your confusion is that "pure resistive load" actually has a specific meaning in electrical engineering, and it doesn't just mean "there are resistors involved". It actually means a load which behaves exactly the same as if a single, standard resistor were put in its place (that also means the resistance not change value over time, etc). The reason that tungsten loads don't generally trip circuit breakers, etc, is that the current spike is for only a brief moment when turning them on (it's actually only a fraction of a second, not even anywhere near 5s), and most breakers and fuses are actually designed to be fairly slow-acting (partly for this reason). This can cause a problem, though, if for example somebody replaces a regular fuse with a fast-blow type fuse in circuits involving incandescent lights, etc, because those often will blow in that situation when the more common slow-blow fuses won't.
In next revision you may consider a better placement for the poor antenna of the esp8266, as I'm not sure it would like that big ground plane around it 😀
Was going to say the same thing! Follow their guide on it. I place mine at the edge of the board, and have the PCB vendor rout out the PCB under the antenna. 15mm clearance on either side I think is in the guidelines.
I think the reason the small transformer distorted was because most mains transformers saturate a bit with no load. That's the same phenomenon that makes old school power supplies warm
why exactly is it a problem to put the current measurement IC on the mains side and isolate the SPI? You anyways have mains voltage in there and the transformers seem like a ton of added build volume and BOM cost.
Scott, I got some threaded, silver tipped contacts, from a big brother of the relay, which was a contactor, and it was made for a large DC drive motor from some warehouse transport equipment. I used these for my welding earth ground as they were much more conductive than the copper plated steel ones that were standard on a battery charger clamp. These were for my "new" flux core welder. It was a heavy clamp with a rubberized coating, and was replaced with a newer clamp, but wasn't worn out. I ran a tinned braided copper cable from the welding lead end which were both attached at the jaw on one side. I then secured this with a contact stud from the former contactor behind the back of the pivot inside the grip, around to the other jaw of the clamp. Then I attached a silver contact on this side as well. It was a fair substitute for a proper earth ground, and will work until I find a suitable replacement. The contacts are proud in the clamp, and have a good "bite" on the steel thanks to a good spring.
Great work again! You can add a small transistor circuit to switching the coil to a lower holding current to make the circuit more power efficient. Since you were concentrating on improvising the design, you could have included low power considerations also for the electronics.
yes ! this just solved my curiousity !!! i know them are Planned Obscolescence as i bought 4 of them and they just dead and yes, they have that pop sound always
Why bother with the galvanic isolation? The whole system gets encased in plastic anyways. Maybe without the transformers you could have made the pcb small enouth to fit in the original case. I only see a reason for the isolation while you are develpoing the curcit / software
You not only get the safety aspects but if there is trouble on your mains side then the extra isolation will make it harder that the circuit will suffer on the lower voltage side. But then again like you said, without it you can make everything much more smaller and cheaper. But my focus here was safety and reliability.
@@greatscottlab I think you've done a good job there. My final concern, though, is that the 3D-printed case is not fire-rated/self-extinguishing, so if things get to exciting in the mains side, well, you know. Great depth on all the electrical stuff, though. Always enjoy your videos for that.
@@PatrickRigney You can print it from material which had self-extinguishing proprieties. Some even have tests according to UL94 and if you are willing to pay, you can buy UL certified materials.
Nice Job. Consider switching the relay at the zero crossing of the mains (since you are measuring the voltage). That should dramatically increase the life of the relay.
@@bansheedearg doesn't have to be perfect, triacs detector is used to rearm the triac for every cycle but for relay you only to do it once every switching. even if you miss the timing by 3ms you still subject to ~30% voltage which creates smaller spark
Great project! I had no idea how much extra work went in to voltage and current monitoring. I wonder if it would be possible to precisely time the relay turning on and off to match the current waveform you showed. If you were able to reliably switch the relay at the 0 point of the current cycle, then theoretically you wouldn't have to worry about arcing or welding of the contacts.
I was going to mention the same. Mr Carlson's Lab did a similar upgrade on a refrigerator light that used a zero crossing circuit to prevent the inrush/arcing. It didn't use relays but could probably be used as a starting point.
Next time you may want to use cutouts between your low voltage part and the mains voltage part on the PCB to get the insulation voltage up and prevent creepage paths on the pcb
why exactly is it a problem to put the current measurement IC on the mains side and isolate the SPI? You anyways have mains voltage in there and the transformers seem like a ton of added build volume and BOM cost.
I am 100% with you - I recently replaced all my cheap boards I bought on Ali (with blue relays, SONGLE) that were almost all sticky, to the new ones - FANHAR - and these are with AgSnO2. Btw good companies use exactly FANHAR relays. It is not easy to find the 5V ones (black, FANHAR) but I back ordered 100 pieces on LCSC. And the cost of FANHAR is just about 0.5$/piece P.S. your solution is kindly 4x more expensive than the good sockets i.e. from Athom and they use AgSnO2 relays, that are also providing power measurements and are based on ESP so super easy with ESPhome
I've been thinking about this for some time but have not built anything yet. Some ideas I've been toying with: 1. Make a multiway strip. That way you avoid duplicating the LV power supply, the voltage sensor and the controller chip. Plus you put less burden on your WiFi router. Plus you can build in value added functionality like turning off peripheral power supplies when the main device power drops to standby level. 2. Use latching relays. That way you avoid consuming current to hold the relays on. These relays have gotten surprisingly inexpensive. 3. Use a hall effect sensor for current measurement. It ought to be possible to build this like a miniature clamp meter on the PCB. Intrinsically safe and should be much smaller than a current transformer. 4. Zero- current switching. If sensing AC current you can delay opening the relay contacts until the zero crossing of the current waveform to eliminate arcing. Also may be worth closing the contact on the zero crossing of the voltage waveform. 5. Genuine zero-power standby. This could be done with a super capacitor and push-button for wake up. Maybe even a solar cell and an IR transmitter for cordless remote.
Ok, I'm curious... Scott, what are your thoughts on solid state relays? I've used some DC driver solid state relays on arduino projects, on the theory that solid state won't weld contacts, I know AC driver solid state relays are a thing, but I've never used them.
One thing to note that usually cheap relays are specced to AC currents or to a rather low voltage resistive load. In your tests you kinda have a capacitive load in DC.
It's a great educational video! I just wanted to share a data with you, you might know also that the enclosed air-tight relay are basically spark-protected by its design. Inside the air-tight encloser, their are no Oxygen available to make a spark/fire. Because the fire triangle is broken here. That's why it's fill with some inert gas like N2, it may be welded together if really high current passes through the contact point(Over 2-3 times of rated current).
I think you have some misunderstanding of the basic physics of electrical arcing. Electrical arcing is not actually fire, and it does not require oxygen (or any combustible material) to occur. What you see when electricity arcs from one contact to another (and what causes much of the damage) is the ionization of the gas molecules into an incandescent plasma. This can happen with any gas, even completely inert ones (this is actually the same thing that happens (in a controlled way) in flourescent and neon lamps, etc, which also have no oxygen in them). Removing oxygen can prevent oxidation of the relay contacts (which can lead to high resistance and relay failure), but it does not prevent the arcing itself, nor does it prevent the high heat of the arc which is what results in relay contacts ultimately fusing and sticking together in these sorts of scenarios. Also, hermetically sealed relays are actually not that common, and are usually substantially more expensive. Most common relays are not actually sealed in any way that can keep oxygen out to begin with.
The 3d printed mains enclosure concerns me. There are many considerations given to fault containment and flammability in rated (UL) enclosures that may or may not be covered by a print. Many (most?) molded enclosures are ABS or polycarbonate same as could be done on a 3d printer, though I was under the impression that they have flame retardants added. *After a quick search you can in fact buy flame retardant ABS filament, neat! That being said, there are no shortage of sketchy, unlisted devices that don't end up burning your house down, so in all likelihood it's probably ok.
There're some other filaments out there. For example INKRAYON Glass (PEN-PET, like PETG), UL94V-2. Sometime you can get it for a very low price on ebay(DE/EU). But's transparent.
I've been uninstalling some smart switches I put in 5 years ago that have all stopped working, and I'm seeing here what probably happened to all of them. Thank you for your endless creativity and educational efforts.
Great project 😊 And happy to see that we can also repair the cheap smart sockets with a better relay. I think a awesome project could be to do that with each port of a power strip
@Annette Singleton Steele i prefer to invest in drugs
2 роки тому+5
Hi @GreatScott! , one way that I found that can help improve the relay sticking problem is using a zero crossing circuit to turn on or off the relay at the zero voltage of the sine wave of the main voltage, I believe the IC that you used have that functionality and improves a lot the arc problem ;)
There is one thing you could add also to such a divice, called zero point switching! It´s used in modern impulse switches and stairwell relais! Problem with modern contact materials are that the use of beryllium copper was baned some years ago, until then such problems where more or less unheard of!
Nice work. You could as well keep the old relay but add an NTC resistor in series with the load. This eliminates the inrush current capacitor charging problem. I did it with one nasty socket some years ago and it is still going strong.
Very cool! Will you be sharing the BOMs and Gerbers for this project? My preferred smart socket is completely sold out, but I need more of them. Also, an inline cable design might be cool.
I only have one concern. As you said in the video we are dealing with mains voltage. There are codes and standards the normal manufacturers have to follow. Depending on the country you live in, it may not be up to code.
A solid state relay as 1-st phate of turning-on and after it should be crossed by a normal relay. Well, there is already 3.3V PSU, so why can't be used both? Pretty simple in my opinion and NO sparks on connect (on disconnect - still possible - need tests).
@GreatScott! I went trough this too. Realized that the sockets are built to a cost not a high standard. Id thought about moding them for higher load but the reality is they already sell them if you look hard enough on google & are willing to pay for it. Would also point out Outdoor smart plug applications tend to have the internals were after
by the way since you're already monitoring mains you could also make your relay switch in a very low current part of the waveform to extend its lifetime even further (this would also prevent arcing on disconnection of inductive loads for example, not necessarily catch _all_ the inrush current though, but should definitely make it "nicer" / less spikey).
Very interesting and useful project! I have a small question - can a solid state relay be considered over electromechanical for longer life and compact design?
I have for many years done service on ultra low temperature freezers. The main problem was sticky relay contacts for the compressors duty relays. The worst working relays was with long contact legs and two poles. The speed and torque of the switching is so important. In the last 15 Years s the relays was changed to a single pole Potter and Brumfield that never let me down. Those small 25amp had one big diameter curved contact side and the other a smaller that rolled a little to the side on every action. The duty cycle of every 15 minutes 24/7 and never made a failure. The sugar cube sized beauties was awesome in function. The ones to try on heavy load and frequent duty😊
You can add solid state relay in parallel with mechanical one, and turn it on just a moment before mechanical. You'll get: 1) guaranteed turn on when voltage will cross zero 2) shunted relay contacts, that will significantly increase it's lifetime because of no sparks 3) low resistance and no heat comparing with stand-alone solid state relay
Hello from Frankreich !! Once again a GREAT job 👌 I like your approach of problem and your methodology to resolve them. Thanks for sharing your thoughts, projects and tips !!
I had built an ESP8266-01 4 channel relay controller board for 220v ac appliences last year. It has been 1 year+. I use it daily, controlling Fan rated 80W, LED Tube light rated 25W, A Lamp rated 20W and a small dim bulb of 2W. No problems found yet, best of all they don’t stick in my case which might be due to low current consumption of appliences.
I did this by simply buying a $1 power socket and rewiring it to a hlk relay and ESP breadboard. Would love to see you redo it that way with your circuit
I love your channel and the way you explain things in detail. I built a spot welder one time, and had the high power switching turn on at the zero crossing point so there was no current flow on switching and no arcing. I am surprised you did not do something similar.
I really appreciate your efforts and I like this video. Creating independent solutions for the proprietary smart home jungle could not be honored enough but for the comparison the time for the design process of circuit, board, case and the documentation needs to be taken into account. Feature wise your solution is far more advanced but even if you only add only 40h of development time in total (which is surely not that unrealistic) economically your solution sadly won't be able to compete with the commercial product in my opinion.
@@greatscottlab There is a market for something like this. The Tasmota smart bulbs (which can be re-flashed to ESPhome if one wishes) cost 2-3x more than the Tuya ones but people do buy them. The market is smaller, because the average person does not consider the security implications of using the multitude of "no hub" smart home apps.
Hey, i have a different issue regarding such smart sockets: It occasionally trips my circuit because of various power supplies in the circuit. Wouldn't a solid state relay solve the issue and why didn't you use one?
I thought it gonna be solid state relay switching at the zero crossing of the mains. It would be also beneficial in scenario where you have 5 PSU under one socket. It popping 16A circuit breaker if you hit peak mains voltage when turning on. Great job with DIY smart socket :)
I would love to see your comparison between what JLCPCB offers in 3D printed parts and what you can create at home. I have used their 3D printed parts in the past and I am quite happy with them, especially compared to the quite a bit lower quality of the parts from my own 3D printer.
I’ve done this too where I need a hard wearing part, print in PETG on my Ender and order it online in Nylon once I’ve tested my prototype works/fits well
What about a solid state relay? I don't know much about how they work or if they could handle the current but seems like it wouldn't wear out. Cool project!
Awesome Work! Thank you for sharing! :) On a side note: Something that popped into mind is that you may be able to extend relay life by creating a zero crossing circuit. Maybe that could be a future video topic? :) Stay Creative! :)
I actually thought this video was going to be about zero-crossing switching. A little annoying to tune the timing, but once you have the contacts closing at less than 10-20V, there's essentially no chance of welding. I'd be interested to see how disconnecting works. I made my circuits open at zero-cross as well, but I never really knew if it had the desired effect.
@@samuraisystemsllc The problem with zero-crossing on open is that you actually need to open at zero _current,_ not zero _voltage._ With purely resistive loads, they will be the same, but many types of things people plug into outlets are not purely resistive, so you need to be able to account for a (often unpredictable) offset between voltage and current zero-points. It also doesn't necessarily help that much if you have inductive loads, due to back-EMF, etc, which can still produce voltages across the contacts far higher than the relay is designed for, even after they're fully open. For this sort of concern, something like a MOV in parallel with the relay is usually an easier and more effective way to deal with the issue.
Just one reminder since GreateScott didn't say it: Check if you are legally allowed to connect any stuff to mains voltage you build yourself. In Germany, you are not allowed to connect anything to mains that has not been tested and certified before. Even if you are qualified, you are not allowed to connect stuff you made directly to mains, because of insurance reasons. If you find a company that tests and verifies your stuff and is liable with their insurance, you can choose the DIY way. So "buy" is in the case of mains voltage devices always the win, at least in Germany.
If you are qualified at the level where you could actually certify the work of others , then im guessing it is not a problem. Im not sure whether you are required to have that insurance then, but most people do.
Okay.. looked through the Video, load Patreon, downloaded the files, send JLCPCB a new job to make me 50 of this PCB´s, Ordered all parts direktly after that.. now i am waiting and just loving (as always) your videos. Can´t count how often you make a video and my online thoughts are "i need to build this too". It started a few years back and is still going strong today. Thought i contaced you one time due to a mistake i made..(?) Great video and top build again. Keep it up :)
I haven’t read all the comments, so someone have suggest this. Do zero crossing switching. That is only open or close the relay when the line voltage/current is zero. May require additional sensing circuitry but the esp32 could be easily programmed to add this function.
You'd also want the current to be zero. Which, depending on the load and would either lead or lag the voltage. Adding ESD protection like an MOV (Metal Oxide Varistor) would probably work better.
Coming here to post the same, a simple zero crossing detector is what would be needed. I’d go through an optocoupler and tie the output to an input pin on the esp. I’d say an interrupt, but 60/50Hz is slow enough to sample, or enter a subroutine that only samples rapidly during a switch on/off mode. @dminting, yes, PF is something to consider and would be load dependent. Though, it wouldn’t be a problem on power on since current = 0. And if we’re only considering inrush, it wouldn’t be an issue on breaking the circuit. Now, monitoring on disconnect, you could sample the current with a current transformer and do zero crossing that way, or, in theory, even with a bad PF, the operating current shouldn’t exceed the relay current rating.
These Hilink power supply modules are quite bad for EMI in my experience. We use them in a commercial product we designed and even with the recommended filter and protection circuit (common mode choke, class x and y capacitors, movs, ntc) it's still radiating quite a lot. Thankfully the board is in a metal box and that keeps the crap inside for the most part. In the past we used Meanwell power modules that are slightly bigger, way more expensive, but had all the filters inside and were rated for medical applications (super low EMI). Think you should consider those for a future revision, they're bulletproof.
That's just brilliant, dude! Fantastic work! 😃 And this way you can get data for almost everything in the house! Anyway, stay safe and creative there! 🖖😊
I have had great luck with my Kasa smart outlets, after 4 years of use i haven't had any issues. ...But I am only running lights and lower power items. I have one on my window AC, no issues so far but good to know I should keep an eye on it.
Nice project. I also worked on a solution like this for years. So I think your solution is safe and the pirce is ok. But I think your standby power consumption is about 1-2W? Maybe you show us the disadvantage in a future coming video?
this is so cool! i really tired of crappy sockets from aliexpress. most of the time they are non-esp so can't be reprogrammed with tasmota or similar. sometimes they just don't work or work only via Chinese cloud. the idea of opensource reliable wifi socket is flying around for years. i really glad that somebody finally did the good job on it. btw 3d printed case is amazing too!
I know right, and they also have the PM switch models. My Shelly Plug-S also measures power consumption and is only a small fraction of the size of the wireless relay built here. And it can handle 10 A at 240v while also being able to set a current limit/maximum power limit.
Nice project, thanks for sharing! Only thing I'd like to ask is the power consumption figures - it seems that the W and VA values for both states are transposed? Or have I missed something? (@ 11:39 in the video)
Another way to prevent the massive inrush is with a Triac in parallel with the relay. You trigger the triac a few milliseconds before the relay so that the inrush current starts to be handled by the triac and stops the relay from arcing, but also having the low on resistance of the relay. Also, I understand why you used the Voltage and Current transformers for power measurement, but personally I would have just used the pure resistive methods to lower bulk and cost. The PCB will 99% of the time be in it's enclosure so it will be safe.
I was thinking about making a comment along the lines of your second idea there. If you're building this device for the sole purpose of not needing to replace or service it for long periods of time, and the only electrical contact it has with the outside world is through mains voltage anyway, then a capacitive dropper and direct resistive measurement should be fine. Also, your first idea is great! I hadn't thought of that. It's just like how high voltage DC transmission circuit breakers work by using a metal contact as the "running" link and using solid state relays as "breaking" links to prevent megavolt+ arcs from annihilating the countryside.
How about adding a software feature into your design to only switch on a mains zero crossing. If tuned to switch on the lowest current that would reduce the sparking completely.
not possible with mechanical relays as the closing/opening time is not perfectly predictable. there are solutions for this. also he was testing with DC switching, AC switching is completely different.
Great topic. This "fragility" is part of planned obsolescence... I made my own system a few years ago and it still works great. Here in Brazil people have been doing home automation with low quality "smart devices" without worrying about safety and this is dangerous.
very good explanation, I revisit this video again after studying Ugreen power strip teardowns on a Chinese website, apparently Ugreen uses the relay that has AgSnO2 as the contact material as you explained to reduce sticking, thus I know they do care about quality.
Cheap relays can be used as long as there is a snubber circuit between the relay contacts. I will only recommend an NTC thermistor in parallel with a timer-relay if the load has a high inrush current. Note that the capacitor may act as a short when power is applied barely powering the load.
Isn't possible to delay the activation of the relay (either on or off) to the zero voltage of AC line (or just before as closing in the circuit, depending on activation time) ? This way no arcing and far than acceptable "response time" AND low consumption. I wonder if it won't be possible to do it with some cheap electronics too. Of course extendable with an appropriate relay but this time you can focus on conductivity alone (and having a high thermal conductivity gaz into it -He- plus some metalic enclosure (AL would be the best) would help the life time. => I also experience issues with relays as I'm currently living in altitude and they seem to not like at all the cold temperature we can have here and they solder themself a lot in the outside. => Had some really high thermal high spot with a thermal camera on the relay inside an hybrid solar inverter (wks), in the command part. It was far hotter than the rest of inverter even during high load times. It both scared me AND worried me about it's efficiency and lifetime. Sometime relays are somehow hungry and I wonder if there are some out there that have a far less consumption.
Hello sir, I remember that you have introduced how a zero-voltage crossing detecting circuit[maybe isn't explained like that in English, I apologize] works and you also used it for solving the surge current problem from your big variac, I guess that principle would work on this relay sticking problem, isn't it?😃
If you know roughly how fast the relay switches I don't see why you couldn't time it. In a simpler circuit that's impractical but he's got a whole ESP there.
0:40... Oh boy does that bring back memories 🤣 Had to un-weld an industrial relay at work one time... 600V, 200ish Amp... it welded... Took a big screwdriver and juuust a bit of a hammer tap. 🤣
Always take a actual size printout of your pcb before sending out to the manufacturer. That way you can try all the components and size any enclosure you want.
Great advice. What computer program do you use to do this?
@@Mdsoebee there are many ways to do this. Most softwares for PCB design allow you to directly print your design into paper or PDF directly. Most also allow you to export the PCB to a 3D file which is what I do, and then you can 3D print the design to see if it will fit
Personally, I always make the enclosure first then I design the PCB around the design. When I use Fusion 360 for PCB design they have an option to just select a sketch and turn it into a PCB outline. If you use any other PCB software such as KiCAD, you can export a fusion 360 sketch as an DFX file and then import it into KiCAD or other as the outline
or use the fusion360 electrical 3d tool..
Looks like a fun project. As a fellow EE, I do have a couple of things to recommend you consider to increase the life of your switch.
First, as an aside, I am also working on a own project that includes an ESP32 - a ceramics Kiln remote temperature monitor. But, let's get back to you. Here is what I would consider.
1) The simplest solution would be to move from a relay to using an AC solid state relay. These always switch when the ac crosses zero so no nasty current transition issues. You could buy one but, I would expect that you would want to make you own one.
2) If you really want to stick with the relay, add a PTC thermistor in series. I expect that the high current you are seeing must be due to inrush, not the static current or the circuit would overload. Adding the PTC will limit the inrush current when you turn the relay on and hopefully prevent the contact from arcing.
Have fun and stay creative!
2) you probably meant to say NTC instead of PTC? NTC (Negative Temperature Coefficient) start as high impedance as cold and then current flow dissipates power for them to warm up and become low impedance. A PTC is the opposite - useful to protect from battery overload, but WAY too slow to protect from inrush.
@@dl5244 Thanks DL, I don't use this technique very often so I guess I got the terms swapped.
You could also add a snubber circuit over the relay-switch to prevent electrical interference noise and sparking. (I have had micro controllers reset because of electrical interference from switching relays)
Also sounds like a good idea. Might try that in another video ;-) Thanks.
@@greatscottlab would be cool to have a video on methods to reduce sparking in relays/switches!
@@jorno1994 and what about solid state relays, like I know he did a video on them, but he didn't mention them here
@@ianthehunter3532 SSR with 10A capability has to be big I think, much bigger than mechanical one. And their reliability is not as good either
Than three will be no proper seperation between mains and load .
I love the way you introduce the topics, and how clear you speak!
I did something similar, twice. Parts: 4 gang outlet box, populate with 4 dual outlets and a 4 gang plate. Recycle a power cord from something heavy. Inside is an 8-relay board from SainSmart but any relay board will do. The brains is a Raspberry Pi using the Wiring Pi to switch the relays, which are connected to the outlets. Use a USB charger and a 6 inch usb cable to power the rPi. The pi has a USB wifi adapter for communication. Finally I use the web server on the pi and CGI scripts (and some SUID scripts) to turn outlets on and off. I use it for Christmas Lights, our lawn irrigation system, and to shut down an internet switch so the kids are not up all night. Putting it in a 4 gang outlet box means it is more like a chunky power strip than a single outlet. Very useful though and doesn't serve ads, require a subscription, or anything. Code can be found here: github.com/zettix/outlet
Hello mate
I've been loving the content for years now, and have been watching since I was 16.
I am now in my 2nd year of electronics engineering degree thanks to your content too!
Please keep it up and I love the content!
One thing you may want to try to prevent inrush relay sticking is to use a dual inrush relay circuit. Basically you have two relays where the load contacts are in parallel. One relay has a current limiting in series (resistor will do for testing). You close the current limited relay first then the non-limited relay is energized and bypasses the current limiting. When turning off you open the non-limited relay contacts and then the current limited contacts.
There's is a really old method for starting motors using this system to prevent inrush current.
Smart!
And the double click must be nice to hear for the connoisseur, a bit like someone heel&toeing while downshifting
This can be useful for really high loads, high switch frequency, or something which requires precise start timing, but is usually overkill for something like this IMHO. Much the same result can usually be achieved (much more easily) using something like a negative-temperature-coefficient (NTC) thermistor in series with the load...
Also, a lot of the time, relay arcing is actually not because of inrush current, but occurs when _disconnecting_ due to back-EMF from things like motors (this doesn't usually result in relay sticking, but can result in contact degradation which ultimately leads to high resistance and relay failure (or worse, fire risk). For that sort of issue, adding a metal-oxide-varistor (MOV) can often reduce or eliminate the problem...
Double the failure modes. Brilliant.
@@fodl4387 Some old electric trains use this system, they have massive DC motors connected to massive banks of resistors which are bypassed/put in parallel as the train speeds up and current reduces. But not all old trains use resistors, some use tapping contactors.
I'm really excited about the ESP32-C3 for projects like this, it feels more like the next evolution of the ESP8266 than it does the other ESP32 series chips. One nice feature about it is that it has a built-in USB Serial/JTAG port, so by simply connecting IO18/19 to USB D-/D+ you can connect it to a computer and program it without even having to mess with programming pins
S2 has this for ages already, S3 as well ;-)
@@zyghom Oh that's awesome! I've mostly been sticking to the chips on the lower end, so it's great to see this feature is now in one of the boards you can get for under $2 each
Another advantage of the ESP32 is the GPIO matrix which allows almost complete flexibility of which signal connects to which pin. The SPI wiring issue in this video could have been addressed without a hardware revision.
ESPs are great. I wanted to experiment with making a joystick a while ago, but it turned out none of my arduinos supported USB HID.. I remembered I had an ESP (not sure what model atm). It too didn't have USB HID either though, so I ended up creating a Bluetooth joystick instead 😅. I found a sketch online and was up and running in less than an hour. It did turn out that the only potentiometer I had was for audio volume, thus logarithmic/exponential, so didn't make for a precise input device. Still a cool experiment.
The "joystick" was a single axis input for a mining throttle in Star Citizen.
@@chrisreynolds6331 That's awesome, Tasmota is really cool for tasks where you don't want to write your own application code from scratch. My builds are fairly specialized though so I'm writing code for them in Rust with ESP-IDF. I can deploy my code to the ESP32-C3 with a simple `cargo espflash --release` command
A cheaper relay can also be used, as long as a simple soft-start circuit is being used.
Either with resistors or with a NTC, to bring down the inrush current.
Downside is that it will take a little longer for the devices to get needed energy to power on.
0.7W of standby consumption per outlet is a lot, mate.
Some people have solved this problem using one of the aforementioned relays, but also ensuring that the switching occurs at the zero crossing point in the AC waveform. Though with switch bounce being a factor, it might be worth measuring how long the bounce effect occurs for your given relay before trying it.
One thing I was surprised you didn't mention was proper derating for relays depending on anticipated load type.
One of my pet peeves about these sorts of "smart switch" things is that they generally use the cheapest relays they can get away with, which means they are also not derating them properly. If the switch claims it supports, say, 10A, they actually mean that only for *purely resistive loads.* (and sometimes it may even say that somewhere in the fine print, but often not) For any other types of loads it will only be able to handle a fraction of that without eventually failing.
If you are switching inductive loads (like something with a transformer), you really need your relay to have twice the current rating. If you're switching motors, it should be around 4 times. If you're switching "tungsten" loads, such as incandescent lamps, the relay should actually be rated for somewhere around *8 or 10 times* the nominal current in order to actually reliably function and last properly over time. Since these sort of "outlet switch" devices could theoretically have all kinds of different loads plugged into them, and you can't know what the user is going to try to switch, you really need to design conservatively, IMHO, and should usually be substantially oversizing your relay specs to be safe.
You also really should design your circuit with some thermal protection to detect if the relay gets too hot (because somebody's plugged too big a load into it, or because its contacts have degraded over time so it can't support as high a load as it should be able to). Most commercial products place some sort of thermal fuse right next to the relay to detect problems and cut out before things get so toasty that they start melting things or burning your house down.
For the massive wall of text you wrote, it's weird that you end up contradicting yourself. A tungsten lamp is a purely resistive load. Meaning 25 regular bulbs would be what they expect you to use.
Well in general these are intended to smarten up lamps. They don't expect people to use them on their ac or fans because they think you should normally have that installed and not plugged into an outlet. They're made in China they don't think people live in decades old buildings in Europe.
I don't know what you're trying to control through these but it just wasn't intended for that, i don't think it's really the fault of the specs they report.
@@SquintyGears No, that's a common misunderstanding, but a tungsten lamp is *not* a purely resistive load (at least the way the term is typically used in electrical engineering). This is why if you look closely, many components like switches will have a separate "normal" wattage limit and a (much lower) "tungsten" wattage rating listed.
The reason is that the materials that incandescent filaments are made out of actually have a resistance that varies depending on the temperature. When they are cold (right after turning on), they actually have a fairly low resistance, and it's only as they warm up (and start glowing) that they settle down to their nominal resistance/wattage. That means that at first, they will actually pull substantially higher current (10 times or more) when they're initially switched on than they do after they're fully "on".
So any components designed for switching "tungsten" loads like incandescent bulbs really need to be designed to handle substantially higher instantaneous currents than one would expect from the nominal wattage of the bulbs themselves.
(And in my experience, people often do put these sorts of switches on things like pumps, fans, even sometimes things like refrigerators, etc, and then usually get annoyed when they fail after a few months of use, even though they never exceeded the power ratings the thing claims it's supposed to be able to handle...)
@@foogod4237 a variable resistor is still only a resistor. I'm not confused about that part.
I guess i see what you mean, they don't include the burst rating of the first 5s of short circuit current from turning on cold.
That's the source of the arcs. That's why the contacts fuse.
But shouldn't that only covers the material choice? because 5 bulbs doesn't trip anything pulling double breaker limit during the warm-up.
@@SquintyGears A typical "40 watt" tungsten filament bulb (120 volts) has a cold resistance of about 28 Ohms. If you apply 120VAC (0% THD) at 90deg phase angle, the peak applied voltage is ~170V. This means the peak power for a couple milliseconds (plenty of time for bouncing and sparks) is about 1kW. Averaged over the first half-cycle (8-10ms) it's still 500W. After many cycles the wire temperature and its resistance has increased to ~360 Ohm, so the average power dissipation is now 40W.
Circuits don't "trip anything pulling double breaker limit during the warm-up" because breakers are designed with a time delay. Mechanical ones use a bi-metallic strip that (like the tungsten filament) takes time to warm up. Fancy new electronic breakers basically emulate this with a time-constant or i^2-t implementation.
@@SquintyGears I think your confusion is that "pure resistive load" actually has a specific meaning in electrical engineering, and it doesn't just mean "there are resistors involved". It actually means a load which behaves exactly the same as if a single, standard resistor were put in its place (that also means the resistance not change value over time, etc).
The reason that tungsten loads don't generally trip circuit breakers, etc, is that the current spike is for only a brief moment when turning them on (it's actually only a fraction of a second, not even anywhere near 5s), and most breakers and fuses are actually designed to be fairly slow-acting (partly for this reason). This can cause a problem, though, if for example somebody replaces a regular fuse with a fast-blow type fuse in circuits involving incandescent lights, etc, because those often will blow in that situation when the more common slow-blow fuses won't.
Great project! You should remove ground plane copper below ESP antenna
i learned that the hard way
How about having the antenna at the edge of the main PCB, even hanging over the edge?
In next revision you may consider a better placement for the poor antenna of the esp8266, as I'm not sure it would like that big ground plane around it 😀
Was going to say the same thing! Follow their guide on it. I place mine at the edge of the board, and have the PCB vendor rout out the PCB under the antenna. 15mm clearance on either side I think is in the guidelines.
I think the reason the small transformer distorted was because most mains transformers saturate a bit with no load. That's the same phenomenon that makes old school power supplies warm
why exactly is it a problem to put the current measurement IC on the mains side and isolate the SPI? You anyways have mains voltage in there and the transformers seem like a ton of added build volume and BOM cost.
Scott, I got some threaded, silver tipped contacts, from a big brother of the relay, which was a contactor, and it was made for a large DC drive motor from some warehouse transport equipment. I used these for my welding earth ground as they were much more conductive than the copper plated steel ones that were standard on a battery charger clamp. These were for my "new" flux core welder.
It was a heavy clamp with a rubberized coating, and was replaced with a newer clamp, but wasn't worn out. I ran a tinned braided copper cable from the welding lead end which were both attached at the jaw on one side. I then secured this with a contact stud from the former contactor behind the back of the pivot inside the grip, around to the other jaw of the clamp. Then I attached a silver contact on this side as well. It was a fair substitute for a proper earth ground, and will work until I find a suitable replacement.
The contacts are proud in the clamp, and have a good "bite" on the steel thanks to a good spring.
Great work again!
You can add a small transistor circuit to switching the coil to a lower holding current to make the circuit more power efficient. Since you were concentrating on improvising the design, you could have included low power considerations also for the electronics.
yes ! this just solved my curiousity !!! i know them are Planned Obscolescence as i bought 4 of them and they just dead and yes, they have that pop sound always
Why bother with the galvanic isolation? The whole system gets encased in plastic anyways. Maybe without the transformers you could have made the pcb small enouth to fit in the original case. I only see a reason for the isolation while you are develpoing the curcit / software
You not only get the safety aspects but if there is trouble on your mains side then the extra isolation will make it harder that the circuit will suffer on the lower voltage side. But then again like you said, without it you can make everything much more smaller and cheaper. But my focus here was safety and reliability.
@@greatscottlab I think you've done a good job there. My final concern, though, is that the 3D-printed case is not fire-rated/self-extinguishing, so if things get to exciting in the mains side, well, you know. Great depth on all the electrical stuff, though. Always enjoy your videos for that.
Why not just replace with ssr.
Theres plenty of deemed safe relays on the market though and you probably have a bunch in your house in appliances.
And of course, as in the datasheet, the esp side will be isolated anyway through optocouplers and such
@@PatrickRigney You can print it from material which had self-extinguishing proprieties. Some even have tests according to UL94 and if you are willing to pay, you can buy UL certified materials.
Nice Job. Consider switching the relay at the zero crossing of the mains (since you are measuring the voltage). That should dramatically increase the life of the relay.
Zero crossing is 120 times per second and relays are mechanical. I used such a detector for triacs but a relay? Iffy.
@@bansheedearg It could use a triac to switch the load directly.
@@bansheedearg Good Point
@@bansheedearg
100. He's not in North America.
@@bansheedearg doesn't have to be perfect, triacs detector is used to rearm the triac for every cycle but for relay you only to do it once every switching. even if you miss the timing by 3ms you still subject to ~30% voltage which creates smaller spark
Great project! I had no idea how much extra work went in to voltage and current monitoring. I wonder if it would be possible to precisely time the relay turning on and off to match the current waveform you showed. If you were able to reliably switch the relay at the 0 point of the current cycle, then theoretically you wouldn't have to worry about arcing or welding of the contacts.
Definitely worth a try :-)
I was going to mention the same. Mr Carlson's Lab did a similar upgrade on a refrigerator light that used a zero crossing circuit to prevent the inrush/arcing. It didn't use relays but could probably be used as a starting point.
Just use a zero crossing SSR.
Next time you may want to use cutouts between your low voltage part and the mains voltage part on the PCB to get the insulation voltage up and prevent creepage paths on the pcb
why exactly is it a problem to put the current measurement IC on the mains side and isolate the SPI? You anyways have mains voltage in there and the transformers seem like a ton of added build volume and BOM cost.
I am 100% with you - I recently replaced all my cheap boards I bought on Ali (with blue relays, SONGLE) that were almost all sticky, to the new ones - FANHAR - and these are with AgSnO2. Btw good companies use exactly FANHAR relays. It is not easy to find the 5V ones (black, FANHAR) but I back ordered 100 pieces on LCSC. And the cost of FANHAR is just about 0.5$/piece
P.S.
your solution is kindly 4x more expensive than the good sockets i.e. from Athom and they use AgSnO2 relays, that are also providing power measurements and are based on ESP so super easy with ESPhome
I've been thinking about this for some time but have not built anything yet. Some ideas I've been toying with:
1. Make a multiway strip. That way you avoid duplicating the LV power supply, the voltage sensor and the controller chip. Plus you put less burden on your WiFi router. Plus you can build in value added functionality like turning off peripheral power supplies when the main device power drops to standby level.
2. Use latching relays. That way you avoid consuming current to hold the relays on. These relays have gotten surprisingly inexpensive.
3. Use a hall effect sensor for current measurement. It ought to be possible to build this like a miniature clamp meter on the PCB. Intrinsically safe and should be much smaller than a current transformer.
4. Zero- current switching. If sensing AC current you can delay opening the relay contacts until the zero crossing of the current waveform to eliminate arcing. Also may be worth closing the contact on the zero crossing of the voltage waveform.
5. Genuine zero-power standby. This could be done with a super capacitor and push-button for wake up. Maybe even a solar cell and an IR transmitter for cordless remote.
Ok, I'm curious... Scott, what are your thoughts on solid state relays?
I've used some DC driver solid state relays on arduino projects, on the theory that solid state won't weld contacts, I know AC driver solid state relays are a thing, but I've never used them.
My exactly same thoughts.
One thing to note that usually cheap relays are specced to AC currents or to a rather low voltage resistive load. In your tests you kinda have a capacitive load in DC.
It's a great educational video! I just wanted to share a data with you, you might know also that the enclosed air-tight relay are basically spark-protected by its design. Inside the air-tight encloser, their are no Oxygen available to make a spark/fire. Because the fire triangle is broken here. That's why it's fill with some inert gas like N2, it may be welded together if really high current passes through the contact point(Over 2-3 times of rated current).
I think you have some misunderstanding of the basic physics of electrical arcing. Electrical arcing is not actually fire, and it does not require oxygen (or any combustible material) to occur. What you see when electricity arcs from one contact to another (and what causes much of the damage) is the ionization of the gas molecules into an incandescent plasma. This can happen with any gas, even completely inert ones (this is actually the same thing that happens (in a controlled way) in flourescent and neon lamps, etc, which also have no oxygen in them).
Removing oxygen can prevent oxidation of the relay contacts (which can lead to high resistance and relay failure), but it does not prevent the arcing itself, nor does it prevent the high heat of the arc which is what results in relay contacts ultimately fusing and sticking together in these sorts of scenarios.
Also, hermetically sealed relays are actually not that common, and are usually substantially more expensive. Most common relays are not actually sealed in any way that can keep oxygen out to begin with.
@@foogod4237 May be you are right...
The 3d printed mains enclosure concerns me. There are many considerations given to fault containment and flammability in rated (UL) enclosures that may or may not be covered by a print. Many (most?) molded enclosures are ABS or polycarbonate same as could be done on a 3d printer, though I was under the impression that they have flame retardants added. *After a quick search you can in fact buy flame retardant ABS filament, neat! That being said, there are no shortage of sketchy, unlisted devices that don't end up burning your house down, so in all likelihood it's probably ok.
There're some other filaments out there. For example INKRAYON Glass (PEN-PET, like PETG), UL94V-2. Sometime you can get it for a very low price on ebay(DE/EU). But's transparent.
@@deterdamel7380
> But's transparent.
For some of us, that's an improvement :D
@@nagi603 Yes, we have nothings to hide there. And the color of this filament is very nice, too.
I've been uninstalling some smart switches I put in 5 years ago that have all stopped working, and I'm seeing here what probably happened to all of them. Thank you for your endless creativity and educational efforts.
Great project 😊
And happy to see that we can also repair the cheap smart sockets with a better relay.
I think a awesome project could be to do that with each port of a power strip
@Annette Singleton Steele i prefer to invest in drugs
Hi @GreatScott! , one way that I found that can help improve the relay sticking problem is using a zero crossing circuit to turn on or off the relay at the zero voltage of the sine wave of the main voltage, I believe the IC that you used have that functionality and improves a lot the arc problem ;)
Know I finally understand why so many remote controlled sockets dies and I needed to open the socket box and replace the relays ! Thank you !
There is one thing you could add also to such a divice, called zero point switching!
It´s used in modern impulse switches and stairwell relais!
Problem with modern contact materials are that the use of beryllium copper was baned some years ago, until then such problems where more or less unheard of!
Nice work. You could as well keep the old relay but add an NTC resistor in series with the load. This eliminates the inrush current capacitor charging problem. I did it with one nasty socket some years ago and it is still going strong.
Very cool! Will you be sharing the BOMs and Gerbers for this project? My preferred smart socket is completely sold out, but I need more of them. Also, an inline cable design might be cool.
Yes. Of course. I will share all the information. Coming soon😁
I only have one concern. As you said in the video we are dealing with mains voltage. There are codes and standards the normal manufacturers have to follow. Depending on the country you live in, it may not be up to code.
Oh, I thought the solution will be solid state relays. But, as it wasn't the case I learned something new about relays. Thanks Scott!
A solid state relay as 1-st phate of turning-on and after it should be crossed by a normal relay. Well, there is already 3.3V PSU, so why can't be used both? Pretty simple in my opinion and NO sparks on connect (on disconnect - still possible - need tests).
@@Alan123456789876543 on disconnect just turn off normal relay, and then solid state. Agree with you, this will work.
You made a video about something I've been exploring over the past few weeks. Fantastic job and a great project!
Glad you liked it!
@GreatScott! I went trough this too. Realized that the sockets are built to a cost not a high standard. Id thought about moding them for higher load but the reality is they already sell them if you look hard enough on google & are willing to pay for it. Would also point out Outdoor smart plug applications tend to have the internals were after
Don't forget that smart sockets also have their own, always on, power draw!
I thought you'd have gone with a solid state relay too.
by the way since you're already monitoring mains you could also make your relay switch in a very low current part of the waveform to extend its lifetime even further (this would also prevent arcing on disconnection of inductive loads for example, not necessarily catch _all_ the inrush current though, but should definitely make it "nicer" / less spikey).
Very interesting and useful project!
I have a small question - can a solid state relay be considered over electromechanical for longer life and compact design?
Yes. Should work longer. But also is a bit more inefficient since it comes with a voltage drop of 1V to 2V.
@@greatscottlab Thanks for replying!
That's a good point to consider ☺️
What about using a solid state relay? What do you think about this kind of solution?
pro tip: place the wireless module so that no power plane fits under its antenna
the modules' datasheets often have a small chapter on this topic ;)
I have for many years done service on ultra low temperature freezers. The main problem was sticky relay contacts for the compressors duty relays.
The worst working relays was with long contact legs and two poles.
The speed and torque of the switching is so important.
In the last 15 Years s the relays was changed to a single pole Potter and Brumfield that never let me down. Those small 25amp had one big diameter curved contact side and the other a smaller that rolled a little to the side on every action. The duty cycle of every 15 minutes 24/7 and never made a failure. The sugar cube sized beauties was awesome in function. The ones to try on heavy load and frequent duty😊
6:53 I'm a bit confused- does the current transformer do anything else other than act as a way to meter the current?
You can add solid state relay in parallel with mechanical one, and turn it on just a moment before mechanical. You'll get: 1) guaranteed turn on when voltage will cross zero 2) shunted relay contacts, that will significantly increase it's lifetime because of no sparks 3) low resistance and no heat comparing with stand-alone solid state relay
Great Scott to the rescue again✨
Always!
Hello from Frankreich !! Once again a GREAT job 👌 I like your approach of problem and your methodology to resolve them. Thanks for sharing your thoughts, projects and tips !!
Thank You for the Pix-elation! After all, this _is_ a Family Oriented Channel. 🤣😂🙂
I had built an ESP8266-01 4 channel relay controller board for 220v ac appliences last year. It has been 1 year+. I use it daily, controlling Fan rated 80W, LED Tube light rated 25W, A Lamp rated 20W and a small dim bulb of 2W. No problems found yet, best of all they don’t stick in my case which might be due to low current consumption of appliences.
Sounds like a useful project :-) Yep. I think the power draw is too little to cause sticking.
Thanks
Thanks for the support :-)
I did this by simply buying a $1 power socket and rewiring it to a hlk relay and ESP breadboard. Would love to see you redo it that way with your circuit
DIY *AND* buy seems to be the winner here. Just replace the relay in the original socket.
Great Smile implies Great DIY Project. Good Job GreatScott!
You are creative I salute you for this wonderful work✅✅
Thank you! Cheers!
I love your channel and the way you explain things in detail. I built a spot welder one time, and had the high power switching turn on at the zero crossing point so there was no current flow on switching and no arcing. I am surprised you did not do something similar.
Thyristors would make sense. As easy as switching a transistor and relatively cheap with high current capabilities for their size
They are more inefficient.
(note: I do too)
Great video as always, been watching your stuff a lot recently and although I understand 10% of it I love 100% of it.
Amazing as always. Greetings from Argentina.
What about replacing the mechanical relay with a solid state one?
I really appreciate your efforts and I like this video. Creating independent solutions for the proprietary smart home jungle could not be honored enough but for the comparison the time for the design process of circuit, board, case and the documentation needs to be taken into account. Feature wise your solution is far more advanced but even if you only add only 40h of development time in total (which is surely not that unrealistic) economically your solution sadly won't be able to compete with the commercial product in my opinion.
Yeahh....it is not very cheap.
@@greatscottlab Please sell these!
@@greatscottlab There is a market for something like this. The Tasmota smart bulbs (which can be re-flashed to ESPhome if one wishes) cost 2-3x more than the Tuya ones but people do buy them. The market is smaller, because the average person does not consider the security implications of using the multitude of "no hub" smart home apps.
Hey, i have a different issue regarding such smart sockets: It occasionally trips my circuit because of various power supplies in the circuit. Wouldn't a solid state relay solve the issue and why didn't you use one?
They come with a higher voltage drop. Around 1 to 2V. This makes them less efficient.
I thought it gonna be solid state relay switching at the zero crossing of the mains. It would be also beneficial in scenario where you have 5 PSU under one socket. It popping 16A circuit breaker if you hit peak mains voltage when turning on. Great job with DIY smart socket :)
I would love to see your comparison between what JLCPCB offers in 3D printed parts and what you can create at home. I have used their 3D printed parts in the past and I am quite happy with them, especially compared to the quite a bit lower quality of the parts from my own 3D printer.
I’ve done this too where I need a hard wearing part, print in PETG on my Ender and order it online in Nylon once I’ve tested my prototype works/fits well
It's amazing how many problems are solved with a well placed smack :)
What about a solid state relay? I don't know much about how they work or if they could handle the current but seems like it wouldn't wear out.
Cool project!
indeed. Maybe even with a mosfet but the problem is main power isnt decoupled from the electronics.
Awesome Work! Thank you for sharing! :)
On a side note: Something that popped into mind is that you may be able to extend relay life by creating a zero crossing circuit. Maybe that could be a future video topic? :)
Stay Creative! :)
I can put it on my to do list :-)
I actually thought this video was going to be about zero-crossing switching. A little annoying to tune the timing, but once you have the contacts closing at less than 10-20V, there's essentially no chance of welding. I'd be interested to see how disconnecting works. I made my circuits open at zero-cross as well, but I never really knew if it had the desired effect.
@@samuraisystemsllc The problem with zero-crossing on open is that you actually need to open at zero _current,_ not zero _voltage._ With purely resistive loads, they will be the same, but many types of things people plug into outlets are not purely resistive, so you need to be able to account for a (often unpredictable) offset between voltage and current zero-points.
It also doesn't necessarily help that much if you have inductive loads, due to back-EMF, etc, which can still produce voltages across the contacts far higher than the relay is designed for, even after they're fully open. For this sort of concern, something like a MOV in parallel with the relay is usually an easier and more effective way to deal with the issue.
Just one reminder since GreateScott didn't say it: Check if you are legally allowed to connect any stuff to mains voltage you build yourself. In Germany, you are not allowed to connect anything to mains that has not been tested and certified before. Even if you are qualified, you are not allowed to connect stuff you made directly to mains, because of insurance reasons. If you find a company that tests and verifies your stuff and is liable with their insurance, you can choose the DIY way. So "buy" is in the case of mains voltage devices always the win, at least in Germany.
How sensible, yet boring.
If you are qualified at the level where you could actually certify the work of others , then im guessing it is not a problem. Im not sure whether you are required to have that insurance then, but most people do.
Okay.. looked through the Video, load Patreon, downloaded the files, send JLCPCB a new job to make me 50 of this PCB´s, Ordered all parts direktly after that.. now i am waiting and just loving (as always) your videos.
Can´t count how often you make a video and my online thoughts are "i need to build this too".
It started a few years back and is still going strong today.
Thought i contaced you one time due to a mistake i made..(?)
Great video and top build again. Keep it up :)
Thanks for the feedback. Glad I inspire you :-)
Hey, nice video! A solid state relay would also be an option in this case
specially if it has a zero crossing detection ckt built in
I haven’t read all the comments, so someone have suggest this. Do zero crossing switching. That is only open or close the relay when the line voltage/current is zero. May require additional sensing circuitry but the esp32 could be easily programmed to add this function.
What about using solid state relays?
You need to open/close the relay when the AC voltage is close to 0, that way you avoid the sparks.
You'd also want the current to be zero. Which, depending on the load and would either lead or lag the voltage. Adding ESD protection like an MOV (Metal Oxide Varistor) would probably work better.
Coming here to post the same, a simple zero crossing detector is what would be needed. I’d go through an optocoupler and tie the output to an input pin on the esp. I’d say an interrupt, but 60/50Hz is slow enough to sample, or enter a subroutine that only samples rapidly during a switch on/off mode. @dminting, yes, PF is something to consider and would be load dependent. Though, it wouldn’t be a problem on power on since current = 0. And if we’re only considering inrush, it wouldn’t be an issue on breaking the circuit. Now, monitoring on disconnect, you could sample the current with a current transformer and do zero crossing that way, or, in theory, even with a bad PF, the operating current shouldn’t exceed the relay current rating.
These Hilink power supply modules are quite bad for EMI in my experience. We use them in a commercial product we designed and even with the recommended filter and protection circuit (common mode choke, class x and y capacitors, movs, ntc) it's still radiating quite a lot. Thankfully the board is in a metal box and that keeps the crap inside for the most part.
In the past we used Meanwell power modules that are slightly bigger, way more expensive, but had all the filters inside and were rated for medical applications (super low EMI). Think you should consider those for a future revision, they're bulletproof.
That's just brilliant, dude! Fantastic work! 😃
And this way you can get data for almost everything in the house!
Anyway, stay safe and creative there! 🖖😊
Hey Scott! It's "Next Time"!! 😄😀
I have had great luck with my Kasa smart outlets, after 4 years of use i haven't had any issues.
...But I am only running lights and lower power items.
I have one on my window AC, no issues so far but good to know I should keep an eye on it.
They are $20 USD each so definitely more expensive.
I try not to cheap out on something that controls mains power in my home.
Nice project. I also worked on a solution like this for years. So I think your solution is safe and the pirce is ok. But I think your standby power consumption is about 1-2W? Maybe you show us the disadvantage in a future coming video?
You could also have used 3.3v relays instead of 5v ones and use the HLK-PM03 as power suppply, then you wouldnt have to add the 5v to 3.3v part
this is so cool! i really tired of crappy sockets from aliexpress. most of the time they are non-esp so can't be reprogrammed with tasmota or similar. sometimes they just don't work or work only via Chinese cloud. the idea of opensource reliable wifi socket is flying around for years. i really glad that somebody finally did the good job on it. btw 3d printed case is amazing too!
Why not use SSR relay instead of normal relay? You can easily make one using optocoupler and triac
You can even use said ssr as power/speed regulator
Using Shelly 2.5 relays in all of my relevant sockets works for over a year without any issues yet with daily switching cycles.
I know right, and they also have the PM switch models. My Shelly Plug-S also measures power consumption and is only a small fraction of the size of the wireless relay built here. And it can handle 10 A at 240v while also being able to set a current limit/maximum power limit.
Nice project, thanks for sharing!
Only thing I'd like to ask is the power consumption figures - it seems that the W and VA values for both states are transposed? Or have I missed something? (@ 11:39 in the video)
Another way to prevent the massive inrush is with a Triac in parallel with the relay. You trigger the triac a few milliseconds before the relay so that the inrush current starts to be handled by the triac and stops the relay from arcing, but also having the low on resistance of the relay.
Also, I understand why you used the Voltage and Current transformers for power measurement, but personally I would have just used the pure resistive methods to lower bulk and cost. The PCB will 99% of the time be in it's enclosure so it will be safe.
I was thinking about making a comment along the lines of your second idea there. If you're building this device for the sole purpose of not needing to replace or service it for long periods of time, and the only electrical contact it has with the outside world is through mains voltage anyway, then a capacitive dropper and direct resistive measurement should be fine. Also, your first idea is great! I hadn't thought of that. It's just like how high voltage DC transmission circuit breakers work by using a metal contact as the "running" link and using solid state relays as "breaking" links to prevent megavolt+ arcs from annihilating the countryside.
That last b-roll of the opened socket gives a new meaning to "german quality".
Ralph S Bacon's video #131 also goes over the relay damage and sparking and how to fix it using the snubber. Worth checking out.
10:58 - what does the last T in THT stand for? SMD = Surface Mount Device, right? TH = Through Hole, so what does THT stand for?
such a cool concept for a series as I think the same way
How about adding a software feature into your design to only switch on a mains zero crossing. If tuned to switch on the lowest current that would reduce the sparking completely.
not possible with mechanical relays as the closing/opening time is not perfectly predictable. there are solutions for this. also he was testing with DC switching, AC switching is completely different.
I'm curious? Why not use a Solid State Relay? One would think that this would eliminate the arcing-relay sticking problem and would last forever?
They are more inefficient. Produce more heat.
Really awesome project and the result was great! I did not know about the relay sticking!
Glad to see you are finally use your DIY T12 Soldering Station :)
Great topic.
This "fragility" is part of planned obsolescence...
I made my own system a few years ago and it still works great.
Here in Brazil people have been doing home automation with low quality "smart devices" without worrying about safety and this is dangerous.
Finally 😢😢 A DIY winner
Great video ad always. Would have liked to see an explanation of a diode across the relay to decay the avalanche properties of the coil discharge.
I talked about that in previous electronics basics videos ;-) Check them out
very good explanation, I revisit this video again after studying Ugreen power strip teardowns on a Chinese website, apparently Ugreen uses the relay that has AgSnO2 as the contact material as you explained to reduce sticking, thus I know they do care about quality.
Cheap relays can be used as long as there is a snubber circuit between the relay contacts. I will only recommend an NTC thermistor in parallel with a timer-relay if the load has a high inrush current.
Note that the capacitor may act as a short when power is applied barely powering the load.
Isn't possible to delay the activation of the relay (either on or off) to the zero voltage of AC line (or just before as closing in the circuit, depending on activation time) ? This way no arcing and far than acceptable "response time" AND low consumption. I wonder if it won't be possible to do it with some cheap electronics too.
Of course extendable with an appropriate relay but this time you can focus on conductivity alone (and having a high thermal conductivity gaz into it -He- plus some metalic enclosure (AL would be the best) would help the life time.
=> I also experience issues with relays as I'm currently living in altitude and they seem to not like at all the cold temperature we can have here and they solder themself a lot in the outside.
=> Had some really high thermal high spot with a thermal camera on the relay inside an hybrid solar inverter (wks), in the command part. It was far hotter than the rest of inverter even during high load times. It both scared me AND worried me about it's efficiency and lifetime. Sometime relays are somehow hungry and I wonder if there are some out there that have a far less consumption.
The relay isn't fast enough
@@AgentOffice i guess you replied to the wrong person
Hello sir, I remember that you have introduced how a zero-voltage crossing detecting circuit[maybe isn't explained like that in English, I apologize] works and you also used it for solving the surge current problem from your big variac, I guess that principle would work on this relay sticking problem, isn't it?😃
In fact no. The relay is not fast enough.
If you know roughly how fast the relay switches I don't see why you couldn't time it. In a simpler circuit that's impractical but he's got a whole ESP there.
0:40... Oh boy does that bring back memories 🤣
Had to un-weld an industrial relay at work one time... 600V, 200ish Amp... it welded...
Took a big screwdriver and juuust a bit of a hammer tap. 🤣
With the power monitoring, is it possible to add a programmable fuse and/or current limiting feature??
that would a very interesting video??