Grundfos Well Controller

I am working with a Grundfos well pump that uses a CU301 controller. I am attempting to integrate it into Home Assistant with ESPHome. I would like it to have its typical functions accessible with the interface plugged in normally so all of the buttons and LEDs work if the ESP were to be offline.

Emulating the buttons is simple with a 200ms GPIO button output. However, due to the design of the circuit, the LEDs are posing a challenge. The LEDs use a common 10v DC+ line and switch the ground to illuminate. I’m wondering if anyone has an idea of how to integrate this so that a GPIO circuit can read the status of the LEDs. I have considered having the ESP board act as an LED controller, taking the inputs and controlling the LEDs separately, but this means that if the ESP stops working, I need to rewire the controller to allow for local control again.

I have attached a photo of the circuit board, if that helps. To the header, I have temporarily attached some wires for testing.

Thanks in advance!

I am also interested in this. Do you have any progress? How about using optocoupler (PC817)?

I found these articles regarding reading LED status:

It has a IR controller that runs $500+.
I am hoping to borrow one and try to scan its operation with a flipper.
It also has a INT Sensor pin on top right of board, but i haven’t figured what its for yet.

Guys, any progress on this? I have a CU 301 as well that I’d love to integrate with HA.

Any luck getting your hands on the controller (I assume you’re talking about the MI 301?)

Yes, progress here! A few months ago I managed to integrate Grundfos CU 301 pump controller into Home Assistant - I will try to share my solution and experiences :wink:

KIND WARNING:
If you don’t know what you are doing, don’t do that! Your device may be damaged. There is a risk of electric injury. All you do is at your own risk!

What I wanted to achieve:

  • know the state of pump (power state, if pump is running and low water level problem)
  • be able to turn it on and off
  • make it detachable in case of any problems (without irreversible changes)
  • for safety make it electrically isolated from the pump controller

Result:
ESPHome device:


from top - on/off push button, pump is running, (extra door sensor, humidity and temperature sensor), low water level problem and on/off state

Final Lovelace card:
image
from top: on/off switch, pump is running, low water level problem

What you need:

  • ESP32 development board running ESPHome
  • at least 3 optocouplers for LED state reading
    • I used this PC817 4-channel optocoupler board (but additional modification is needed)
    • maybe easier would be 3 single optocouplers (but more boards and cables to organize inside pump controller)
  • 3.3V 1-channel relay module for on/off button pressing
  • 40 pin header socket connector for connecting cables in a detachable way
  • some (dupont) cables
  • 5V power supply (I used this one on DIN rail)

How to do that:
Here is sketch of pins inside pump controller:


from left:
“LEDs section”

  • LED plus pole (there is voltage all the time ~10.2 V)
  • maintenance LED minus pole (is connected to ground when LED is active)
  • pumping top LED minus pole
  • pumping middle LED
  • pumping bottom LED
  • low water level LED
  • 5.0 bar LED
  • 4.5 bar LED
  • 4.0 bar LED
  • 3.5 bar LED
  • 3.0 bar LED
  • 2.5 bar LED
  • 2.0 bar LED
  • turned on LED
  • turned off LED
  • locked LED

“Buttons section” - for button pres shortly connect button to GND

  • on/off button
  • pressure plus button
  • pressure minus button
  • not used
  • not used
  • GND

Note: maybe it could vary based on your HW revision…don’t know

Everything else should be clear I think :grinning:

If not, in short:
LED state detection:
Use optocouplers to parallelly connect to LEDs - be careful because all optocouplers on the board have common GND but LEDs inside the pump controller have common (+) and they are turned on by connecting to GND. You cannot interchange poles on optocouplers so either use 1-channel optocouplers or “cut” the optocouplers board (on both sides) to disconnect them. Afterthat you can interconnect IN1, IN2 and IN3 on board to reduce wiring. On output side you can interconnect GNDs to reduce wiring to ESP. Then connect GND and V1, V2 and V3 to GND and GPIO pins on ESP.

On/off button press:
At first I wanted to use also optocoupler (in reverse way) to perform button press but it had too much resistance. So that I used standard relay.

Problems:
After some time I was experiencing problems with floating states on GPIOs. I also tried different GPIOs but after some time it was the same. The solution to that was to use ADC on ESP. Now I have “pump is running” and “low water level” on ADC and “power state” on digital GPIO and it is working…today I would put all the LEDs to ADCs. Note that not all pins on ESP32 can be used as ADC, see here.

ESPHome code:

...
switch:
  - platform: gpio
    pin:
      number: GPIO19
      inverted: true
    name: "On/Off button"
    id: on_off_button
    on_turn_on:
    - delay: 500ms
    - switch.turn_off: on_off_button

binary_sensor: 
  - platform: gpio
    pin:
      number: GPIO22
      mode:
        input: true
    filters:
      - delayed_off: 100ms
      - delayed_on: 1000ms
    id: "power_gpio"
  - platform: template
    name: "Power"
    lambda: "return id(power_gpio).state;"
    filters:
      - invert

  - platform: template
    name: "Pumping"
    lambda: "return id(pumping_voltage).state < 1;"
    device_class: running
    filters:
      - delayed_off: 5000ms

  - platform: template
    name: "Low water level"
    lambda: "return id(low_water_level_voltage).state < 1;"
    device_class: problem

sensor:
  - platform: adc
    pin: GPIO32
    id: pumping_voltage
    update_interval: 500ms
    attenuation: auto

  - platform: adc
    pin: GPIO33
    id: low_water_level_voltage
    update_interval: 5s
    attenuation: auto

Home Assistant switch:

- platform: template
  switches:
    well_pump:
      unique_id: well_pump
      value_template: "{{ is_state('binary_sensor.esphome_web_d0e77c_power', 'on') }}"
      turn_on:
        service: switch.turn_on
        target:
          entity_id: switch.esphome_web_d0e77c_on_off_button
      turn_off:
        service: switch.turn_on
        target:
          entity_id: switch.esphome_web_d0e77c_on_off_button

Gallery:

Good luck and hope it helps!

1 Like

Hi Saryn!

Actually good job!
I’m interested why didn’t you consider pressure sensor? Think this more valuable thing than other.

Alex.

I didn’t want to modify existing piping anymore (I don’t have much space there) and I also wanted to be able to turn off the pump remotely (in case of leakage or valve malfunction).

My idea was to use this connection
ced12422a9888c6f0a87cfe389012ca32a291ec1
It has pressure sensor danfoss mbs1900 on the end, I’m looking for the way how to get data from it.

Hi Gents!

So answering my question
I made some testing and discovered that pressure sensor returns the voltage depending on the actual pressure somewhere from 0 to 10v.
It has linear dependence with an offset.
ChatGPT helped me to build a formula.
But before you can use this signal with your ESP32 you have to downscale it to the range 0 to 3v (got instructions from ChatGPT as well))) using 2 resistors.
The important note is to use the same GND for esp32 and sensor, so you need to power esp32 from cu301 using LM2596S.

Instructions for yaml:

sensor:
  - platform: adc
    pin: GPIO34
    name: "Pressure Sensor Voltage"
    update_interval: 1s
    attenuation: 11db
    filters:
      - multiply: 6.69
      - lambda: |-
          return x - 0.923;
    unit_of_measurement: "bar"
    accuracy_decimals: 1

Need to calibrate a bit but in general i’m ok with it.

This scheme will work with any kind of such sensors for your automation.

Good luck.
Alexandr.