I got this relay module with optocoupler delivered today. I tested the relay without connecting anything on the output side(NO,COM,NC) using the example blink sketch. Used pin 2 and delay of 4 second. Connected 5v to the relay module from phone charger and pin 2 from esp32 to IN on relay module. It was working fine and i could hear the relay ticking.
Now when i connected my table lamp to the NO and COM, the relay stopped working. I thought the coil might have burnt but i tried applying 5v directly to the relay and it was clicking.
Is the module dead? I am using the same blink sketch with 4 second delay.
I connected the bulb by cutting the live wire and connecting it to NO and COMM.
I am powering the relay with a phone charger.
When I power my ESP32 with a phone charger(from Xiaomi) connected through micro USB, the relay does not click but when I power my ESP32 from my laptop's USB, the relay works.
I think the board is not drawing enough power or the charger is not providing enough power to even let the board trigger the relay (I am not sure)
did you connect the GND of the inputside of the relayboard with your ESP32 too?
If not then it is caused by this.
If your computer is connected with a 3-contact plug including the protective conductor. The protective conductor is connected o GND of the computer and if you connect a USB-cable between your computer and the ESP32 on this hidden path you get a connection of GND between ESP32 and the relay-board.
A smartphone-charger has only a two-wire connection leaving the protective conductor out. So there is no GND-connection
The proper way is to wire a GND connection directly between ESP32 and the relay-module.
You have to be very careful to keep COM from the outputside of the relayboard isolated from anything on the inputside.
An ESP32 is a 3.3V device. Depending on the circuitry of the relay-board it might be that 5V get feeded into the Input. Some have a good quality some a bad one.
With these very cheap chinese electronics I have encountered unbelievable hair-raising negligence. Once I had a cheap chinese stepperdriver-board with optocouplers. Optocouplers means electrically isolated output-stage. But the guy who designed the PCB connected GND of the inputside with GND of the outputside = creating a electrical connection between input and output.
Some USB-charger-cables are so thin-wired that you have a relevant voltagedrop across the USB-cable. With a 2,1A USB-power-charger I measured the current for loading my smartphone. A good USB-cable draws a current of 1,4A a real bad thin-wired usb-cable just 0,3A !
Do you have a digital multimeter? If not then now is the right time to buy one. As soon as anything like you encountered happens you have to analyse it by measuring voltages and currents.
Thanks Stefan, for the detailed explanation. I think the GND was the issue. When I power ESP32 and the relay using my laptop's USB, they work because even if the ports are different, the power source is the same.
But when I tried to test with the light bulb connected to the relay, I was powering the relay and ESP32 with 2 different mobile chargers, and what I believe is the ESP32 being connected to a different mobile charger and relay connected to another one, the input going to the relay from ESP32 didn't have a GND path to return therefore nothing triggered the relay.