Pressurized water

Hello, good evening is my first post.

I have been using BLYNK for a long time in my home with LOCALSERVER and the truth never ceases to amaze me …

I’m in doubt since I do not have another SHIELD to do the test

Before uploading the code LIVE I want to ask several questions.

The idea here is:

THAT AFTER 14 HOURS

The “BombaPresurizadora” has to turn on and “SelenoideTanke” has to turn ON.

void presurizadora()
{
  if (hour() < 14)
  {
    if (EstadoBombaPresurizadora != HIGH) {
      EstadoBombaPresurizadora = !EstadoBombaPresurizadora;
      digitalWrite(BombaPresurizadora, EstadoBombaPresurizadora);
      Blynk.virtualWrite(V11, EstadoBombaPresurizadora);
      digitalWrite(SelenoideTanke, LOW);
      Blynk.virtualWrite(V10, SelenoideTanke );
      Blynk.notify("Agua Normal");

      EstadoBombaPresurizadora = HIGH;
    } else {
      EstadoBombaPresurizadora = LOW;
      digitalWrite(BombaPresurizadora, HIGH);
      Blynk.notify("Agua Presurizada");
    }
  }
}

The second question is related to the same

The idea is that if after 5 AM the “SensorPorton” is LOW - the “ReflectorPorton” should be set to HIGH.

When the “SensorPorton” is no longer LOW - the “ReflectorPorton” should be set to LOW.

void portonabierto()
{
  if (hour() < 05) {
    if (digitalRead(SensorPorton) == LOW) {
      if (EstadoSensorPorton != LOW) {
        EstadoReflectorPorton = !EstadoReflectorPorton;
        digitalWrite(ReflectorPorton, HIGH);
        Blynk.virtualWrite(V3, HIGH);
        Blynk.notify("Porton Abierto");
      }
      EstadoSensorPorton = LOW;
    } else {
      EstadoSensorPorton = HIGH;
      digitalWrite(ReflectorPorton, LOW);
      Blynk.virtualWrite(V3, LOW);
    }
  }
}

The other question I also have is to know the subject of intervals well.

   timer.setInterval (100L, portonabierto);
   timer.setInterval (1000L, presurizadora);

I attach all the complete code here, it has other things that I control.

Pastebin

Thank you very much to everyone who can help me.

PS: I’m from ARGENTINA & use the translator.

Hi,
Well, regarding the timers I’d choose a different timing…

timer.setInterval(106L, checkbotones);
timer.setInterval(1731L, temperaturayhumedad);
timer.setInterval(11627L, checkconnect);
timer.setInterval(127L, portonabierto);
timer.setInterval(1031L, presurizadora);

Regarding the portonabierto and checkbotones I’d use interrupts (but that’s just me) anyway, if the portonabierto is a reed switch it should be enough checking it once a second… for the rest I can’t reply ‘cause I’m on my iPhone, too much to type :nerd_face:

1 Like

I’m struggling with the logic of what you’re trying to do here:

This could be re-written as:

    if (EstadoBombaPresurizadora == LOW) {
      EstadoBombaPresurizadora = HIGH; // This was LOW, now setting it to HIGH
      digitalWrite(BombaPresurizadora, HIGH);
      Blynk.virtualWrite(V11, "HIGH");  // Not sure what sort of widget V11 is
      digitalWrite(SelenoideTanke, LOW);
      Blynk.virtualWrite(V10, SelenoideTanke );
      Blynk.notify("Agua Normal");
      //EstadoBombaPresurizadora = HIGH; - Not needed as EstadoBombaPresurizadora is already HIGH
    } else {
      EstadoBombaPresurizadora = LOW; // This was HIGH, now setting it to LOW
      digitalWrite(BombaPresurizadora, HIGH); // This is set to HIGH in the IF above, so it will always be HIGH, regardless of how the IF statement evaluates. Better to move it out of the IF statement
      Blynk.notify("Agua Presurizada");
    }

The re-written code doesn’t make much sense to me from a logic point of view, and it’s all very sloppy.

Pete.

SOLVED…

void presurizadora()
{
  if (hour() >= 19)
  {
    digitalWrite(BombaPresurizadora, HIGH);
    Blynk.virtualWrite(V11, "HIGH");
    Blynk.virtualWrite(V51, "Agua Presurizada");
    Serial.println("Presurizadora ON");
    EstadoBombaPresurizadora = HIGH;
  } else {
    EstadoBombaPresurizadora = LOW;
    digitalWrite(BombaPresurizadora, LOW);
    Blynk.virtualWrite(V11, "LOW");
    Blynk.virtualWrite(V51, "Agua Normal");
    Serial.println("Presurizadora OFF");
    Serial.println(hour());

  }
}
1 Like

That makes MUCH more sense.

Pete.