Go Down

Topic: Relay board keeps restarting Arduino (Read 2297 times) previous topic - next topic

Stevelondon

Hi.

Has anyone ever come across this? I have an arduino mega, I have a touchscreen attached and have bought a 4 channel relay to control a 4 way mains plug splitter. I have soldered the necessary wiring inside the 4 way plug so each plug can be turned on individually and wired it to my relay, and in turn back to my arduino mega. I have assigned the following pins...

A0 - IN1
A1 - IN2
A3 - IN3
A4 - IN4
And then +5v and GND as usual.

The plugs are wired to the relays 'normally closed' outputs as to turn it all of in case of a fail.

I then have a touchscreen sketch which shows me if each plug is on or off with a green and red image, and also allows you to touch and turn each on and off.

THE ISSUE...
All of them work, but sometimes after turning a channel on and off a couple of times, the arduino restarts itself.

Has anyone come across this before or have any ideas as to what might be causing this? I'm 99.9% sure its not the sketch as if I disconnect the relays from the Arduino, it doesn't do it, its only when they are connected.

All ideas welcome as I'm coming to the end of my project and now in the testing and troubleshooting phase.

Thanks in anticipation,
Steve

ps. I can attach the sketch if you think its necessary.

Delta_G

Are you powering the relays directly off the Arduino?  You shouldn't.  When they power up they can pull more current than Arduino can safely supply causing it to reset itself.  The relays should have their own power supply and be controlled from Arduino through a transistor. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

Stevelondon

Ohhhh right. I thought it would be something like that but thanks for explaining it. I'll sling a 5v plug into the loop to power my relays. Also, if I use a separate plug to power the relay board, will I still need the transistor? ie...

IN1,2,3 and 4 to pins A0,A1,A2 and A4 respectively
+5v and GND to separate 5v power supply?



Thank you Delta.

Steve

Delta_G

Yes, you'll still need a transistor.  You need some method to switch that 5 volts. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

Stevelondon

Even if the 5 volts is coming from an independent power source?

Delta_G

If the 5V is coming from another source, how will you turn this 5V on and off to the relay?  It can't come through Arduino.  How are you going to switch it on and off to the relay contact?
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

TomGeorge

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Tom.... :)
Everything runs on smoke, let the smoke out, it stops running....

Stevelondon

If the 5V is coming from another source, how will you turn this 5V on and off to the relay?  It can't come through Arduino.  How are you going to switch it on and off to the relay contact?
I was thinking of keeping the 5v constant to the relay so that it is always powered, then just having the data pins 1-4 connected from the Arduino to turn each individual relay open or closed. Would that work?

Stevelondon

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?

Tom.... :)
When I get in from work tonight I will do mate. Thanks.

CrossRoads

Relays can need tens of mA thru their coil to turn on.
Unless they are really small telecom type relays, 5V coils usually need more than an Arduino pin can sink. Use a buffer.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Stevelondon

One thing I have just noticed, the relays switch on and off perfectly without any crashing, it is inky when I plug something into the relevant socket and turn it on and off (generally it seems to be when I am turning the connected item off) that the Arduino crashes. Why is it ok when nothing is plugged into that relay but not when there is?

Attached is a rough diagram of the circuit.


redbafo

One thing I have just noticed, the relays switch on and off perfectly without any crashing, it is inky when I plug something into the relevant socket and turn it on and off (generally it seems to be when I am turning the connected item off) that the Arduino crashes. Why is it ok when nothing is plugged into that relay but not when there is?

Attached is a rough diagram of the circuit.


Hi,

I have exactly same problem with ESP32.. Did you found solution?

relay module (with optocouplers) is swithed by ESP32 .. If I havenĀ“t connected device which I want to switch on/off with relay, then all works OK.. But when I connect device, switchin relay randomly reset (or stuck!) ESP32..

Go Up