ESP32 Pin not opearting relay but Ardunio operates relay

Adrunio digital pin works relay fine - switches it off and on, esp32 does not using same sketch and relay. Voltage of digital pin on esp32 measured going from 0V (low) to 4V (high), yet relay will not operate. Tried other digital pins on esp32 but no difference.

Hi @madison1776. Please provide detailed information about your relay.

Is this a relay module with drive circuitry, or is it just a relay by itself?

If possible, post a link to the product page you bought it from or the datasheet.

Dear Pert

I "solved" the issue, but don't know why it works. I took GPIO4 output pin then in serial place a 4.7k ohm resistor with a diode (1N4007) before connecting to the relay input pin. It then worked.
Do you know why this would have fixed it.
Regards
John

ESP32 pins cannot have 4V.
Its supply voltage should be 3.3V.
Show your wiring diagram.

@madison1776, your topic as been moved to a more suitable location on the forum.

1 Like

Your image is ridiculously small, but I am guessing this is an "active LOW" relay module which you are powering from 5 V - as you must as it is a 5 V relay.

Because 3.3 V is already lower than 5 V, a 3.3 V "HIGH" is effectively a LOW to the relay module, so the relay is always actuated. The diode adds 0.7 V to your 3.3 V so when HIGH, it is only pulled down to 4 V or so, not enough to actuate the relay. A red LED might be a better choice of diode.


This relay module puts the green indicator diode in parallel with the relay coil, so the PNP transistor whose emitter is connected to the 5 V supply, will tend to conduct on any voltage below 4.3 V. You need a little lower voltage to make it conduct sufficiently to actually switch the relay.

The multi-relay boards with optical isolation have the green LED and the optocoupler in series, so require more like 3 V to conduct, so these work perfectly well withe the 3.3 V ESP logic when powered from 5 V.

Paul,
Sorry for the image, I tried to make as large as possible.
Thank-you for your answer and the detailed explanation, I checked the voltages that confirmed your analysis.
Once again thanks for taking the time.