Author Topic: ESP8266 with relays  (Read 2437 times)

0 Members and 1 Guest are viewing this topic.

Offline GabrielTopic starter

  • Regular Contributor
  • *
  • Posts: 66
  • Country: au
ESP8266 with relays
« on: December 26, 2018, 06:57:27 am »
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
 

Offline IconicPCB

  • Super Contributor
  • ***
  • Posts: 1546
  • Country: au
Re: ESP8266 with relays
« Reply #1 on: December 26, 2018, 07:19:05 am »
Gabriel,

Make Q1  SMD .
Shift Q1 and the capacitor from top side to solder side.
 
The following users thanked this post: Gabriel

Offline saike

  • Regular Contributor
  • *
  • Posts: 74
  • Country: gb
Re: ESP8266 with relays
« Reply #2 on: December 26, 2018, 07:26:00 am »
If there is a connection from the voltage regulator output to the rest of the circuit, I can't see it
 
The following users thanked this post: Gabriel

Offline GabrielTopic starter

  • Regular Contributor
  • *
  • Posts: 66
  • Country: au
Re: ESP8266 with relays
« Reply #3 on: December 26, 2018, 07:29:11 am »
Gabriel,

Make Q1  SMD .
Shift Q1 and the capacitor from top side to solder side.

Ok, thanks for the tip. Any suggestions on what transistor to use instead of the 2n2222?

If there is a connection from the voltage regulator output to the rest of the circuit, I can't see it

You are right, god I'm dumb...
 

Offline semir-t

  • Regular Contributor
  • *
  • Posts: 64
  • Country: ba
Re: ESP8266 with relays
« Reply #4 on: December 26, 2018, 07:31:26 am »
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_diode

more info: https://electronics.stackexchange.com/questions/93452/correct-use-of-flyback-or-snubber-diode-across-motor-or-transistor
« Last Edit: December 26, 2018, 07:36:08 am by semir-t »
 
The following users thanked this post: Gabriel

Offline GabrielTopic starter

  • Regular Contributor
  • *
  • Posts: 66
  • Country: au
Re: ESP8266 with relays
« Reply #5 on: December 26, 2018, 07:43:03 am »
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_diode

more info: https://electronics.stackexchange.com/questions/93452/correct-use-of-flyback-or-snubber-diode-across-motor-or-transistor

Yeah you are right. So I would just use a general purpose diode (rectifier diode)?
 

Offline semir-t

  • Regular Contributor
  • *
  • Posts: 64
  • Country: ba
Re: ESP8266 with relays
« Reply #6 on: December 26, 2018, 08:48:26 am »
Yes, you can use general purpose diode.
 

Offline GabrielTopic starter

  • Regular Contributor
  • *
  • Posts: 66
  • Country: au
Re: ESP8266 with relays
« Reply #7 on: December 26, 2018, 09:12:07 am »
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
 

Offline picandmix

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Re: ESP8266 with relays
« Reply #8 on: December 26, 2018, 09:32:06 am »
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.
 

Offline GabrielTopic starter

  • Regular Contributor
  • *
  • Posts: 66
  • Country: au
Re: ESP8266 with relays
« Reply #9 on: December 26, 2018, 09:44:23 am »
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.

It 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?
 

Offline picandmix

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Re: ESP8266 with relays
« Reply #10 on: December 26, 2018, 10:15:15 am »
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 voltages
https://www.allaboutcircuits.com/technical-articles/safety-capacitor-class-x-and-class-y-capacitors/
 

Offline Finder

  • Supporter
  • ****
  • Posts: 14
  • Country: fi
Re: ESP8266 with relays
« Reply #11 on: December 26, 2018, 10:22:44 am »
It will be switching mains voltage.

You need to increase the isolation between circuit ground and mains. Or even put some slots.
 

Offline CCB

  • Supporter
  • ****
  • Posts: 17
  • Country: nz
Re: ESP8266 with relays
« Reply #12 on: December 26, 2018, 10:26:57 am »
Mounting holes?
 

Offline GabrielTopic starter

  • Regular Contributor
  • *
  • Posts: 66
  • Country: au
Re: ESP8266 with relays
« Reply #13 on: December 26, 2018, 11:01:52 am »
Mounting holes?

Done :)

It will be switching mains voltage.

You need to increase the isolation between circuit ground and mains. Or even put some slots.

How much isolation do I need (or should I have)? Is 0.5mm enough?
 

Offline GabrielTopic starter

  • Regular Contributor
  • *
  • Posts: 66
  • Country: au
Re: ESP8266 with relays
« Reply #14 on: December 26, 2018, 11:16:26 am »
Ok version 3, (hopefully the final version)!

Thanks so much guys for taking the time to help a noob :)

I have added some mounting holes and I have increased the clearance for the mains traces.

Once again is there anything else (hope not),
Gabriel

 

Offline picandmix

  • Frequent Contributor
  • **
  • Posts: 395
  • Country: gb
Re: ESP8266 with relays
« Reply #15 on: December 26, 2018, 11:46:34 am »
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.

 

Offline hsn93

  • Regular Contributor
  • *
  • Posts: 114
  • Country: bh
Re: ESP8266 with relays
« Reply #16 on: December 26, 2018, 12:29:50 pm »
your mounting holes.. need clearance


screw head will touch your components.


Quote
How much isolation do I need (or should I have)? Is 0.5mm enough?
i would target 2mm if no distance 1mm.
look for "clearance vs creepage"
http://www.smpspowersupply.com/ipc2221pcbclearance.html
-------------------------------------
 

Offline GabrielTopic starter

  • Regular Contributor
  • *
  • Posts: 66
  • Country: au
Re: ESP8266 with relays
« Reply #17 on: December 27, 2018, 12:45:47 am »
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 a 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.



I'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.
 

Offline Nusa

  • Super Contributor
  • ***
  • Posts: 2417
  • Country: us
Re: ESP8266 with relays
« Reply #18 on: December 27, 2018, 03:52:03 am »
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.
 

Offline Nusa

  • Super Contributor
  • ***
  • Posts: 2417
  • Country: us
Re: ESP8266 with relays
« Reply #19 on: December 27, 2018, 05:54:29 am »
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.
 

Offline GabrielTopic starter

  • Regular Contributor
  • *
  • Posts: 66
  • Country: au
Re: ESP8266 with relays
« Reply #20 on: December 28, 2018, 09:08:13 am »
Ok so taking all that you guys have said into consideration I present version 4!
« Last Edit: December 28, 2018, 09:10:18 am by Gabriel »
 

Offline Nusa

  • Super Contributor
  • ***
  • Posts: 2417
  • Country: us
Re: ESP8266 with relays
« Reply #21 on: December 28, 2018, 04:52:08 pm »
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.
 

Offline Twoflower

  • Frequent Contributor
  • **
  • Posts: 742
  • Country: de
Re: ESP8266 with relays
« Reply #22 on: December 28, 2018, 05:10:48 pm »
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.
 
The following users thanked this post: hsn93


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf