Read LED blinks for pump motor status

I have a water pressure pump with controller. The controller normally displays a green LED which is solid for “on” and blinking for “pumping”. However, if the system faults, it displays int eh same spot a Red LED, blinking. The blinks indicate the cause of the fault.

The blinks can be anywhere form 1 to 10 blinks, followed by a pause, then repeat.

I would like to use a GPIO to sense the Red LED, and trigger a notification, which will include an interpretation of the blink code.

I plan to install a 4-pin opto isolator to the Red leads of the dual LED, rather than having and optical sensor.

At this point I do not know the duration of the pulses, nor the duration of the pause. I would guess the pulses are on the order of 1 second (0.5 on, 0.5 off), and the pause may be several seconds.

Once I have a pulse counter on the ESP (I will be using a Wemos D1 Pro), I can handle the automations in HA to alert me. The ESP should contain one output that indicates a trip, and a second that indicates a number from 1 to 10 to indicate how many blinks.

Are there built-in reset-able counters, or do I need to build up a Lambda filter code to do this? Any suggestions would be helpful.

We have already incorporated the ESP to monitor tank level (with a small 50kpa pressure transducer) and to monitor well pump trips (two 240V coil relays, one before the pump monitor and one after). This current project is to monitor the variable speed pressure pump that lies between the storage tank and the house pressurized lines.

ESPHome made the setup of what we have so far very simple!

Thanks in advance for any ideas!

Chuck

I tried various ways to use the pulse counter, but could not seem to make it work. So I used some delays on on and off on a GPIO, and have a workable solution:

esphome:
  name: water_system
  platform: ESP8266
  board: nodemcuv2
  on_boot:
    - then:
      - lambda: |-
          id(p_err_active).publish_state(0);
          id(pressure_error).publish_state("Normal");
api:
  password: "XXXXXXXX"
  services:
    - service: clear_pressure_fault
      then:
        - lambda: |-
            id(pressure_error).publish_state("Normal");

binary_sensor:
  - platform: gpio
    name: "Red Pulse"
    internal: True
    pin:
      number: D5
      inverted: True
      mode: INPUT_PULLUP
    filters:
      - delayed_on: 10ms
    on_press:
      - then:
        - lambda: |-
            id(p_err_active).publish_state(id(p_err_active).state + 1);
  - platform: gpio
    name: "Red Pulses Done"
    internal: True
    pin:
      number: D5
      inverted: True
      mode: INPUT_PULLUP
    filters:
      - delayed_off: 1500ms
    on_release:
      - then:
        - logger.log:
            format: "The pulse counter reports value %.1f "
            args: [ 'id(p_err_active).state' ]
        - lambda: |-
            if(id(p_err_active).state == 1){
                id(pressure_error).publish_state("No Water/Loss of Prime");}
            else if(id(p_err_active).state == 2){
                id(pressure_error).publish_state("Tank Water Logged");}
            else if(id(p_err_active).state == 3){
                id(pressure_error).publish_state("Pressure Sensor Fault");}
            else if(id(p_err_active).state == 4){
                id(pressure_error).publish_state("Pump Bound");}
            else if(id(p_err_active).state == 5){
                id(pressure_error).publish_state("Short Circuit");}
            else if(id(p_err_active).state == 6){
                id(pressure_error).publish_state("Ground Fault");}
            else if(id(p_err_active).state == 7){
                id(pressure_error).publish_state("High Temperature");}
            else if(id(p_err_active).state == 8){
                id(pressure_error).publish_state("Over Voltage");}
            else if(id(p_err_active).state == 9){
                id(pressure_error).publish_state("Motor Overload");}
            else {
              id(pressure_error).publish_state("Unkown Error");}
            id(p_err_active).publish_state(0);

sensor:
  - platform: template
    name: "Pressure Error Active"
    id: p_err_active
text_sensor:
  - platform: template
    name: "Pressure Error"
    id: pressure_error
    update_interval: 60s

I am only showing the pertinent parts of the code. When the red led goes on (with a debounce delay), I increment p_error_active. When the Red LED then goes off for at least 1.5 seconds, I convert the count to a text message, and then clear the counter.

I also had to set initial states on boot (otherwise Nan), and set up an API service for a clear faults button in HA.

Seems to work well, at least with testing simulated blinks by momentarily connecting wires to the ESP board. I may have to adjust the duration when I get it hooked to the real pump controller.

Chuck

1 Like

Hi ceandra,

I have a solar hot water controller that has 2 led’s (one green, one red) that are either on solid or flash depending on modes or error codes. I am wanting a way to track these similar to what you have done.

Would you mind sharing the circuit you used and parts you needed to do it? If there is any other code that would be useful to know that would be great.

Thanks