ESP32 Dosing Pump

Home Assistant automation projects, questions, etc. go here.
morrisraybrooks
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 57
Joined: Fri Dec 04, 2020 3:27 am

i could so use some help here


i got it working some what
it passes ESPhome and up loaded to ESP32
im kinda lost as to where to go next im confused about the card part i guess
if you could look at my code and give a fella some direction thanks :?:

new ESP32 doser pump code
rename doser pump to = fertigation-doser-1
_________________________________________________________________
esphome:
name: fertigation-doser-1
platform: ESP32
board: esp32doit-devkit-v1
#-----------------------------------------------------------------------------------

wifi:
ssid: "!secret"
password: "!secret"
#-----------------------------------------------------------------------------------

# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Fertigation-Doser-1"
password: "UnzEmzcJOZpq"
#-----------------------------------------------------------------------------------

captive_portal:
#-----------------------------------------------------------------------------------

# Enable logging
logger:

# Enable Home Assistant API
api:
password: "!secret"
#-----------------------------------------------------------------------------------

ota:
password: "!secret"
#-----------------------------------------------------------------------------------
binary_sensor:
- platform: gpio
pin:
number: GPIO12
mode: INPUT_PULLUP
inverted: False
name: "Select Button"
on_press:
then:
- switch.turn_on: 'floragro'
- delay: !lambda "return id(floragro_pump_ml).state * 1300;"
- switch.turn_off: 'floragro'
- delay: 1s
- switch.turn_on: 'floramicro'
- delay: !lambda "return id(floramicro_pump_ml).state * 1300;"
- switch.turn_off: 'floramicro'
- delay: 1s
- switch.turn_on: 'florabloom'
- delay: !lambda "return id(florabloom_pump_ml).state * 1300;"
- switch.turn_off: 'florabloom'
- delay: 1s
- switch.turn_on: 'floralicious_plus'
- delay: !lambda "return id(floralicious_plus_pump_ml).state * 1300;"
- switch.turn_off: 'floralicious_plus'
- delay: 1s
- switch.turn_on: 'liquid_koolbloom'
- delay: !lambda "return id(liquid_koolbloom_pump_ml).state * 1300;"
- switch.turn_off: 'liquid_koolbloom'
- delay: 1s
- switch.turn_on: 'CALiMAGic'
- delay: !lambda "return id(CALiMAGic_pump_ml).state * 1300;"
- switch.turn_off: 'CALiMAGic'
- delay: 5s

- platform: gpio
pin:
number: GPIO14
mode: INPUT_PULLUP
inverted: False
name: "R.O. Valve"
on_press:
then:
- switch.toggle: 'ro_valve'

- platform: gpio
pin:
number: GPIO27
mode: INPUT_PULLUP
inverted: False
name: "Down Button"

- platform: gpio
pin:
number: GPIO26
mode: INPUT_PULLUP
inverted: False
name: "Up Button"


sensor:
- platform: homeassistant
name: "floramicro Pump Doser"
entity_id: input_number.floramicro_pump_ml
id: floramicro_pump_ml

- platform: homeassistant
name: "florabloom Pump Doser"
entity_id: input_number.florabloom_pump_ml
id: florabloom_pump_ml

- platform: homeassistant
name: "CALiMAGic Pump Doser"
entity_id: input_number.CALiMAGic_pump_ml
id: CALiMAGic_pump_ml

- platform: homeassistant
name: "liquid_koolbloom Pump Doser"
entity_id: input_number.liquid_koolbloom_pump_ml
id: liquid_koolbloom_pump_ml

- platform: homeassistant
name: "floralicious_plus Pump Doser"
entity_id: input_number.floralicious_plus_pump_ml
id: floralicious_plus_pump_ml

- platform: homeassistant
name: "floragro Pump Doser"
entity_id: input_number.floragro_pump_ml
id: floragro_pump_ml

- platform: homeassistant
name: "Nutrient Doser Toggle"
entity_id: input_boolean.nutrient_dosing_toggle
id: nutrient_dosing_toggle


switch:
- platform: gpio
pin: GPIO15
name: "Reverse Osmosis Valve"
id: ro_valve
inverted: yes
- platform: gpio
pin: GPIO02
name: 'floragro'
id: floragro
inverted: yes
- platform: gpio
pin: GPIO0
name: 'florabloom'
id: florabloom
inverted: yes
- platform: gpio
pin: GPIO04
name: 'floramicro'
id: floramicro
inverted: yes
- platform: gpio
pin: GPIO16
name: 'CALiMAGic'
id: CALiMAGic
inverted: yes
- platform: gpio
pin: GPIO17
name: 'floralicious_plus'
id: floralicious_plus
inverted: yes
- platform: gpio
pin: GPIO5
name: 'liquid_koolbloom'
id: liquid_koolbloom
inverted: yes
- platform: gpio
pin: GPIO18
name: 'PH Down'
inverted: yes


