I am trying to control a 5V relay with a push button with an indicator LED using GPIOs 0, 1 and 3. I have pulled up the GPIO0 and using it as output, so that when I drive it low, the LED should glow, but its not happening. Is there anything wrong with my schematic?
-
\$\begingroup\$ perhaps you should be asking about the switch led, not about your project ... please add the datasheet for the switch \$\endgroup\$– jsotolaDec 6, 2021 at 16:22
-
\$\begingroup\$ I will try to find it. The issue I am facing is that when I write the code in Arduino for just blinking the LED and switching the relay on/off at 1 second intervals, nothing happens. \$\endgroup\$– AmorphousDec 6, 2021 at 16:24
-
1\$\begingroup\$ GPIO0 sees +5V through LED1 + R6, that will cause trouble later, if not now. \$\endgroup\$– jayDec 6, 2021 at 16:37
-
1\$\begingroup\$ I will try without the LED or swap the 5V on the LED with 3.3V source \$\endgroup\$– AmorphousDec 6, 2021 at 17:28
-
1\$\begingroup\$ Yes. Swap +5V for the Led with 3.3V. Safer. \$\endgroup\$– Antonio51Dec 6, 2021 at 17:30
1 Answer
Is there anything wrong with my schematic?
If you are using a switch similar to this one: -
Image from here courtesy of RS components.
Then, the switching contacts are between pins 2 and 4 (or 1 and 3). Your schematic shows this: -
So, it looks possible that you may not have wired up the switch correctly. You can confirm this by linking the data sheet. In other words, between pins 1 and 2 is a dead short.
Of course, if you put a feeble switch like this directly across a 100 nF capacitor, when the switch closes, you get an almighty current surge into the switch that may weld the contacts closed. This type of switch has the following current rating: -
50 mA is just not going to cut-the-mustard when shorting out a charged capacitor if this switch is similar to the one used. Data sheet link required.
-
\$\begingroup\$ Infact I did screw up exactly like this earlier but then corrected it in my current prototype PCB. Can confirm that switch is wired correctly \$\endgroup\$ Dec 6, 2021 at 17:13
-
1\$\begingroup\$ I can't confirm that because I only have your schematic and no link to the device. However, I have pointed out another deficiency in your design; you may need a 100 ohm (or thereabouts) resistor in series with your switch to prevent it becoming damaged when you short out the capacitor (C7). \$\endgroup\$– Andy akaDec 6, 2021 at 17:20
-
\$\begingroup\$ Thanks a ton. I will add a current limiting resistor in series with the switch..never thought of it..much appreciated PS : Sorry I meant I can confirm that the switch is wired correctly (in the previous comment) \$\endgroup\$ Dec 6, 2021 at 17:27
-
\$\begingroup\$ @Amorphous no problems and good luck (but you still didn't link the switch used because I like to nail these things down instead of leaving a slightly open-ended answer!) \$\endgroup\$– Andy akaDec 6, 2021 at 17:32
-
\$\begingroup\$ Its a chinese switch, I will try & dig out the datasheet \$\endgroup\$ Dec 6, 2021 at 17:35