Relay switches every 2 seconds on/off. It works fine if the light bulb isn't connected to 220v, if I plug the light bulb in, then it works for a couple of seconds ant then the whole thing freezes. As far as I understand the problem is that the on/off switching generates some kind of interfering current?
In future I will replace the light bulb with a solenoid valve and I thing the problem will be even worse with it.
Can I solder in a diode from relay to light bulb to make sure no current can flow back to the relay? I found some forum posts about similar problems, but I still cant figure it out.
the drawing above is just for illustrative purposes.
:::
Relay switches every 2 seconds on/off. It works fine if the light bulb isn't connected to 220v, if I plug the light bulb in, then it works for a couple of seconds ant then the whole thing freezes.
So it does only one thing... on or off ?
I think it’s time to see what else is going on.
Full schematic, and code.
It can't be the code. It works fine if the lamp is not connected to the wall power outlet.
The relay switches on/off for 5h without any problem. As soon as I plug in the lamp in the wall it works for 5 - 30 seconds (sometimes less, sometimes longer) and then everything freezes.
What freezes ? Put some Serial.print statements in your code when it switches the relay to see if it is the Arduino. It can “freeze” and leave the light on or off or both ?
Your relay module is like the one illustrated with an inbuilt led?
The cheap 9volt power supply is not immune to mains power hash (try a 5volt cellphone charger connected to the USB socket)
or
The incandescent lightbulb is only there for "illustrative purposes", but is really a complex load,
like a CFL or LED lightbulb that needs a snubber circuit (a solenoid/valve definately needs one).
Leo..
The cheap 9volt power supply is not immune to mains power hash (try a 5volt cellphone charger connected to the USB socket)
or
The incandescent lightbulb is only there for "illustrative purposes", but is really a complex load,
like a CFL or LED lightbulb that needs a snubber circuit (a solenoid/valve definately needs one).
Leo..
Yes, for now it is a LED light. In future it will be a solenoid valve. What is a snubber circuit?
6v6gt:
What freezes ? Put some Serial.print statements in your code when it switches the relay to see if it is the Arduino. It can “freeze” and leave the light on or off or both ?
Your relay module is like the one illustrated with an inbuilt led?
I have serial outputs. It seams like the whole Arduino freezes.
How about powering the Arduino from the PC/laptop, without that external 9volt supply.
The extra current draw of one relay module (~75mA) should be ok.
Or powering the setup with the cellphone charger I mentioned before.
This is simple fault finding stuff.
Can't (shouldn't) fix something if you don't know what's causing it.
Leo..
Wawa:
How about powering the Arduino from the PC/laptop, without that external 9volt supply.
The extra current draw of one relay module (~75mA) should be ok.
Or powering the setup with the cellphone charger I mentioned before.
This is simple fault finding stuff.
Can't (shouldn't) fix something if you don't know what's causing it.
Leo..