Configuration.yaml
___________________________________________________________________________________________________________________
esphome:
name: fertigation-doser-1
platform: ESP32
board: esp32doit-devkit-v1
#-----------------------------------------------------------------------------------

wifi:
ssid: "!secret"
password: "!secret"
#-----------------------------------------------------------------------------------

# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Fertigation-Doser-1"
password: "UnzEmzcJOZpq"
#-----------------------------------------------------------------------------------

captive_portal:
#-----------------------------------------------------------------------------------

# Enable logging
logger:

# Enable Home Assistant API
api:
password: "!secret"
#-----------------------------------------------------------------------------------

ota:
password: "!secret"
#-----------------------------------------------------------------------------------
binary_sensor:
- platform: gpio
pin:
number: GPIO12
mode: INPUT_PULLUP
inverted: False
name: "Select Button"
on_press:
then:
- switch.turn_on: 'floragro'
- delay: !lambda "return id(floragro_pump_ml).state * 1300;"
- switch.turn_off: 'floragro'
- delay: 1s
- switch.turn_on: 'floramicro'
- delay: !lambda "return id(floramicro_pump_ml).state * 1300;"
- switch.turn_off: 'floramicro'
- delay: 1s
- switch.turn_on: 'florabloom'
- delay: !lambda "return id(florabloom_pump_ml).state * 1300;"
- switch.turn_off: 'florabloom'
- delay: 1s
- switch.turn_on: 'floralicious_plus'
- delay: !lambda "return id(floralicious_plus_pump_ml).state * 1300;"
- switch.turn_off: 'floralicious_plus'
- delay: 1s
- switch.turn_on: 'liquid_koolbloom'
- delay: !lambda "return id(liquid_koolbloom_pump_ml).state * 1300;"
- switch.turn_off: 'liquid_koolbloom'
- delay: 1s
- switch.turn_on: 'CALiMAGic'
- delay: !lambda "return id(CALiMAGic_pump_ml).state * 1300;"
- switch.turn_off: 'CALiMAGic'
- delay: 5s

- platform: gpio
pin:
number: GPIO14
mode: INPUT_PULLUP
inverted: False
name: "R.O. Valve"
on_press:
then:
- switch.toggle: 'ro_valve'

- platform: gpio
pin:
number: GPIO27
mode: INPUT_PULLUP
inverted: False
name: "Down Button"

- platform: gpio
pin:
number: GPIO26
mode: INPUT_PULLUP
inverted: False
name: "Up Button"


sensor:
- platform: homeassistant
name: "floramicro Pump Doser"
entity_id: input_number.floramicro_pump_ml
id: floramicro_pump_ml

- platform: homeassistant
name: "florabloom Pump Doser"
entity_id: input_number.florabloom_pump_ml
id: florabloom_pump_ml

- platform: homeassistant
name: "CALiMAGic Pump Doser"
entity_id: input_number.CALiMAGic_pump_ml
id: CALiMAGic_pump_ml

- platform: homeassistant
name: "liquid_koolbloom Pump Doser"
entity_id: input_number.liquid_koolbloom_pump_ml
id: liquid_koolbloom_pump_ml

- platform: homeassistant
name: "floralicious_plus Pump Doser"
entity_id: input_number.floralicious_plus_pump_ml
id: floralicious_plus_pump_ml

- platform: homeassistant
name: "floragro Pump Doser"
entity_id: input_number.floragro_pump_ml
id: floragro_pump_ml

- platform: homeassistant
name: "Nutrient Doser Toggle"
entity_id: input_boolean.nutrient_dosing_toggle
id: nutrient_dosing_toggle


switch:
- platform: gpio
pin: GPIO15
name: "Reverse Osmosis Valve"
id: ro_valve
inverted: yes
- platform: gpio
pin: GPIO02
name: 'floragro'
id: floragro
inverted: yes
- platform: gpio
pin: GPIO0
name: 'florabloom'
id: florabloom
inverted: yes
- platform: gpio
pin: GPIO04
name: 'floramicro'
id: floramicro
inverted: yes
- platform: gpio
pin: GPIO16
name: 'CALiMAGic'
id: CALiMAGic
inverted: yes
- platform: gpio
pin: GPIO17
name: 'floralicious_plus'
id: floralicious_plus
inverted: yes
- platform: gpio
pin: GPIO5
name: 'liquid_koolbloom'
id: liquid_koolbloom
inverted: yes
- platform: gpio
pin: GPIO18
name: 'PH Down'
inverted: yes
morrisraybrooks
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 57
Joined: Fri Dec 04, 2020 3:27 am

20210401_152056.jpg
coming long with it
Attachments
20210319_215915.jpg
stud
LED Lover
LED Lover
Reactions:
Posts: 143
Joined: Wed Jun 03, 2020 4:19 pm
Location: Canada

morrisraybrooks wrote:
Sat Apr 03, 2021 6:18 am
20210401_152056.jpg coming long with it
NICE !!!!!!! im starting working on my dosers this week
morrisraybrooks
LED Enthusiast
LED Enthusiast
Reactions:
Posts: 57
Joined: Fri Dec 04, 2020 3:27 am

Ben working hard on the dowser
i got it working code so far in node red
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[{"id":"5481cbfb.aecf94","type":"delay","z":"8617c5f9.76abd","name":"","pauseType":"delayv","timeout":"0","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":440,"y":120,"wires":[["72a82a09.5be40c"]]},{"id":"c74ea08f.6b7e68","type":"api-call-service","z":"8617c5f9.76abd","name":"","server":"","version":1,"debugenabled":false,"service_domain":"fan","service":"turn_on","entityId":"fan.floramicro_doser_pump","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":620,"y":60,"wires":[[]]},{"id":"72a82a09.5be40c","type":"api-call-service","z":"8617c5f9.76abd","name":"","server":"","version":1,"debugenabled":false,"service_domain":"fan","service":"turn_off","entityId":"fan.floramicro_doser_pump","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":620,"y":120,"wires":[[]]},{"id":"84576030.e97cc","type":"inject","z":"8617c5f9.76abd","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"currentTime","payload":"$substring($now(),11,8)","payloadType":"jsonata","x":90,"y":80,"wires":[["718867e7.d749e8"]]},{"id":"14f70e24.f0041a","type":"server-state-changed","z":"8617c5f9.76abd","name":"","server":"","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_datetime.micro","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":160,"y":220,"wires":[["718867e7.d749e8"]]},{"id":"57a3a7e2.c4e648","type":"function","z":"8617c5f9.76abd","name":"","func":"// SET THIS CONSTANT TO HOWEVER LONG IT TAKES TO PUMP 1 LITER, IN SECONDS\nconst secondsPerLiter = 12; \n\nvar currentTime = msg.payload[\"currentTime\"];\n\n//CHANGE THE STRINGS BELOW IN GREEN TO THE ENTITY IDs OF YOUR INPUT_DATE TIMES \nvar fertTime1 = msg.payload[\"input_datetime.micro\"];\n//var fertTime2 = msg.payload[\"input_datetime.YOUR_FERTIGATION_DATETIME2\"];\n//var fertTime3 = msg.payload[\"input_datetime.YOUR_FERTIGATION_DATETIME3\"];\n\n//THIS CONVERTS YOUR 'LITERS' INPUT NUMBER TO PUMP TIME IN MILLISECONDS \nvar fertDuration = (msg.payload[\"input_number.micro\"] * secondsPerLiter) *1000;\n\n//THIS RETURNS THE DELAY TIME TO THE VARIABLE DELAY BLOCK\nmsg.delay = fertDuration;\n\n//IF ANY OF YOUR INPUT_DATETIMES MATCH THE CURRENT TIME, TURN ON THE PUMP AND THEN TURN OFF AFTER DELAY EXPIRES\nif(fertTime1 == currentTime)\n//if(fertTime1 == currentTime || fertTime2 == currentTime || fertTime3 == currentTime)\n {\n return msg;\n }\n \n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":280,"y":80,"wires":[["5481cbfb.aecf94","c74ea08f.6b7e68"]]},{"id":"718867e7.d749e8","type":"join","z":"8617c5f9.76abd","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"1","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":250,"y":140,"wires":[["846aced4.5c0e5","57a3a7e2.c4e648"]]},{"id":"846aced4.5c0e5","type":"debug","z":"8617c5f9.76abd","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":180,"wires":[]},{"id":"7fb8f9a9.79b7d","type":"server-state-changed","z":"8617c5f9.76abd","name":"Liters","server":"","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":"Alarm 1"},{"property":"icon","value":"mdi:fire"}],"entityidfilter":"input_number.micro","entityidfiltertype":"exact","outputinitially":true,"state_type":"num","haltifstate":"","halt_if_type":"num","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"x":70,"y":140,"wires":[["718867e7.d749e8"]]},{"id":"92ba335a.ab5dc","type":"comment","z":"8617c5f9.76abd","name":"Send the current time every second","info":"","x":160,"y":40,"wires":[]}]
Post Reply