Electrical Schematic Review Request:  SMART SWITCH ESP32 - Page 1
Forum section: electronics / projects

author: Yisus
author_rank: Newbie
timestamp: April 26, 2025, 12:55:35 pm
content: 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 weird1) 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).3)Then i will control my relay with the 5V and power my esp32 with the 3.3V4) 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 !

author: SteveThackery
author_rank: Super Contributor
timestamp: April 26, 2025, 01:11:09 pm
content: 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?

author: Yisus
author_rank: Newbie
timestamp: April 26, 2025, 01:20:51 pm
content: 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... SorryD4 orientation was a mistake, already fixed!

author: PGPG
author_rank: Frequent Contributor
timestamp: April 26, 2025, 01:33:10 pm
content: A very unusual solution for powering esp32 3V3 via capacitors.And your relay will not work.

author: Yisus
author_rank: Newbie
timestamp: April 26, 2025, 01:42:28 pm
content: Thank you for the replay!Could I know why my relay is not going to work?About the uC powering, fixed!

author: PGPG
author_rank: Frequent Contributor
timestamp: April 26, 2025, 01:46:22 pm
content: Quote from: SteveThackery on April 26, 2025, 01:11:09 pmI am not trying to understand how rectangles cooperate with each other.I pointed errors I noticed looking at each rectangle as separate circuit.

author: PGPG
author_rank: Frequent Contributor
timestamp: April 26, 2025, 01:47:59 pm
content: Quote from: Yisus on April 26, 2025, 01:42:28 pmD4 will not allow current to flow from +5V.

author: Yisus
author_rank: Newbie
timestamp: April 26, 2025, 01:49:42 pm
content: I think i fixed the mistake for the relay!It should work now (see attachment)Thank you guys, you are helping me very much

author: SteveThackery
author_rank: Super Contributor
timestamp: April 26, 2025, 02:46:48 pm
content: 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.

author: SteveThackery
author_rank: Super Contributor
timestamp: April 26, 2025, 02:57:33 pm
content: Quote from: Yisus on April 26, 2025, 01:20:51 pmCorrect. 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.

author: bookaboo
author_rank: Frequent Contributor
timestamp: April 26, 2025, 03:11:11 pm
content: - 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.

author: xvr
author_rank: Frequent Contributor
timestamp: April 26, 2025, 04:31:59 pm
content: 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-10Also double check voltage range on output of ACS712 and input voltage range of ADC.

author: Yisus
author_rank: Newbie
timestamp: May 02, 2025, 04:49:52 pm
content: 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!

author: ifrythings
author_rank: Contributor
timestamp: May 02, 2025, 08:37:07 pm
content: D2 is useless, D1 will cause VUSB to always be <5v and will never try to back feed into the power supply.

author: Yisus
author_rank: Newbie
timestamp: May 02, 2025, 11:20:04 pm
content: Quote from: ifrythings on May 02, 2025, 08:37:07 pmThank 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!

author: ifrythings
author_rank: Contributor
timestamp: May 03, 2025, 12:37:36 am
content: 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.