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?
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]
#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
}
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