I'm trying to use an Arduino to press a button on a toy, and getting some strange behavior. I connected the two wires from the button to a relay, which is controlled by the Arduino. It works perfectly for awhile, and after maybe 20 minutes the relay starts turning on and off in a loop.
The toy is always on, powered by two AA batteries, and has a button to start some motion. It's similar to this:
I'm guessing the reason is that the button wires are carrying voltage, about 2.5 volts. And the toy is powered by batteries (two AA), not sharing a ground with the Arduino.
Is there some other way I should be simulating a button press?
From googling I have a feeling the answer is a transistor, but I'm confused about how to wire it.
Or would sharing the ground between the Arduino and the toy make the relay work?
Thanks for any help, and let me know if I'm leaving out any relevant data.
The button from the toy is connected to the NO and common pins of one of the relays.
The code is simple, just activating the relay:
digitalWrite(relay7_pin, LOW);
I don't think the relay triggering on it's own is related to the code, I think it's electrical, since a) the issue doesn't happen without the button wires attached to the relay, and b) if I connect anything else to the relay it works perfectly.
I just confirmed that the issue happens even with a blank (template) script, so it's not code.
As far as wiring, it's dead simple: ground and 5v from relay board to ground and 5v of the arduino, and the signal pin of the relay board to pin 5 of the Arduino.
The button wires from the toy to NO and common of the relay pins.
wrybread:
I just confirmed that the issue happens even with a blank (template) script, so it's not code.
As far as wiring, it's dead simple: ground and 5v from relay board to ground and 5v of the arduino, and the signal pin of the relay board to pin 5 of the Arduino.
The button wires from the toy to NO and common of the relay pins.
The relay cycles with a blank sketch on the Arduino!? hmmmm....
I'll bet you're overloading the Arduino's voltage regulator by using it to power the relay board. When the regulator goes into thermal shutdown, the relay opens. You're using the Arduino as an expensive bimetallic strip.
S.
I'm simply connecting the positive and ground pins of the relay board to the arduino's 5v and ground pins. And digital pin 5 of the arduino to the relay board's signal pin.
And the two wires of the toy's button to the relay common and NO connectors. I'll take a pic later but it's that simple.
Does anyone have any thoughts on whether I should be sharing the ground with the toy? Again the toy is powered by 2 AA batts. When the button is pressed on the toy it starts the motion, and I'm trying to press that button from the arduino.
The toy's two button wires show 2.5v when connected to a multimeter, which is new to me.
For the moment, forget about the toy. It is irrelevant if it is connected as you say it is. And no, do not connect the toy's "ground" to your circuit.
A nice feature of mechanical relays is that they make a noise when changing state. If you are hearing "click click click", but only after a period of time has elapsed, I strongly suspect something is overheating. It is fine at first but begins misbehaving when it get too hot.
I'll add my voice to all of the previous calls for posting a [clear] picture of your setup. It is very easy to be blind to a circuit mistake which has been staring you in the face. Sort of like trying to proofread a document for the 20th time.
S.
As far as wiring, it's dead simple: ground and 5v from relay board to ground and 5v of the arduino, and the signal pin of the relay board to pin 5 of the Arduino.
Common ground = no opto-isolation.
Lets turn all 8 relays on: 80mA x 8 = 640mA.
No separate supply?
Separate supply = Happy Arduino, improved isolation and EMI/RFI rejection.
4 relay module but only using one relay. I don't even have to turn on a relay for the issue to happen. Heat is an interesting theory. Unfortunately I'm not at the location with the gizmo until Monday wilk look then.