Author Topic: Esp32 controls a 12v coil relay through PC817 and 2N7000  (Read 482 times)

0 Members and 1 Guest are viewing this topic.

Offline paoloros97Topic starter

  • Newbie
  • Posts: 3
  • Country: it
Esp32 controls a 12v coil relay through PC817 and 2N7000
« on: July 12, 2024, 07:54:43 pm »
Hello

I need to control a 12v relay with an Arduino nano ESP32.
Can somebody check if the circuit I designed is good?

Components list:
MOSFET: 2N7000
Optocoupler: PC817
Diode: 1N4007
Relay: 40.31.7.012.0000 (coil needs 42mA @ 12V)

Please find attached the picture with the circuit I made. (Updated 13/7/24)

« Last Edit: July 13, 2024, 02:54:34 am by paoloros97 »
 

Offline selcuk

  • Regular Contributor
  • *
  • Posts: 200
  • Country: tr
Re: Esp32 controls a 12v coil relay through PC817 and 2N7000
« Reply #1 on: July 12, 2024, 08:30:24 pm »
I guess D2 LED direction is wrong.
 
The following users thanked this post: paoloros97

Online Benta

  • Super Contributor
  • ***
  • Posts: 6056
  • Country: de
Re: Esp32 controls a 12v coil relay through PC817 and 2N7000
« Reply #2 on: July 12, 2024, 10:49:42 pm »
I guess D2 LED direction is wrong.

Agreed.

And don't use a 1N4007, but a 24...33 V Zener across Q1 instead.
 
The following users thanked this post: paoloros97

Offline paoloros97Topic starter

  • Newbie
  • Posts: 3
  • Country: it
Re: Esp32 controls a 12v coil relay through PC817 and 2N7000
« Reply #3 on: July 13, 2024, 02:43:16 am »
Thank you!

I did a mistake to place the LED in Kicad.

I uploaded a new schematics.

About the:
And don't use a 1N4007, but a 24...33 V Zener across Q1 instead.
may I ask you why?

thx
 

Offline kripton2035

  • Super Contributor
  • ***
  • Posts: 2653
  • Country: fr
    • kripton2035 schematics repository
Re: Esp32 controls a 12v coil relay through PC817 and 2N7000
« Reply #4 on: July 13, 2024, 06:52:51 am »
can someone explain to me the need for the pc817 ?
 

Offline paoloros97Topic starter

  • Newbie
  • Posts: 3
  • Country: it
Re: Esp32 controls a 12v coil relay through PC817 and 2N7000
« Reply #5 on: July 13, 2024, 06:58:06 am »
It's not really needed but good to have, IMO.
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 6056
  • Country: de
Re: Esp32 controls a 12v coil relay through PC817 and 2N7000
« Reply #6 on: July 13, 2024, 10:54:12 am »
Thank you!

I did a mistake to place the LED in Kicad.

I uploaded a new schematics.

About the:
And don't use a 1N4007, but a 24...33 V Zener across Q1 instead.
may I ask you why?

thx

To protect the relay contacts. Using a normal diode like in your circuit slows down the release time of the relay immensely, potentially causing contact burn.
Allowing the coil a higher voltage when turning off, the contacts will open much faster.
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3586
  • Country: nl
Re: Esp32 controls a 12v coil relay through PC817 and 2N7000
« Reply #7 on: July 13, 2024, 05:27:25 pm »
When beginning with electronics, it's good to build circuits like this on breadboards.

Gate voltage of the 2n7000 can also be as high as 3V, which is getting uncomfortably close to the 3V3 of most microcontrollers. it works with this circuit (with 12V gate drive) but it's dubious when the gate gets connected directly to the uC. The 2n7002 is more common, and has a maximum threshold voltage of 2V5.
« Last Edit: July 13, 2024, 05:32:19 pm by Doctorandus_P »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf