[SOLVED] Arduino Relay is always open on Power Supply

Hello everyone.

I'm a bit loss here. I bought this set:
DIY Kit

I threw away the sensors and hooked up a IR remote control to watering my plants via remote.
My issue: The code and everything else is working fine. If i press a button the relay opens and the pumps starting. But as soon as i unplug the USB and put the power supply in (who wants his laptop running just to watering his plants?) the relays open automatically and the pumps running as long as the supply is plugged in. I am totally lost here. Does anyone has any ideas?

Show us a good schematic of your circuit.
Show us a good image of your ‘actual’ wiring.
Posting images:
https://forum.arduino.cc/index.php?topic=519037.0

Use CTRL T to format your code.
Attach your ‘complete’ sketch between code tags, use the </> icon in the posting menu.
[code]Paste your sketch here[/code]

Hello. Sure. Here are two pictures: Imgur: The magic of the Internet

And here the code:

#include "IRremote.h"
int IN1=2; 
int IN2=3; 
int IN3=4; 
int IN4=5;
 
int receiver = 11; // Signal Pin of IR receiver to Arduino Digital Pin 11

/*-----( Declare objects )-----*/
IRrecv irrecv(receiver);     // create instance of 'irrecv'
decode_results results;      // create instance of 'decode_results'

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  Serial.begin(9600);
  Serial.println("IR Receiver Button Decode"); 
  irrecv.enableIRIn(); // Start the receiver
  pinMode(IN1,OUTPUT);
  pinMode(IN2,OUTPUT); 
  pinMode(IN3,OUTPUT);
  pinMode(IN4,OUTPUT);

  digitalWrite(IN1,HIGH);
  digitalWrite(IN2,HIGH); 
  digitalWrite(IN3,HIGH); 
  digitalWrite(IN4,HIGH); 
  delay(500);


}/*--(end setup )---*/


void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  if (irrecv.decode(&results)) // have we received an IR signal?

  {
    translateIR(); 
    irrecv.resume(); // receive the next value
  }  
}/* --(end main loop )-- */

/*-----( Function )-----*/
void translateIR() // takes action based on IR code received

// describing Remote IR codes 

{

  switch(results.value)

  {
  case 0xFFA25D: 
 Serial.println("Wasser marsch!");    
 digitalWrite(IN1,LOW);
 digitalWrite(IN2,LOW);
 digitalWrite(IN3,LOW);
 digitalWrite(IN4,LOW);
 delay(150);
 Serial.println("Wasser halt!"); 
 digitalWrite(IN1,HIGH);
 digitalWrite(IN2,HIGH);
 digitalWrite(IN3,HIGH);
 digitalWrite(IN4,HIGH);
  break;

  }// End Case

  delay(1500); // Do not get immediate repeat


}
1 Like

The images are a bit out of focus and it would be nice to see closeup of the header connections.

Draw a schematic of the wiring hookup too.


FYI
ddloyd

Just scratch the sensors. This is the manual which comes with the set.

This image ‘does not’ show the external power going to Vin.

What ‘voltage and at what current’ do you have connected to the ‘power-jack’ on the Arduino ?

What is written on the relays ?

Good morning. Here is a shot from my relays:

Here is a shot from the power supply of my Arduino:

And the supply the circuit board is powered from:

The external Power shouldn't be connected to VIN. At least this is what the seller and the manuals says. External + into the relays and GRD from the pumps back into the external power supply. In my case the circuit board or however this thing is called. I am sorry. I am new in the world of Arduino.

I finally found out what was wrong. Even tho i wired everything up like shown in the sellers manual, the wiring was completely wrong. Wiring everything up like shown in Larryds picture:

worked immediately. I can now watering my plants remotely without needing the USB plugged in. Just throw in the two power supplies and there it goes. Thank you so much for your help, Larryd! <3

Modify your sketch if you want to prevent possible relay chatter during bootup.

In setup()...

digitalWrite(IN1,HIGH); // enable internal pull up

must be used before

pinMode(IN1,OUTPUT); // set to output

Same for the other INs, so move that whole block.
Leo..

1 Like