Hi all,
I'm desperate, please help!
I'm not so good at electronics and I don't know something important.
I'm trying to build Arduino MQTT Irrigation Controller for two Rain Bird 100DV 9v solenoid valves.
I read this topic:
And this article:
And decided to optimize the project.
This is a simple scheme of the 4 relay modules and the connection with the 9V power supply and the valves.
IMPORTANT: The 4 wires on the top left part of the scheme are connected: the two BLACK wires of the VALVES and the two wires from the 4 relay module.
This is part of the code for controlling the 4 replay model
// orange - module 1 relay 1
const int Module_1_Relay_1 = D5;
// white - module 1 relay 2
const int Module_1_Relay_2 = D6;
// yellow - module 1 relay 2
const int Module_1_Relay_3 = D7;
// black - module 1 relay 2
const int Module_1_Relay_4 = D8;
const int VALVE_WEST = 1;
const int VALVE_EAST = 2;
const int relayDelay = 100;
void turnOnValvesProtection(){
delay(relayDelay);
digitalWrite(Module_1_Relay_1, HIGH);
delay(100);
}
void turnOffAllValveRelays(){
digitalWrite(Module_1_Relay_1, HIGH);
digitalWrite(Module_1_Relay_2, HIGH);
digitalWrite(Module_1_Relay_3, HIGH);
digitalWrite(Module_1_Relay_4, HIGH);
}
void reverseValveCurrent(){
turnOnValvesProtection();
delay(relayDelay);
digitalWrite(Module_1_Relay_2, LOW);
delay(relayDelay);
digitalWrite(Module_1_Relay_4, LOW);
}
void normalValveCurrent(){
turnOnValvesProtection();
delay(relayDelay);
digitalWrite(Module_1_Relay_2, HIGH);
delay(relayDelay);
digitalWrite(Module_1_Relay_4, HIGH);
}
void switchToValveEast(){
delay(relayDelay);
digitalWrite(Module_1_Relay_3, LOW);
}
void switchToValveWest(){
delay(relayDelay);
digitalWrite(Module_1_Relay_3, HIGH);
}
void sendSignalToValve(){
delay(relayDelay);
digitalWrite(Module_1_Relay_1, LOW);
delay(500);
digitalWrite(Module_1_Relay_1, HIGH);
}
void openValve(int valve, const char *topic){
char state[] = {"1"};
if (!mqttClient.publish(topic, (byte *)state, strlen(state), true))
{
Serial.println("Could not send message :( - openValve");
}
turnOnValvesProtection();
if (valve == VALVE_EAST){
switchToValveEast();
} else {
switchToValveWest();
}
normalValveCurrent();
sendSignalToValve();
turnOffAllValveRelays();
}
void closeValve(int valve, const char *topic){
char state[] = {"0"};
if (!mqttClient.publish(topic, (byte *)state, strlen(state), true))
{
Serial.println("Could not send message :( closeValve");
}
turnOnValvesProtection();
if (valve == VALVE_EAST){
switchToValveEast();
} else {
switchToValveWest();
}
reverseValveCurrent();
sendSignalToValve();
turnOffAllValveRelays();
}
The Rain Bird 100DV 9v solenoid valve is turning ON when the RED wire is connected to the plus (+) of the 9v power supply and the BLACK wire to the minus (-). And it's turning OFF when the RED wire is connected to the minus (-) and the BLACK wire - to the plus (+).
I using the 1st relay for protection. I connect the + of the 9v power supply only when the other relays are configured in a way to have the required connection.
When I start the controller and power supply everything works like is expected. I successfully turn on and off the valves. After a few minutes (maybe 10 or more) the 4 relay module is working like expected (open and close the relays) but the valves most of the time don't react.
I disconnect and reconnect everything - improve the connection, and check the connections - everything is OK.
So what I'm doing wrong?
Thank you in advance for your support.