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)
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.
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!
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.
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
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.
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.
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 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.
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! 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.
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.
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.
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.
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
@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
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.
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 ;)
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?
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).
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.
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.
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).
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!
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
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 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
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.
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!
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?
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
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.
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 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
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 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.
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.
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😊
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)
Did you ever take a look at the Shelly devices? Comparable to your DIY version, the Shelly plug S is also based on ESP32, works with home assistant, has a relay and voltage/current measurement. I am not sure about the used relay, but never had any sticking up to now, although I have multiple ones that are switched many times per day.
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
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 :)
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 am wondering if using a solid state device to (triac) that is only used when switching can be the best of both worlds. The semiconductor won't have time to get hot so it wouldn't need a heatsink. And the relay would never connect/disconnect more than the triac voltage drop. Or would de relay need a little spark to keep working? And what would the failure modes be?
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.
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?
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.
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.
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.
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, thank you for the video. I am inspired by your understanding of electronics. What advice would you give someone trying to pursue that journey without doing an electrical engineering course? Thank you.
What do you think about triac optocoupler circuits (deconstructed solid state relay) to control mains power? Smaller, silent, no sparking. I hardly see it used anywhere. I have my own DIY board with it and it works great (as far as I can tell).
I'm asking myself, why so many projects avoid the ACS7xx sensors in favor of chunky transformers. In this desgn, it should be possible to avoid isolation at all, if you take a propper isolation class for the actual device into account. The cheaper switches do so.
Silly thought - would it be feasible to have the esp detect the phase/frequency of the mains, and aim to connect/disconnect the relay at an A/C zero crossing with clever timing?
Is it possible to connect four CS5460A Power Measurement IC's to a single ESP32 controller to create a 3ph+N power meter? Would all four IC's use the same serial bus to communicate?
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
Since an ESP is switching the relais, would it be possible to just turn on the relais when mains voltage is 0V ?? Similar to a triac? Then you would never have sparks or an inrush current. Or am I missing something?
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.
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.
Hey Scott, you seem to be using JLCPCB for quite a while now. I was wondering if there is an option to order with the VAT and DUTIES/CUSTOM costs precalculated (EU). Cause really don't wanna mess with those procedures... Thank you for the nice tutorial.
Hey wanted to know did you make the breakout board for esp8266 yourself, if yes then can you share the schematic and layout design please. And if not then can you give some insights on how to do so.
I'm curious about the selection of R7 in the schematic for the current sense burden resistor. At a turn ratio of 1:1000, a 20 ohm resistance would cause a differential voltage at 30A to exceed 250mV differential voltage spec for the CS5460A chip. The resistance needs to maybe be like 8.2 ohms. Also I suggest looking at the upgraded CS5463 chip as a drop in replacement.
With the voltage sense and a micro, why not switch the relay on (or very near) zero crossing too? Wouldn't this minimize contact arcing and inrush stresses on the switched devices?
Lots of suggestions to use zero crossing, how well will zero crossing work if you have contact bounce and a dead time between de-energizing the coil and when the contacts actually open? Most likely relay and load specific.
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!
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 .
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.
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!
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
I love the way you introduce the topics, and how clear you speak!
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.
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?
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
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.
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.
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 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.
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! 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.
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.
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.
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.
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
@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
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...
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 ;)
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 ☺️
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).
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.
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.
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!
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.
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!
What about using a solid state relay? What do you think about this kind of solution?
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
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.
What about replacing the mechanical relay with a solid state one?
Great Smile implies Great DIY Project. Good Job GreatScott!
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 !
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
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.
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.
Thyristors would make sense. As easy as switching a transistor and relatively cheap with high current capabilities for their size
They are more inefficient.
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.
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
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.
Great Scott to the rescue again✨
Always!
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.
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 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
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 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.
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.
6:53 I'm a bit confused- does the current transformer do anything else other than act as a way to meter the current?
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😊
With the power monitoring, is it possible to add a programmable fuse and/or current limiting feature??
that would a very interesting video??
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)
Did you ever take a look at the Shelly devices? Comparable to your DIY version, the Shelly plug S is also based on ESP32, works with home assistant, has a relay and voltage/current measurement. I am not sure about the used relay, but never had any sticking up to now, although I have multiple ones that are switched many times per day.
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
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 :-)
Amazing as always. Greetings from Argentina.
You are creative I salute you for this wonderful work✅✅
Thank you! Cheers!
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.
Thank You for the Pix-elation! After all, this _is_ a Family Oriented Channel. 🤣😂🙂
(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.
I am wondering if using a solid state device to (triac) that is only used when switching can be the best of both worlds. The semiconductor won't have time to get hot so it wouldn't need a heatsink. And the relay would never connect/disconnect more than the triac voltage drop. Or would de relay need a little spark to keep working? And what would the failure modes be?
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.
What about using solid state relays?
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?
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?
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.
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.
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.
what test equipment did you used to test low resistance current with those red and black twisted wires? Analog or digital oscilloscope?
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, thank you for the video. I am inspired by your understanding of electronics. What advice would you give someone trying to pursue that journey without doing an electrical engineering course? Thank you.
What do you think about triac optocoupler circuits (deconstructed solid state relay) to control mains power? Smaller, silent, no sparking. I hardly see it used anywhere. I have my own DIY board with it and it works great (as far as I can tell).
Thanks
Thanks for the support :-)
Coul it be possible to make "soft start" or delay time, somehow, 220/240 AC power delivery, so relay would be "ready" with already connected contacts?
I am an amateur regarding electronics. For measuring current, could the Acs712 ic be used it is very small? As always a very informative video🙂
I'm asking myself, why so many projects avoid the ACS7xx sensors in favor of chunky transformers. In this desgn, it should be possible to avoid isolation at all, if you take a propper isolation class for the actual device into account. The cheaper switches do so.
It's amazing how many problems are solved with a well placed smack :)
Silly thought - would it be feasible to have the esp detect the phase/frequency of the mains, and aim to connect/disconnect the relay at an A/C zero crossing with clever timing?
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
love to see how much you enjoy making your video :D
your Great..Scott
Is it possible to connect four CS5460A Power Measurement IC's to a single ESP32 controller to create a 3ph+N power meter? Would all four IC's use the same serial bus to communicate?
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
When you have the voltage transformer would it not make sense to also make the relay sort or zero cross switch?
Since an ESP is switching the relais, would it be possible to just turn on the relais when mains voltage is 0V ?? Similar to a triac? Then you would never have sparks or an inrush current. Or am I missing something?
Finally 😢😢 A DIY winner
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.
DIY *AND* buy seems to be the winner here. Just replace the relay in the original socket.
Glad to see you are finally use your DIY T12 Soldering Station :)
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.
Hey Scott, you seem to be using JLCPCB for quite a while now.
I was wondering if there is an option to order with the VAT and DUTIES/CUSTOM costs precalculated (EU). Cause really don't wanna mess with those procedures...
Thank you for the nice tutorial.
Hey wanted to know did you make the breakout board for esp8266 yourself, if yes then can you share the schematic and layout design please. And if not then can you give some insights on how to do so.
Would using a solid state relay work effectively as well?
I'm curious about the selection of R7 in the schematic for the current sense burden resistor. At a turn ratio of 1:1000, a 20 ohm resistance would cause a differential voltage at 30A to exceed 250mV differential voltage spec for the CS5460A chip. The resistance needs to maybe be like 8.2 ohms. Also I suggest looking at the upgraded CS5463 chip as a drop in replacement.
With the voltage sense and a micro, why not switch the relay on (or very near) zero crossing too? Wouldn't this minimize contact arcing and inrush stresses on the switched devices?
Lots of suggestions to use zero crossing, how well will zero crossing work if you have contact bounce and a dead time between de-energizing the coil and when the contacts actually open? Most likely relay and load specific.
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
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!