The intention is simple. I have a relay module (with optical isolation and transistor). The power supply is a 6V supply with 2A which powers both the relay and the Arduino. Similar to the picture below but the power for the relay comes from the supply itself and not Arduino 5V and grounds are connected together.
I've a simple sketch that listens for messages over MQTT and when it receives the intended msg it's turns on the relay. The intention is to turn on a AC load.
The relays work as intended when the AC load is not connected. But when the AC load is connected, it stops working after the 1st time or 2-3 times and stays ON and activated.
The code is simple and so not posting here. I believe something to do with the circuit itself.
Scratching my head as I never faces this situation before as I've done similar thing before with success.
Anyone faced similar situation or have any idea what is going wrong, p[lease help
Agree it’s likely a “circuit issue” because the cheapest 2 relay board on amazon which looks a lot like what you frizted states it needs “Current: More than 100mA“ which is more than you should be trying to get from a arduino pin.
Maybe try moving the relay VCC away from your 5v pin and give it its own power supply connection.
You may need a snubber circuit on the relay contacts, to suppress sparks and consequential electric noise. A SSR may be more appropriate in your case, instead of a relay.
Wawa:
Can't you see it's an incandescent lightbulb. So no snubber circuit needed.
I thought you know better than taking a Fritzing at face value
But this is ambiguous as well:
Assuming
dattasaurabh82:
it stops working after the 1st time or 2-3 times and stays ON and activated.
Does this mean the relay will remain in the ON state even after removing the power, and the relay is basically trashed? Because a single regular light bulb, even an incandescent one, shouldn't have the power to fuse relay contacts.
DrDiettrich:
You may need a snubber circuit on the relay contacts, to suppress sparks and consequential electric noise. A SSR may be more appropriate in your case, instead of a relay.
Wawa:
So you're NOT using optical isolation, because two separate supplies, and grounds NOT shared are needed for this.
How did you power the Uno. 6volt is too much for the USB socket or 5volt pin, and borderline low for the V-in pin.
Since when can an Uno connect to the internet.
Can't you see it's an incandescent lightbulb. So no snubber circuit needed.
Different story ofcourse if this was an inductive load, like a CFL or LED light.
Leo..
Optical isolation here meant relay module board has opto-isolators on board, meaning no risk of back current.
6Volt is not coming through USB but supplied to VIN (This is obvious thing to know). Not a noob on this aspect.
Put an ethernet shield and see the magic of internet, I thought this is not important to mention here, hence the short cut.
wvmarle:
But this is ambiguous as well:
Assuming
Does this mean the relay will remain in the ON state even after removing the power, and the relay is basically trashed? Because a single regular light bulb, even an incandescent one, shouldn't have the power to fuse relay contacts.
Say the AC load(In this case an IKEA lamp) is connected to the relay ends. Now I send it a MQTT message to activate the relay and turn the lamp ON. it happens and then if I send it a message to turn OFF, the relay stays ON. If I now remove the AC load and send an OFF command, the relay still stays activated.
If the AC load is not connected and then I do the same thing, it works flawlessly.
I know what opto isolation is, but you are NOT using it.
The opto isolation feature of that relay is only available if you use a separate 5volt relay supply, connected to JD-VCC and relay ground, with the jumper removed. And connect Arduino 5volt to relay VCC (not JD-VCC), and DON't connect relay ground to Arduino ground.
The 5volt regulator on an Uno has a dropout voltage of about 1volt, so 6volt input to make 5volt is borderline.
But could be ok if it's regulated.
A 5volt cellphone charger connected to the USB socket is an easier way to power an Uno (with ethernet shield).
SSR = SolidStateRelay.
So what are you switching (don't just say 'IKEA lamp').
Leo..
dattasaurabh82:
6Volt is not coming through USB but supplied to VIN (This is obvious thing to know).
You need more than 6V on Vin for the onboard regulator to produce the 5V required to power the UNO.
Check what voltage you have on the 5V pin of the UNO and on the Vin pin.
Thanks.. Tom...
TomGeorge:
You need more than 6V on Vin for the onboard regulator to produce the 5V required to power the UNO.
Check what voltage you have on the 5V pin of the UNO and on the Vin pin.
Thanks.. Tom...
Simple test: short the relay contacts, leaving the AC circuit in place. Then try to switch the relay and watch whether it reacts on multiple messages as it should. If this works, and without the short it fails, some suppressor element may help.
dattasaurabh82:
If the AC load is not connected and then I do the same thing, it works flawlessly.
Interesting.
No obvious red flags to me, but your information is limited. Leaving out the ethernet shield part makes me wonder what else you left out. You may think some detail has no effect, but it may be key to the problem.
Are you sure you receive the message and it's processed properly? (Try using print statements).
DrDiettrich:
Simple test: short the relay contacts, leaving the AC circuit in place. Then try to switch the relay and watch whether it reacts on multiple messages as it should. If this works, and without the short it fails, some suppressor element may help.