Author Topic: Electrical Schematic Review Request: SMART SWITCH ESP32  (Read 2779 times)

0 Members and 1 Guest are viewing this topic.

Offline YisusTopic starter

  • Newbie
  • Posts: 6
  • Country: es
Electrical Schematic Review Request: SMART SWITCH ESP32
« on: April 26, 2025, 12:55:35 pm »
Hello people,

I am at my last year of electronic systems engineering degree and I decided to build this smart switch that connects to the National Electrical Service through it's API. I am going to purchase not only the PCB but also the Assembly on JLCPCB. Since it's going to cost me some money, I want to make sure the device is going to work. I will share the schematic with you and a brief explanation of how it works and I hope that you can tell me if you find anything weird  ;D

1) It's going to be powered from an outlet at 220V/50Hz. Thus, the AC/DC converter to 5V.
2) I want to flash my esp32 using an usb-c. Then, I connect both voltages to a single point (they are not going to be connected at the same time) before the 3.3V voltage regulator and after having filtered it with a pi filter (why not :D).
3)Then i will control my relay with the 5V and power my esp32 with the 3.3V
4) I also added a wifi_status led and a ACS712 to measure the power consumption of the AC connected device.

Thank you in advance and sorry for my english !
« Last Edit: April 26, 2025, 01:19:00 pm by Yisus »
 

Offline SteveThackery

  • Super Contributor
  • ***
  • Posts: 3378
  • Country: gb
  • 50 year novice
Re: Electrical Schematic Review Request: SMART SWITCH ESP32
« Reply #1 on: April 26, 2025, 01:11:09 pm »
Hmmm.... yet another schematic with labels instead of wires.

Anyway, what is the role of D4? It isn't set up as a normal flywheel diode. Could be a mistake?
 

Offline YisusTopic starter

  • Newbie
  • Posts: 6
  • Country: es
Re: Electrical Schematic Review Request: SMART SWITCH ESP32
« Reply #2 on: April 26, 2025, 01:20:51 pm »
Thank you for the replay!

I have always thought it looks cleaner using labels instead of wires. Guess it might make it more difficult for people to review it... Sorry

D4 orientation was a mistake, already fixed!
 

Offline PGPG

  • Super Contributor
  • ***
  • Posts: 1330
  • Country: pl
Re: Electrical Schematic Review Request: SMART SWITCH ESP32
« Reply #3 on: April 26, 2025, 01:33:10 pm »
A very unusual solution for powering esp32 3V3 via capacitors.

And your relay will not work.
« Last Edit: April 26, 2025, 01:38:56 pm by PGPG »
 

Offline YisusTopic starter

  • Newbie
  • Posts: 6
  • Country: es
Re: Electrical Schematic Review Request: SMART SWITCH ESP32
« Reply #4 on: April 26, 2025, 01:42:28 pm »
Thank you for the replay!

Could I know why my relay is not going to work?

About the uC powering, fixed!

 

Offline PGPG

  • Super Contributor
  • ***
  • Posts: 1330
  • Country: pl
Re: Electrical Schematic Review Request: SMART SWITCH ESP32
« Reply #5 on: April 26, 2025, 01:46:22 pm »
Hmmm.... yet another schematic with labels instead of wires.

I am not trying to understand how rectangles cooperate with each other.
I pointed errors I noticed looking at each rectangle as separate circuit.
 

Offline PGPG

  • Super Contributor
  • ***
  • Posts: 1330
  • Country: pl
Re: Electrical Schematic Review Request: SMART SWITCH ESP32
« Reply #6 on: April 26, 2025, 01:47:59 pm »
Could I know why my relay is not going to work?

D4 will not allow current to flow from +5V.
 

Offline YisusTopic starter

  • Newbie
  • Posts: 6
  • Country: es
Re: Electrical Schematic Review Request: SMART SWITCH ESP32
« Reply #7 on: April 26, 2025, 01:49:42 pm »
I think i fixed the mistake for the relay!

It should work now (see attachment)

Thank you guys, you are helping me very much
 

Offline SteveThackery

  • Super Contributor
  • ***
  • Posts: 3378
  • Country: gb
  • 50 year novice
Re: Electrical Schematic Review Request: SMART SWITCH ESP32
« Reply #8 on: April 26, 2025, 02:46:48 pm »
With respect, @Yisus, I still find the orientation of the components and wires a bit obscure for "at a glance" reading.

I've attached another way of drawing the relay circuit, where the emphasis is on having the positive and ground rails horizontal, and the components connected to the rails carry the current vertically. Signals travel horizontally, left to right where possible. This is the traditional way of laying out a schematic, and if you examine it for a moment I hope you will see that it is much easier to discern the "design logic" than the schematic that you drew.

