NodeMCU & Sprinkler system


#1

I am still building the sprinkler system, so everything is still on my desk :slight_smile:.

I’m using NodeMCU to control the relays, and I have a 8 channel relay.

Got all the code into my openhab config, and I have managed to load the code into the NodeMCU and I am able to control the relays via the OpenHab iPhone app, but I have a problem that I’m not sure how to solve.

On power up, all the relay’s start up in the “on” or “make” position. Once implemented this would mean on a power situation, all the sprinklers would be open. Not ideal as you can imagine.

Any ideas on how I would solve that?


#2

I managed to solve it, but it is an ugly workaround.

// set pin modes
pinMode(channel1, OUTPUT);
digitalWrite(channel1, HIGH);

Now I thought HIGH, would send the “on” command to the relay, making it, but for some reason, in this case it doesn’t.

I also had to change my code like this…

if (msgString == “Z1ON”)
{
digitalWrite(channel1, LOW);
delay(250);
}
else if (msgString == “Z1OFF”)
{
digitalWrite(channel1, HIGH);
delay(250);
}

Not sure how I cocked this up. But it’s working. Next project.
Be nice if someone could add some insights.
:slight_smile: