Peristaltic dosing pumps setup

Home Assistant automation projects, questions, etc. go here.
warmachine
LED-Curious
LED-Curious
Reactions:
Posts: 18
Joined: Wed Sep 02, 2020 3:48 am

I got my peristaltic pumps this week. I would like to imitate the setup LEDg is using but, I can't figure out how to get node red or a script to run the ml per gallon. I don't know where to begin to do this. Turning them off and on and setting PWM speed is easy enough but, getting it to acurately pump nutrients is the goal. I looked at LEDg HA configs and it looks like he uses nodecommand in the yaml. I'm not familiar with this. I need some kind of calibration setup, I guess it could be done manually as long as I can get a milliliter command in HA or node red to calibrate with.

LEDg I know your busy but, a video on your pump setup or a writeup would be awesome. Also, your fertigation cards adding and subtracting from an input number? How did you do that? I think it's possible to upload Lovelace stuff now.
User avatar
LEDG
Site Admin
Reactions:
Posts: 1599
Joined: Sun Jun 04, 2017 8:15 pm

nodecommands is just my MQTT topic that I'm publishing to, in order to tell my control box to trigger the pumps. I just calibrated the pumps by tweaking PWM on each of them so that when I turn them on for X amount of time, I get Y amount of liquid.

Here is the code inside the vertical stack card for fertigations. Just add a vertical stack card, click "show code editor" in the bottom left and then paste this all in. Then add the binary sensors and input number slider as shown further down below.

Code: Select all

cards:
  - entities:
      - input_number.fertigation_freq
      - input_number.fertigation_duration
    show_header_toggle: false
    title: Fertigations
    type: entities
  - card:
      entities:
        - input_datetime.fert_1_time_4x4
      type: entities
    conditions:
      - entity: binary_sensor.fert_1
        state: 'on'
    type: conditional
  - card:
      entities:
        - input_datetime.fert_2_time_4x4
      type: entities
    conditions:
      - entity: binary_sensor.fert_2
        state: 'on'
    type: conditional
  - card:
      entities:
        - input_datetime.fert_3_time_4x4
      type: entities
    conditions:
      - entity: binary_sensor.fert_3
        state: 'on'
    type: conditional
  - card:
      entities:
        - input_datetime.fert_4_time_4x4
      type: entities
    conditions:
      - entity: binary_sensor.fert_4
        state: 'on'
    type: conditional
  - card:
      entities:
        - input_datetime.fert_5_time_4x4
      type: entities
    conditions:
      - entity: binary_sensor.fert_5
        state: 'on'
    type: conditional
type: vertical-stack
It relies on the state of 5 binary sensors I set up, and these go high or low depending on the "Frequency" input number slider in my UI.

Here are the binary sensors in my config file:

Code: Select all

binary_sensor:
  - platform: template
    sensors:
      fert_1:
        friendly_name: "One Fert"
        value_template: >-
          {{ states("input_number.fertigation_freq") | float >= 1.0 }}
  - platform: template
    sensors:
      fert_2:
        friendly_name: "Two Ferts"
        value_template: >-
          {{ states("input_number.fertigation_freq") | float >= 2.0 }}
  - platform: template
    sensors:
      fert_3:
        friendly_name: "Three Ferts"
        value_template: >-
          {{ states("input_number.fertigation_freq") | float >= 3.0 }}
  - platform: template
    sensors:
      fert_4:
        friendly_name: "Four Ferts"
        value_template: >-
          {{ states("input_number.fertigation_freq") | float >= 4.0 }}
  - platform: template
    sensors:
      fert_5:
        friendly_name: "Five Ferts"
        value_template: >-
          {{ states("input_number.fertigation_freq") | float >= 5.0 }}
Want to Support the Site?

Use this Amazon referral link and any purchase you make within 24 hrs will earn LEDgardener a commission at no cost to you!
warmachine
LED-Curious
LED-Curious
Reactions:
Posts: 18
Joined: Wed Sep 02, 2020 3:48 am

Thanks for the vertical card yaml. I had no idea you could add conditions to individual cards. Only took about 2min as soon as I understood it. This will help me do some other things as well.

Going over your yamls I couldn't find how the pumps actual put out a mL measurement. Your esp32 is setup to receive a command in SPD and mL? So your esp32 is doing the calculations for how many mL are output in a given time? It's not a bad way to do it but, I think I'm going to try and have all the calculations done in HA or nodeRed. That way I can use any microcontroller with PWM and easy change any values and have a backup of everything in case of fatal error. Also, should be easier for others to implement pumps. I should be able to have HA or nodeRed output a specific ml per Gal, the same as your esp32. I should have a little spare time in about a week to work on it.
warmachine
LED-Curious
LED-Curious
Reactions:
Posts: 18
Joined: Wed Sep 02, 2020 3:48 am

The solution I ended up using for hardware is a mosfet based LED strip controller. It can run on either 12v or 24v so they are a great fit for peristaltic pumps. I found some industrial 24v pumps I ended up using. The mosfets would heat up in about 10 seconds so, I ordered some small heatsinks to see if they would be effective enough. Turns out they work great! The mosfets stay very cool with the oversized heatsinks. For just over $20 you can have a 5ch wifi pump controller that runs off the same input voltage as the pumps. I would have used a shellyrgbw2 but, there is no room for a heatsink and only 4ch. I flashed them with ESPHome so they intergrate into HA with API. They are set as monochromatic lights so, I might need to figure out how to get gamma dimming turned off for a linear PWM dimming. Only thing left to do is build a PVC cabinet for the pumps and figure out how to get the calibration and dosing based off ml/gal into HA/nodeRed.

I don't know how to add LEDgardener amazon extension but, here is a link to the controller

also, available on bangood.

Heatsinks


ESPHome config

Code: Select all

substitutions:
  esphome_name: PumpDose
esphome:
  name: doserpump5ch2
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: "internet"
  password: "password"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Doserpump5Ch Fallback Hotspot"
    password: "3N2XT3lUhfms"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

light:
  - platform: monochromatic
    name: "${esphome_name}-1"
    output: pwm1
  - platform: monochromatic
    name: "${esphome_name}-2"
    output: pwm2
  - platform: monochromatic
    name: "${esphome_name}-3"
    output: pwm3
  - platform: monochromatic
    name: "${esphome_name}-4"
    output: pwm4
  - platform: monochromatic
    name: "${esphome_name}-5"
    output: pwm5

output:
  - platform: esp8266_pwm
    id: pwm1
    frequency: 1000 Hz
    pin: 14
  - platform: esp8266_pwm
    id: pwm2
    frequency: 1000 Hz
    pin: 12
  - platform: esp8266_pwm
    id: pwm3
    frequency: 1000 Hz
    pin: 13
  - platform: esp8266_pwm
    id: pwm4
    frequency: 1000 Hz
    pin: 15
  - platform: esp8266_pwm
    id: pwm5
    frequency: 1000 Hz
    pin: 5
Attachments
pump controller heatsink.jpg
pump controller.jpg
User avatar
LEDG
Site Admin
Reactions:
Posts: 1599
Joined: Sun Jun 04, 2017 8:15 pm

Hey, awesome! Thanks for sharing! I love seeing people improve on my attempts. I would really like to be able to move all my logic over to the HA side as well, and just leave the absolute essentials to the Arduinos.
Want to Support the Site?

Use this Amazon referral link and any purchase you make within 24 hrs will earn LEDgardener a commission at no cost to you!
warmachine
LED-Curious
LED-Curious
Reactions:
Posts: 18
Joined: Wed Sep 02, 2020 3:48 am

I'm asking questions on the HA forum on how to get a linear calibration done in template sensors so that you can set the PWM and it adjusts the calibration automatically. I thought about using 3 different calibrations low, med, high so I'd have some adjustment but, I'd rather figure out how to do it right and use PWM to scale with calibration. Until I figure that out here is the setup I just finished:
Template sensor calculates seconds required for dosing batch size.

Code: Select all

#Pump Calibration
      nutrient_batch_micro:
        friendly_name: "Micro Batch Seconds"
        icon_template: mdi:calendar
        value_template: "{{ ((float(states('input_number.nutrient_batch_size'))*(float(states('input_number.micro_ml_per_gallon')))) / ((float(states('input_number.calibration_results_micro')))/(float(states('input_number.calibration_time_micro'))))) | round(2) }}"
        unit_of_measurement: 'sec'
I stuck to LEDgardener inputs so, if you are using it you only have to add the 2 calibration input_numbers

Anyone should be able to use this sensor to do their automation in HA, NodeRed, or however they choose.
Attachments
mixing.jpg
warmachine
LED-Curious
LED-Curious
Reactions:
Posts: 18
Joined: Wed Sep 02, 2020 3:48 am

No help from the folks at HA but, I did manage to setup a linear PWM calibration based on a low and a high calibration. My pumps don't come on until about 55 so, I made an input_number for 60-100 to use as the base to change the 255 scale. Also, if the pumps weren't ON/running I couldn't pull a brightness for the calculations. So you need a PWM slider input number and 2 calibration time input numbers and 2 calibration results input numbers. I didn't include the PWM calibration points they are just listed 100 -60 but, you could add them dynamically too.

Code: Select all

      nutrient_batch_micro:
        friendly_name: "Micro Batch Seconds PWM"
        icon_template: mdi:calendar
        value_template: "{{ ((float(states('input_number.nutrient_batch_size'))*(float(states('input_number.micro_ml_per_gallon')))) / ((((((float(states('input_number.calibration_results_micro'))) / (float(states('input_number.calibration_time_micro')))) - ((float(states('input_number.calibration_results_micro_low')))/(float(states('input_number.calibration_time_micro_low')))))/(100 - 60)))*float(states('input_number.pumpdose_6_pwm'))+(((float(states('input_number.calibration_results_micro')))/(float(states('input_number.calibration_time_micro')))) - ((((float(states('input_number.calibration_results_micro')))/(float(states('input_number.calibration_time_micro')))) - ((float(states('input_number.calibration_results_micro_low')))/(float(states('input_number.calibration_time_micro_low')))))/(100 - 60))*100))) | round(2) }}"
        unit_of_measurement: 'sec'
I'm a newbie to any kind of coding so forgive the sloppyness.
I just finished so, I haven't had any time to clean up my front end but, I am pleased everything is working accurately on paper. Now I need to build a nice cabinet to start putting some pumps.
Attachments
PWM calibration change.jpg
PWM calibration.jpg
jaysal
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 75
Joined: Sat May 30, 2020 7:49 am

warmachine wrote:
Sun Nov 08, 2020 7:00 am
The solution I ended up using for hardware is a mosfet based LED strip controller. It can run on either 12v or 24v so they are a great fit for peristaltic pumps. I found some industrial 24v pumps I ended up using. The mosfets would heat up in about 10 seconds so, I ordered some small heatsinks to see if they would be effective enough. Turns out they work great! The mosfets stay very cool with the oversized heatsinks. For just over $20 you can have a 5ch wifi pump controller that runs off the same input voltage as the pumps. I would have used a shellyrgbw2 but, there is no room for a heatsink and only 4ch. I flashed them with ESPHome so they intergrate into HA with API. They are set as monochromatic lights so, I might need to figure out how to get gamma dimming turned off for a linear PWM dimming. Only thing left to do is build a PVC cabinet for the pumps and figure out how to get the calibration and dosing based off ml/gal into HA/nodeRed.

I don't know how to add LEDgardener amazon extension but, here is a link to the controller

also, available on bangood.

Heatsinks


ESPHome config

Code: Select all

substitutions:
  esphome_name: PumpDose
esphome:
  name: doserpump5ch2
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: "internet"
  password: "password"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Doserpump5Ch Fallback Hotspot"
    password: "3N2XT3lUhfms"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

light:
  - platform: monochromatic
    name: "${esphome_name}-1"
    output: pwm1
  - platform: monochromatic
    name: "${esphome_name}-2"
    output: pwm2
  - platform: monochromatic
    name: "${esphome_name}-3"
    output: pwm3
  - platform: monochromatic
    name: "${esphome_name}-4"
    output: pwm4
  - platform: monochromatic
    name: "${esphome_name}-5"
    output: pwm5

output:
  - platform: esp8266_pwm
    id: pwm1
    frequency: 1000 Hz
    pin: 14
  - platform: esp8266_pwm
    id: pwm2
    frequency: 1000 Hz
    pin: 12
  - platform: esp8266_pwm
    id: pwm3
    frequency: 1000 Hz
    pin: 13
  - platform: esp8266_pwm
    id: pwm4
    frequency: 1000 Hz
    pin: 15
  - platform: esp8266_pwm
    id: pwm5
    frequency: 1000 Hz
    pin: 5
This looks great! How were you able to flash with esphome? I don't see a micro USB port so I assume serial converter adapter?
stud
LED Lover
LED Lover
Reactions:
Posts: 143
Joined: Wed Jun 03, 2020 4:19 pm
Location: Canada

stud
LED Lover
LED Lover
Reactions:
Posts: 143
Joined: Wed Jun 03, 2020 4:19 pm
Location: Canada

warmachine wrote:
Sun Nov 15, 2020 6:22 am

Code: Select all

#Pump Calibration
      nutrient_batch_micro:
        friendly_name: "Micro Batch Seconds"
        icon_template: mdi:calendar
        value_template: "{{ ((float(states('input_number.nutrient_batch_size'))*(float(states('input_number.micro_ml_per_gallon')))) / ((float(states('input_number.calibration_results_micro')))/(float(states('input_number.calibration_time_micro'))))) | round(2) }}"
        unit_of_measurement: 'sec'
Thank You @warmachine , this template saved me a lot of time !
doserha.png
:geek: :geek: :geek: :geek:
Post Reply