Notice how the current flows downwards through the relay, the transistor, to ground. Yours flows down, across, down, a long way across, and down. Note the positioning of D7, right next to the relay coil, in order to show that its purpose is a flywheel diode for the relay coil. Yours is way off to the left and the current in it is vertical whereas the current in the relay coil is horizontal. Yours isn't wrong but it's just that bit more difficult to read at a glance.

Mine is also considerably more compact. 😄

Anyway, check it out.
« Last Edit: April 26, 2025, 03:17:07 pm by SteveThackery »
 

Offline SteveThackery

  • Super Contributor
  • ***
  • Posts: 3378
  • Country: gb
  • 50 year novice
Re: Electrical Schematic Review Request: SMART SWITCH ESP32
« Reply #9 on: April 26, 2025, 02:57:33 pm »
I have always thought it looks cleaner using labels instead of wires. Guess it might make it more difficult for people to review it...

Correct. The purpose of a schematic isn't to look "clean", but rather to convey the design logic to a viewer. The problem with using numerous boxes "connected" by labels is that the design logic isn't immediately obvious. The viewer must mentally join the labels in their head to discern how the signal, or power, travels through the circuit.

This is doable when a circuit is really simple, like yours, but it quickly becomes extremely difficult. It is almost impossible when a signal splits two or more ways: the viewer must search the schematic for every instance of the label, and each time one is found they must add another connection wire in the model inside their head.  It's really quite difficult and very error prone.

I fact, I (and, I'm sure, others) sometimes end up drawing wires between the labels (either on a printout or in a drawing app), which is basically converting the label-based schematic to a wire-based schematic! As they are doing so they wish you had done it to begin with. 😄

It's up to you - perhaps consider it next time.
« Last Edit: April 26, 2025, 03:10:41 pm by SteveThackery »
 

Offline bookaboo

  • Frequent Contributor
  • **
  • Posts: 803
  • Country: ie
Re: Electrical Schematic Review Request: SMART SWITCH ESP32
« Reply #10 on: April 26, 2025, 03:11:11 pm »
- You will need a boot button to program the ESP32
- The USB can be used for program and debug, but I'd recommend adding Uart header for optional FTDI cable debugging
- Relay coil is wired incorrectly.  fix noted.

I'd build on breadboard with a devkit first, you will fix a few issues there without the expense of a board spin.
 

Offline xvr

  • Frequent Contributor
  • **
  • Posts: 920
  • Country: ie
    • LinkedIn
Re: Electrical Schematic Review Request: SMART SWITCH ESP32
« Reply #11 on: April 26, 2025, 04:31:59 pm »
Ther is ADC1 better to use for current measurement - ADC2 has reduced functionality (DIG module doens't work for ADC2). So move otput of ACS712 from GPIO11 to one of GPIO 1-10

Also double check voltage range on output of ACS712 and input voltage range of ADC.
 

Offline YisusTopic starter

  • Newbie
  • Posts: 6
  • Country: es
Re: Electrical Schematic Review Request: SMART SWITCH ESP32
« Reply #12 on: May 02, 2025, 04:49:52 pm »
Hello! Thank you all for your advise. I have been working on the schematic again and I think it looks much better now.

I would appreciate it so much if you could take a look again!
 

Offline ifrythings

  • Contributor
  • Posts: 43
  • Country: ca
Re: Electrical Schematic Review Request: SMART SWITCH ESP32
« Reply #13 on: May 02, 2025, 08:37:07 pm »
D2 is useless, D1 will cause VUSB to always be <5v and will never try to back feed into the power supply.
 

Offline YisusTopic starter

  • Newbie
  • Posts: 6
  • Country: es
Re: Electrical Schematic Review Request: SMART SWITCH ESP32
« Reply #14 on: May 02, 2025, 11:20:04 pm »
D2 is useless, D1 will cause VUSB to always be <5v and will never try to back feed into the power supply.

Thank you for the answer! I placed them for protection in case I connected both power supplies at the same time (which I won't, but it is good to have some protection). I'm sorry I don't understand the problem with D1. Could you explain it for me please!

 

Offline ifrythings

  • Contributor
  • Posts: 43
  • Country: ca
Re: Electrical Schematic Review Request: SMART SWITCH ESP32
« Reply #15 on: May 03, 2025, 12:37:36 am »
Nothing is wrong with D1, D2 isn’t needed and could actually cause issues with the ACS712. SS14 has a forward voltage drop of 0.5v, with the way you have it right now your 5v rail is going to be 4.5v which is the absolute minimum the ACS712 can take, not a good idea being on the edge like that. If you remove D2, you’ll have full 5v from your power supply and if you plug in the USB, the USB power will be blocked by D1 being reversed biased. If you plug in just USB and not the mains, then it’s not a big deal if your 5v rail is at 4.5 as the ACS712 won’t be measuring any current without mains. I would also reduce R9 to 6.2k just to use more of the range of your ADC.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->