Przyszła wiosna więc zabawy z podlewaniem nadszedł czas
Dzięki @isom1266 udało mi się to zrobić, a z efektu finalnego jestem zadowolony, jedynie zasięg wifi jest strasznie słaby z tego ESP na płytce - mimo, że mam na dworze Ubiquiti UAP-AC-M co super pokrywa całe podwórko - a nawet i pół osiedla, to zasięg wifi z esp jest słaby - chyba przelutuje to esp32 na płytce na wersję z gniazdem do anteny zewnętrznej - między płytką, a AP jest ok 20m w linii prostej i jedyną przeszkodą po drodze jest drewniany domek w którym ta płytka jest,a zrywa połączenie, wg. esp sygnał wifi jest na poziomie -63dBi +/-5, a wg. unifi -88dBm ale TX Retries 42%.
Jakby ktoś zainteresowany był to mój kod do esphome wygląda tak, dodałem czujnik DHT22 do pomiaru wilgotności i temperatury oraz czujnik ciśnienia wody - kupiony na aliexpress 31.81zł 25% OFF|Nadajnik czujnika ciśnienia do wody oleju paliwa gazu powietrza G1/4 5V czujnik ceramiczny ze stali nierdzewnej 0.5Mpa 1.2Mpa przetwornik| | - AliExpress z racji, że czujnik na 5V to podłączony przez dzielnik 51kOhm i 100kOhm, czujnik ma zakres pracy 0-5V, i 0-10bar, ja mam max 4,3bara gdy zbiornik nabity - użyłem większego zakresu napięcia na wejściu, stąd attenuation: 11db (domyślnie jest 0 i wejście analogowe pracuje jako 0-1V).
substitutions:
### Modify only the following 6 lines.
zone_1_name: 1.Trawnik 1
zone_2_name: 2.Trawnik 2
zone_3_name: 3.Trawnik 3
zone_4_name: 4.Trawnik 4
zone_5_name: 5.Trawnik 5
zone_6_name: 6.Trawnik 6
zone_7_name: 7.Kroplownica
software_version: V1
sensor_update_frequency: 1s
log_level: none # Enable levels logging https://esphome.io/components/logger.html
# none, error, warn, info, debug (default), verbose, very_verbose
##############################################
# DO NOT CHANGE ANYTHING BELOW THIS LINE ###
##############################################
zone_1_valve_id: valve_0
zone_2_valve_id: valve_1
zone_3_valve_id: valve_2
zone_4_valve_id: valve_3
zone_5_value_id: value_4
zone_6_value_id: value_5
zone_7_value_id: value_6
esphome_name: podlewanie
esphome_platform: ESP32
esphome_board: esp32dev
esphome_comment: Irrigation Control
esphome_project_name: dar3k.Irrigation Control
esphome_project_version: Irrigation Controller, $software_version
devicename: irrigation_controller
upper_devicename: "Irrigation Controller"
uom: Min # this overrides the uom in sprinkler -> run_duration
#Define Project Deatils and ESP Board Type
esphome:
name: $esphome_name
platform: $esphome_platform
board: $esphome_board
comment: $esphome_comment
project:
name: $esphome_project_name
version: $esphome_project_version
on_boot:
priority: -100
then:
# Set default state for Valve Status
- text_sensor.template.publish:
id: valve_status
state: "Idle"
# Set multiplier to 60, convert seconds to minutes
- sprinkler.set_multiplier:
id: $devicename
multiplier: 60
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
logger:
# Enable Web server.
web_server:
port: 80
# Sync time with Home Assistant.
time:
- platform: homeassistant
id: homeassistant_time
api:
encryption:
key: "LjHIyJtf6N8iHqE6ev8j6XmUlzsvKt8AGdnyeguckLE="
ota:
password: "cfaa0c792a4c710253d485add7d61c37"
###############################################
# Text sensors with general information.
###############################################
text_sensor:
- platform: wifi_info
ip_address:
name: "$upper_devicename IP"
# Expose Time Remaining as a sensor.
- platform: template
id: time_remaining
name: $upper_devicename Time Remaining
update_interval: $sensor_update_frequency
icon: "mdi:timer-sand"
lambda: |-
int seconds = round(id($devicename).time_remaining_active_valve().value_or(0));
int days = seconds / (24 * 3600);
seconds = seconds % (24 * 3600);
int hours = seconds / 3600;
seconds = seconds % 3600;
int minutes = seconds / 60;
seconds = seconds % 60;
return {
((days ? String(days) + "d " : "") +
(hours ? String(hours) + "h " : "") +
(minutes ? String(minutes) + "m " : "") +
(String(seconds) + "s")).c_str()};
# Expose Progress Percent as a sensor.
- platform: template
id: progress_percent
name: $upper_devicename Progress %
update_interval: $sensor_update_frequency
icon: "mdi:progress-clock"
lambda: |-
int progress_percent = round(((id($devicename).valve_run_duration_adjusted(id($devicename).active_valve().value_or(0)) - id($devicename).time_remaining_active_valve().value_or(0)) * 100 / id($devicename).valve_run_duration_adjusted(id($devicename).active_valve().value_or(0))));
std::string progress_percent_as_string = std::to_string(progress_percent);
return progress_percent_as_string +"%";
# Expose Valve Status as a sensor.
- platform: template
id: valve_status
name: $upper_devicename Status
update_interval: never
icon: "mdi:information-variant"
sensor:
# Uptime sensor.
- platform: uptime
name: $upper_devicename Uptime
# WiFi Signal sensor.
- platform: wifi_signal
name: $upper_devicename WiFi Signal
update_interval: 120s
- platform: dht
pin: 4
temperature:
name: "Temperatura"
id: temperature_sensor
humidity:
name: "Wilgotnosc"
id: humidity_sensor
update_interval: 90s
- platform: adc
pin: A6
attenuation: 11db
name: "Water pressure"
unit_of_measurement: "bar"
update_interval: 1s
filters:
- multiply: 3.0303
number:
- platform: template
id: zone_1_valve_id
name: $zone_1_name
min_value: 1
max_value: 15
step: 1
unit_of_measurement: $uom
icon: "mdi:timer-outline"
mode: box # Defines how the number should be displayed in the UI
lambda: "return id($devicename).valve_run_duration(0);"
set_action:
- sprinkler.set_valve_run_duration:
id: $devicename
valve_number: 0
run_duration: !lambda 'return x;'
- platform: template
id: zone_2_valve_id
name: $zone_2_name
min_value: 1
max_value: 15
step: 1
unit_of_measurement: $uom
icon: "mdi:timer-outline"
mode: box # Defines how the number should be displayed in the UI
lambda: "return id($devicename).valve_run_duration(1);"
set_action:
- sprinkler.set_valve_run_duration:
id: $devicename
valve_number: 1
run_duration: !lambda 'return x;'
- platform: template
id: zone_3_valve_id
name: $zone_3_name
min_value: 1
max_value: 15
step: 1
unit_of_measurement: $uom
icon: "mdi:timer-outline"
mode: box # Defines how the number should be displayed in the UI
lambda: "return id($devicename).valve_run_duration(2);"
set_action:
- sprinkler.set_valve_run_duration:
id: $devicename
valve_number: 2
run_duration: !lambda 'return x;'
- platform: template
id: zone_4_valve_id
name: $zone_4_name
min_value: 1
max_value: 15
step: 1
unit_of_measurement: $uom
icon: "mdi:timer-outline"
mode: box # Defines how the number should be displayed in the UI
lambda: "return id($devicename).valve_run_duration(3);"
set_action:
- sprinkler.set_valve_run_duration:
id: $devicename
valve_number: 3
run_duration: !lambda 'return x;'
- platform: template
id: zone_5_valve_id
name: $zone_5_name
min_value: 1
max_value: 15
step: 1
unit_of_measurement: $uom
icon: "mdi:timer-outline"
mode: box # Defines how the number should be displayed in the UI
lambda: "return id($devicename).valve_run_duration(4);"
set_action:
- sprinkler.set_valve_run_duration:
id: $devicename
valve_number: 4
run_duration: !lambda 'return x;'
- platform: template
id: zone_6_valve_id
name: $zone_6_name
min_value: 1
max_value: 15
step: 1
unit_of_measurement: $uom
icon: "mdi:timer-outline"
mode: box # Defines how the number should be displayed in the UI
lambda: "return id($devicename).valve_run_duration(5);"
set_action:
- sprinkler.set_valve_run_duration:
id: $devicename
valve_number: 5
run_duration: !lambda 'return x;'
- platform: template
id: zone_7_valve_id
name: $zone_7_name
min_value: 1
max_value: 30
step: 1
unit_of_measurement: $uom
icon: "mdi:timer-outline"
mode: box # Defines how the number should be displayed in the UI
lambda: "return id($devicename).valve_run_duration(6);"
set_action:
- sprinkler.set_valve_run_duration:
id: $devicename
valve_number: 6
run_duration: !lambda 'return x;'
###############################################
# Main Sprinkler Controller
###############################################
sprinkler:
- id: $devicename
main_switch:
name: "Start/Stop/Resume"
id: main_switch
auto_advance_switch: "Auto Advance"
valve_open_delay: 4s
valves:
- valve_switch: $zone_1_name
enable_switch: Enable $zone_1_name
run_duration: 5s
valve_switch_id: ${devicename}_1
- valve_switch: $zone_2_name
enable_switch: Enable $zone_2_name
run_duration: 5s
valve_switch_id: ${devicename}_2
- valve_switch: $zone_3_name
enable_switch: Enable $zone_3_name
run_duration: 6s
valve_switch_id: ${devicename}_3
- valve_switch: $zone_4_name
enable_switch: Enable $zone_4_name
run_duration: 6s
valve_switch_id: ${devicename}_4
- valve_switch: $zone_5_name
enable_switch: Enable $zone_5_name
run_duration: 6s
valve_switch_id: ${devicename}_5
- valve_switch: $zone_6_name
enable_switch: Enable $zone_6_name
run_duration: 6s
valve_switch_id: ${devicename}_6
- valve_switch: $zone_7_name
enable_switch: Enable $zone_7_name
run_duration: 12s
valve_switch_id: ${devicename}_7
button:
- platform: template
id: sprinkler_pause
name: "Pauza"
icon: "mdi:pause"
on_press:
then:
- text_sensor.template.publish:
id: valve_status
state: "Paused"
- sprinkler.pause: $devicename
####################################################
# Switch Control to restart the irrigation system.
####################################################
switch:
- platform: restart
name: "Restart $devicename"
####################################################
# Hidden I/O Switches to control irrigation valve relays
####################################################
- platform: gpio
name: Relay Board Pin IN1
restore_mode: RESTORE_DEFAULT_OFF # Prevents GPIO pin from going high during boot
internal: true # Prevents GPIO switch NAME from showing up in Home Assistant
id: ${devicename}_1
on_turn_on:
- text_sensor.template.publish:
id: valve_status
state: "$zone_1_name Active"
on_turn_off:
- text_sensor.template.publish:
id: valve_status
state: "Idle"
pin: GPIO32
inverted: false
- platform: gpio
name: Relay Board Pin IN2
restore_mode: RESTORE_DEFAULT_OFF # Prevents GPIO pin from going high during boot
internal: true # Prevents GPIO switch NAME from showing up in Home Assistant
id: ${devicename}_2
on_turn_on:
- text_sensor.template.publish:
id: valve_status
state: "$zone_2_name Active"
on_turn_off:
- text_sensor.template.publish:
id: valve_status
state: "Idle"
pin: GPIO33
inverted: false
- platform: gpio
name: Relay Board Pin IN3
restore_mode: RESTORE_DEFAULT_OFF # Prevents GPIO pin from going high during boot
internal: true # Prevents GPIO switch NAME from showing up in Home Assistant
id: ${devicename}_3
on_turn_on:
- text_sensor.template.publish:
id: valve_status
state: "$zone_3_name Active"
on_turn_off:
- text_sensor.template.publish:
id: valve_status
state: "Idle"
pin: GPIO25
inverted: false
- platform: gpio
name: Relay Board Pin IN4
restore_mode: RESTORE_DEFAULT_OFF # Prevents GPIO pin from going high during boot
internal: true # Prevents GPIO switch NAME from showing up in Home Assistant
id: ${devicename}_4
on_turn_on:
- text_sensor.template.publish:
id: valve_status
state: "$zone_4_name Active"
on_turn_off:
- text_sensor.template.publish:
id: valve_status
state: "Idle"
pin: GPIO26
inverted: false
- platform: gpio
name: Relay Board Pin IN5
restore_mode: RESTORE_DEFAULT_OFF # Prevents GPIO pin from going high during boot
internal: true # Prevents GPIO switch NAME from showing up in Home Assistant
id: ${devicename}_5
on_turn_on:
- text_sensor.template.publish:
id: valve_status
state: "$zone_5_name Active"
on_turn_off:
- text_sensor.template.publish:
id: valve_status
state: "Idle"
pin: GPIO27
inverted: false
- platform: gpio
name: Relay Board Pin IN6
restore_mode: RESTORE_DEFAULT_OFF # Prevents GPIO pin from going high during boot
internal: true # Prevents GPIO switch NAME from showing up in Home Assistant
id: ${devicename}_6
on_turn_on:
- text_sensor.template.publish:
id: valve_status
state: "$zone_6_name Active"
on_turn_off:
- text_sensor.template.publish:
id: valve_status
state: "Idle"
pin: GPIO14
inverted: false
- platform: gpio
name: Relay Board Pin IN7
restore_mode: RESTORE_DEFAULT_OFF # Prevents GPIO pin from going high during boot
internal: true # Prevents GPIO switch NAME from showing up in Home Assistant
id: ${devicename}_7
on_turn_on:
- text_sensor.template.publish:
id: valve_status
state: "$zone_7_name Active"
on_turn_off:
- text_sensor.template.publish:
id: valve_status
state: "Idle"
pin: GPIO12
inverted: false
- platform: gpio
pin: GPIO13
name: Przekaznik
id: Przekaznik
binary_sensor:
- platform: gpio
pin:
number: GPIO0
inverted: true
name: "Przycisk"
on_press:
then:
- switch.toggle: main_switch
- platform: gpio
pin:
number: GPIO15
mode:
input: true
name: "Czujnik deszczu"
filters:
- delayed_on: 50ms
- delayed_off: 50ms
Zrobione
Pozostało do zrobienia - podłączyć czujnik deszczu - musi on być podłączony jako bezpotencjałowy - tak aby dawał zwarcie / rozwarcie. Dorobię przy czasie - bo tam chyba też trzeba z rezystorami coś kombinować aby poprawnie wykrywało.