enter image description hereI have a fairly simple code to turn a relay on-off every 2 seconds When i attach the USB of the arduino Uno to the laptop, it goes into a frenzy and the relay triggers on off for 6 times within 3-4 seconds and then it settles down. This however doesnt happen when connecting directly to the power output.

Is there something that needs to be wired to stop this happening ?

I am using an arduino Uno with a relay JQC-3FF-S-Z connected directly to the arduino pins.

const int ONOFF_TRIGGER_PIN = 2;

void setup() {
  // put your setup code here, to run once:

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(ONOFF_TRIGGER_PIN, LOW);
  digitalWrite(ONOFF_TRIGGER_PIN, HIGH);
  • The code is so simple, this has to be a hardware problem. Please add a schematic or a wiring diagram to your question. – JRobert Oct 15 '20 at 22:32
  • Thanks @Jrobert ive added a fritzing image. Couldnt find the the exact same relay component i have JQC-3FF-S-Z – Looneystar Oct 15 '20 at 22:44
  • Put a voltmeter on the pin and to ground while the Uno is starting up with the relay detached. Note any fluctuations. Now, connect the relay with the voltmeter still attached, and restart the Uno. Do you see any difference with the voltage behaviour of the pin? – stevieb Oct 15 '20 at 23:14
  • 1
    @hcheung - Ive tried it on both 5v and 3v. it works on both. – Looneystar Oct 16 '20 at 1:48
  • 1
    @hcheung but after the first 3-4 seconds (which i assume is the arduino booting up or something), it starts to work as per the program, So its just the initial phase. Also, when hooking the arduno to a powersupply, the relay pins are still connected to the arduino. So maybe the arduino i have is corrupted somehow – Looneystar Oct 16 '20 at 2:48

The markings on your relay suggest the coil is for 5VDC. But you have the coil supply wired to 3V3. Move the coil supply to 5V, and try again.

  • I agree with @Seamus. We don't know what might be going on with the 3v supply during boot up, but going to be marginal for a 5v even at steady state. At least try this and find out. – JRobert Oct 16 '20 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.