Water pump control

Hi ive built a Slow sand filter that i have being controled with a audrino nano right now, now im merging over to esphome. so far i have the binary sensors and the solid state relay setup, but now im having issues with the automation part on node red, im using a esp32 devkit v4 board. the sensors are connected thru touch sense, ive got the sensitivity all setup, but i want it to turn the pump off when it hits the high mark, and turn back on when it goes past the low mark, any help would be nice :slight_smile:

Bottem bolt is ground and the other two are where the pump comes on and off

Do you have a seperate sensor for high and low, or are you using a measurment device? Edit: ignore the question. :slight_smile:

The reason I ask is why are you doing it in node red when you can do it all with ESPhome?

Will look something like this:

switch:
  - platform: gpio
    pin: GPIO3
    name: "pump"

binary_sensor:
  - platform: gpio
    pin: GPIO4
    name: "low_sensor"
    on_press:
      then:
        - switch.turn_on: pump

binary_sensor:
  - platform: gpio
    pin: GPIO5
    name: "high_sensor"
    on_press:
      then:
        - switch.turn_off: pump

This assumes you have a sensor that closes when low reached and another that closes when high reached.

that is a better idea, keeping it just on the board and not running off node red, ill give that a try right now

K its close to working, now just gotta change the sending state on the low sensor around so when the water drop below the low sensor it shows sending state on

Or change: on_press: to on_release:

Hell ya! thanks for your help zoogara!
learning stuff everyday

have you ever played around with one of these? liquid level sensors
was going to put one in my systron, its just a 1200 liter tote

Nope - did read up on them when looking for tank sensors for a boat.

They just hook up to an analogue input pin then do a bit of math in lambda to convert to litres or percent full or whatever you want.

Read up on lambda filters.

so got the pump running now, it cycles proper, but now im not sure if u use Condition so when the water tank is full the pump wont turn on anymore even when the water drops below the low_sensor, i do have a 2 probes in the top of the tank

Pump Control

esp32_touch:
setup_mode: false

switch:

  • platform: gpio
    name: “Water Pump”
    pin: GPIO12
    id: pump

binary_sensor:

  • platform: esp32_touch
    name: “low_sensor”
    pin: GPIO13
    threshold: 300
    on_release:
    then:
    - switch.turn_on: pump

  • platform: esp32_touch
    name: “high_sensor”
    pin: GPIO14
    threshold: 300
    on_press:
    then:
    - switch.turn_off: pump

  • platform: esp32_touch
    name: “Water Tank Full”
    pin: GPIO27
    id: tank
    threshold: 300
    off_…:
    if:
    condition:

    Same syntax for is_off

    binary_sensor.is_on: tank

thats so far what i got, but when the water drops below the low_sensor it still wants to turn the pump on even tho the water tank is full

So not sure of your setup here, but first can you reformat your post. Any example code should be posted inside formatted text markers, use the </> button on the toolbar when posting / editing.

# Pump Control
esp32_touch:
  setup_mode: false

switch:
  - platform: gpio
    name: "Water Pump"
    pin: GPIO12
    id: pump
    
binary_sensor:
  - platform: esp32_touch
    name: "low_sensor"
    pin: GPIO13
    threshold: 300
    on_release:
      then:
        - switch.turn_on: pump
    
  - platform: esp32_touch
    name: "high_sensor"
    pin: GPIO14
    threshold: 300
    on_press:
      then:
        - switch.turn_off: pump
        
  - platform: esp32_touch
    name: "Water Tank Full"
    pin: GPIO27
    id: tank
    threshold: 300
    off_...:
  if:
    condition:
      # Same syntax for is_off
      binary_sensor.is_on: tank

just need help with that last part of code, soo when the water tank is full, the pump will no longer turn on, been trying condition, but no such luck

So for starters you indentation is off - I am surprised the editor din’t complain :).

Conditions go inside triggers, i.e.:

  - platform: esp32_touch
    name: "Water Tank Full"
    pin: GPIO27
    id: tank
    threshold: 300
    on_,,,:
      if:
        condition:
        # Same syntax for is_off
        binary_sensor.is_on: tank

But I am not sure a condition is what you need.

So you want the pump to come on when low trigger, off when high triggered, but always turn off on tank full regardless of the state of the other sensors? Correct?

It may help to just write out the logic required, or flowchart it, so we can understand the conditions and the action required under those conditions.

Binary sensors you would use on_state and binary_sensor.is_off: tank

- platform: esp32_touch
    name: "Water Tank Full"
    pin: GPIO27
    id: tank
    threshold: 300
    on_state:
      then:
        - binary_sensor.is_off: tank

when i try and add the lines like that i get a error for binary_sensor

try

- platform: esp32_touch
    name: "Water Tank Full"
    pin: GPIO27
    id: tank
    threshold: 300
    on_state:
      then:
        - if:
            condition:
              binary_sensor.is_off: tank
            then:
              switch.turn_on: relay

     


here is a mock up of what im doing

int waterfilterhigh = 0;
int waterfilterlow = 0;
int cisternfull = 0;
int minimum = 200; // this is the minimum value of analog reading
int pump = HIGH;

void setup()

{

  Serial.begin(9600);          //  setup serial
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(2, OUTPUT);
}



void loop()

{
  /*
  This blinks an LED so you know it's working
   */
  digitalWrite(13, HIGH);
  delay (1000);
  digitalWrite(13, LOW);
  delay(1000);

  
  /*
  This section check the level of the water in the filters
   */
  
  digitalWrite(11, HIGH);
  waterfilterhigh = analogRead(0);
  waterfilterlow = analogRead(1);
  cisternfull = analogRead(2);
  prefilterhigh = analogRead(3);
  prefilterlow = analogRead(4);
  digitalWrite(11, LOW);


  Serial.write( "Water Filter high water level - ");
  Serial.println(waterfilterhigh);
  Serial.write( "Water Filter low water level - ");
  Serial.println(waterfilterlow);
  Serial.write( "Cistern full - ");
  Serial.println(cisternfull);
  Serial.write( "Minimum Number for Electrodes - ");
  Serial.println(minimum);
  Serial.write("Pump on/off? - ");
  Serial.println(pump);


  }
  
  if (waterfilterlow < minimum) {
    pump = HIGH;
  }
 

  if (waterfilterhigh > minimum) {
    pump = LOW;
  }

  if (cisternfull > minimum) {
    pump = LOW;
  }

  digitalWrite(12, pump);

}

here is the code i had wrote for Audrino if that helps any, this code is working

only problem im having now with the stuff you guys have helped with is that when the water tank is full, that tthe pump cant turn on no mater what untill it drops below the sensors,