I’m having some problems with my ESP32 circuit and my 2-channel relay (SLA-05VDC-SL-C).
Configuration of my relay: DC+, DC-, CH1, CH2 // COM1, NO1, NC1, COM2, NO2, NC2
My idea for the circuit is: I connect the DC+ of the relay to 5V, DC- to GND, CH1 to pin 33 of the ESP32, if I set the pin to HIGH, it should turn on the relay, and vice versa.
However, when I connect CH1 with pin 33, it doesn’t change the state of the relay (between NO/NC), I found out that this is due to pin 33 of the ESP32, emitting only 3.3V, if I connect a 5V cable to CH1, the relay turns on normally.
I’ve tried a few solutions, but so far I’ve had no success.
Attempted solution 1:
gpio_set_drive_capability: I set pin 33 of the ESP32 to output 80mA, but to no avail.
Attempted solution 2:
NPN transistor: I tried connecting a transistor (BC547B) that receives direct 5V power (GND on the emitter), on the base, I put a resistor connected to pin 33 of the ESP32, and on the collector, I tried connecting it to the relay, it indicates that it has turned on the LED of the relay, however, it does not have enough power to turn it on. I tried placing a direct 5V pin on the base of the transistor, and it turned on the relay
I have no more ideas on how to solve this problem. If anyone can help me, I’d appreciate it.
My complete circuit:
9V battery:
Positive -> KA7805 (INPUT)
Negative -> GND in common (protoboard bus)
KA7805:
GND -> GND in common (from the negative of the 9V battery)
OUTPUT -> 100μF capacitor
100μF capacitor:
GND -> GND in common (from the negative of the 9V battery)
Positive -> 5V supply to the main protoboard
Main protoboard:
GND -> Receives GND in common from the 9V battery
Positive -> Receives the 5V
ESP32 -> 5V supply
GND -> GND feed from ESP32 to common GND (same as 9V battery)
Transistor (BC547B):
Emitter -> GND in common (From the 9V battery)
Base -> 120Ω resistor -> ESP32 pin 33
Collector -> Connect to Relay CH1
Relay (SLA-05VDC-SL-C):
DC+ -> Receives the 5V from the main protoboard
DC- -> Receives the negative of the main protoboard (common GND of the 9V battery)
CH1 -> Connected to the collector of the transistor
My relay
My Circuit, but at this moment, i was trying set the Base pin of transistor in 5v directly