ESP8266 with relays - Page 1
Forum section: electronics / projects

author: Gabriel
author_rank: Regular Contributor
timestamp: December 26, 2018, 06:57:27 am
content: Hi all,I have created this schematic for an esp8266 and a relay. I was wondering if I have got everything that I should and if I have overlooked anything.It is a relatively simple circuit I just wanted a second pair of eyes to look at it before I send it off to be made.I have also created a PCB, it is my first one that I will actually send off to be made so fingers crossed...Many Thanks,Gabriel

author: IconicPCB
author_rank: Super Contributor
timestamp: December 26, 2018, 07:19:05 am
content: Gabriel,Make Q1 SMD .Shift Q1 and the capacitor from top side to solder side.

author: saike
author_rank: Regular Contributor
timestamp: December 26, 2018, 07:26:00 am
content: If there is a connection from the voltage regulator output to the rest of the circuit, I can't see it

author: Gabriel
author_rank: Regular Contributor
timestamp: December 26, 2018, 07:29:11 am
content: Quote from: IconicPCB on December 26, 2018, 07:19:05 amOk, thanks for the tip. Any suggestions on what transistor to use instead of the 2n2222?Quote from: saike on December 26, 2018, 07:26:00 amYou are right, god I'm dumb...

author: semir-t
author_rank: Regular Contributor
timestamp: December 26, 2018, 07:31:26 am
content: You should put flyback diode between E and C of transistor or parallel to relay.link about flybackdiode and why we use it:https://en.wikipedia.org/wiki/Flyback_diodemore info:https://electronics.stackexchange.com/questions/93452/correct-use-of-flyback-or-snubber-diode-across-motor-or-transistor

author: Gabriel
author_rank: Regular Contributor
timestamp: December 26, 2018, 07:43:03 am
content: Quote from: semir-t on December 26, 2018, 07:31:26 amYeah you are right. So I would just use a general purpose diode (rectifier diode)?

author: semir-t
author_rank: Regular Contributor
timestamp: December 26, 2018, 08:48:26 am
content: Yes, you can use general purpose diode.

author: Gabriel
author_rank: Regular Contributor
timestamp: December 26, 2018, 09:12:07 am
content: Ok here is version 2. Thanks for all the suggestions!I re-did the PCB because I needed to add the diode and the transistor changed to an SMD one. (Also I was slightly boarded haha)Let me know if I did something stupid again.Gabriel

author: picandmix
author_rank: Frequent Contributor
timestamp: December 26, 2018, 09:32:06 am
content: Hi,There is no indication of what the relay is controlling or the voltage / current being switched, but if its a DC voltage you are better using a Logic Level Mosfet.Similarly if its main voltage, using a Triac or SSR module is generally better than a mechanical relay which causes a lot of switching noise that can affect the micro.

author: Gabriel
author_rank: Regular Contributor
timestamp: December 26, 2018, 09:44:23 am
content: Quote from: picandmix on December 26, 2018, 09:32:06 amIt will be switching mains voltage.SSRs are a lot more expensive and seeing as the micro is switching via a transistor and there is a separate voltage for the relay and the micro I think it will be ok. Can anyone else confirm or deny?

author: picandmix
author_rank: Frequent Contributor
timestamp: December 26, 2018, 10:15:15 am
content: Hi,To give a better answer can you say what type of load is being used and the approximate current.A pure resistive load like a heater will generally give less interference, while a more inductive load like a fan or solenoid can cause all sorts of issues, regardless of the relay being on a "separate" 12v supply line. ( I speak from experience on my own projects)If you stay with a mechanical relay then google "relay contact suppression" which will show what kind of components are best suited to reducing interference. Any such parts should be Class X or Y rated for mains voltageshttps://www.allaboutcircuits.com/technical-articles/safety-capacitor-class-x-and-class-y-capacitors/

author: Finder
author_rank: Unknown
timestamp: December 26, 2018, 10:22:44 am
content: Quote from: Gabriel on December 26, 2018, 09:44:23 amYou need to increase the isolation between circuit ground and mains. Or even put some slots.

author: CCB
author_rank: Unknown
timestamp: December 26, 2018, 10:26:57 am
content: Mounting holes?

author: Gabriel
author_rank: Regular Contributor
timestamp: December 26, 2018, 11:01:52 am
content: Quote from: CCB on December 26, 2018, 10:26:57 amDoneQuote from: Finder on December 26, 2018, 10:22:44 amHow much isolation do I need (or should I have)? Is 0.5mm enough?

author: Gabriel
author_rank: Regular Contributor
timestamp: December 26, 2018, 11:16:26 am
content: Ok version 3, (hopefully the final version)!Thanks so much guys for taking the time to help a noobI have added some mounting holes and I have increased the clearance for the mains traces.Once again is there anything else (hope not),Gabriel

author: picandmix
author_rank: Frequent Contributor
timestamp: December 26, 2018, 11:46:34 am
content: Hi,Not trying to put your design down in any way, quite the reverse, am trying to be helpful, so would urge you to first build a one off prototype of your complete design on some form of soldered wiring board before sending off for a pcb.Its so easy to miss something in your design and a test build connected to whatever you are powering will soon show up such potential problems, if any.

author: hsn93
author_rank: Regular Contributor
timestamp: December 26, 2018, 12:29:50 pm
content: your mounting holes.. need clearancescrew head will touch your components.Quotei would target 2mm if no distance 1mm.look for "clearance vs creepage"http://www.smpspowersupply.com/ipc2221pcbclearance.html

author: Gabriel
author_rank: Regular Contributor
timestamp: December 27, 2018, 12:45:47 am
content: Quote from: picandmix on December 26, 2018, 11:46:34 amI'm sorry if I came across rude to you... I was just trying to give the reasons behind my decisions.I have prototyped it out roughly and it all seemed to work fine. But I don't have the exact parts so its only approximately what will be going on to the PCB.

author: Nusa
author_rank: Super Contributor
timestamp: December 27, 2018, 03:52:03 am
content: Just remember mains aren't under your control. If it's 240V nominal, plan clearances for tolerating 1000V spikes as a minimum. They may only be microseconds long, but it doesn't take much to destroy your low voltage stuff if the clearance isn't there.

author: Nusa
author_rank: Super Contributor
timestamp: December 27, 2018, 05:54:29 am
content: Also remember to think in 3 dimensions. a 240V mains trace going under a surface-mount resistor isn't going to cut it clearance-wise.

author: Gabriel
author_rank: Regular Contributor
timestamp: December 28, 2018, 09:08:13 am
content: Ok so taking all that you guys have said into consideration I present version 4!

author: Nusa
author_rank: Super Contributor
timestamp: December 28, 2018, 04:52:08 pm
content: Clearance is needed on both NO and NC pins. They're both in contact with mains.I'd suggest swapping the pins the mains traces go to. Then they don't have to cross. And if they don't cross, you can put them on the same side of the board.

author: Twoflower
author_rank: Frequent Contributor
timestamp: December 28, 2018, 05:10:48 pm
content: I know your design is supposed to very dense. But I would try to remove any devices and the ground-plane below the antennae to improve the RF performance. Probably also move the ESP antennae closer to the edge.Also the power connector there won't help to increase the WLAN performance.Maybe even remove the planes below the relay. Yes you might have the minimum required clearance, but if you can increase the clearance: Do it!Check the thermal limits of the regulator. Assuming 100mA consumption (WLAN active, but it could be even 170mA): (12V - 3.3V) * 100mA = 870mW. Probably you need a heat-sink for that one.