esphome weather staion v5

This commit is contained in:
root
2024-06-14 23:03:05 +12:00
parent 8851f8da5e
commit 6ff9e38e5f
4 changed files with 87 additions and 24 deletions

View File

@@ -8,6 +8,7 @@
# zorruno 2024-05-25 V2 A bunch more sensors added (wind direction not yet sorted)
# zorruno 2024-05-25 V3 Shuffled some sensors, rain count added
# zorruno 2024-06-03 V4 tweaks to battery and wind
# zorruno 2024-06-14 V5 added wind heading, and sorted breaking a change for OTA
#############################################
#############################################
@@ -25,9 +26,11 @@
# bmp280: Temp/pressure on the board (0x76 i2c)
# pulse_meter: Wind Speed (GPIO14)
# pulse_meter: Rainfall (GPIO12)
# ads1115 A0_GND: Wind Direction
#
# text_sensor: Beaufort Wind Scale Labelling
# text_sensor: Temp (av) Average of all temps
# text_sensor: Wind Direction Heading
#
# Battery Calcs:
# template: Last 30mins battery MAX
@@ -37,9 +40,6 @@
# TO TEST (HAVE SENSOR or doesn't need one)
# tsl2561: Ambient Light sensor (0x39 i2c)
# ads1115 A1_GND: UV Index
# ads1115 A0_GND: Wind Direction
#
# ORDERED BUT DON'T HAVE YET
# ltr390: Ambient Light and UV sensor (0x53 i2c)
# pmsx003: PM Particulate Filter (UART)
# AS3935: lightning sensor (i2c, but needs design)
@@ -170,12 +170,18 @@ api:
# https://esphome.io/components/ota.html?highlight=ota
#############################################
ota:
safe_mode: true #Safe mode will detect boot loops
password: ${ota_pass}
- platform: esphome
#safe_mode: true #Safe mode will detect boot loops
password: ${ota_pass}
#############################################
# Wifi Settings
# https://esphome.io/components/wifi.html
#
# Power Save mode (can reduce wifi reliability)
# NONE (least power saving, Default for ESP8266)
# LIGHT (Default for ESP32)
# HIGH (most power saving)
#############################################
wifi:
ssid: ${wifi_ssid}
@@ -266,9 +272,9 @@ text_sensor:
id: wind_scale
update_interval: never
- platform: template
name: ${friendly_name} Wind Direction
name: ${friendly_name} Wind Direction wind_dir_heading
icon: "mdi:tailwind"
id: wind_dir
id: wind_dir_heading
update_interval: never
#############################################
@@ -624,14 +630,56 @@ sensor:
- platform: ads1115
multiplexer: 'A0_GND'
gain: 4.096
name: ${friendly_name} Wind Direction
id: wind_direction
name: ${friendly_name} Wind Direction Voltage
id: wind_direction_voltage
update_interval: 2s
# measured V Max: 3.31 Min: 0.585
#- calibrate_linear
# Map 0.0 (from sensor) to 0.0 (true value)
# - 0.585 -> 0
# - 3.31 -> 100
################################################################
# CONVERT VOLTAGE TO HEADING
# Current version used only has 8 heding points, some have 16.
#
# Bear R Head Meas'd Max Min
# (deg) (Ohms) Volts V+1% V-1%
# ---------------------------------------------
# 0 33000 N 2.900 2.9290 2.8710
# 22.5 6570 NNE
# 45 8200 NE 2.108 2.1290 2.0869
# 67.5 891 ENE
# 90 1000 E 0.584 0.5898 0.5782
# 112.5 688 ESE
# 135 2200 SE 1.061 1.0716 1.0504
# 157.5 1410 SSE
# 180 3900 S 1.506 1.5211 1.4910
# 202.5 3140 SSW
# 225 16000 SW 2.560 2.5856 2.5344
# 247.5 14120 WSW
# 270 120000 W 3.186 3.2178 3.1541
# 292.5 42120 WNW
# 315 64900 NW 3.088 3.1188 3.0571
# 337.5 21880 NNW
################################################################
on_value:
lambda: |-
if (id(wind_direction_voltage).state >= 0.57816 && id(wind_direction_voltage).state <= 0.58984) {
id(wind_dir_heading).publish_state("E");
} else if (id(wind_direction_voltage).state >= 1.05039 && id(wind_direction_voltage).state <= 1.07161) {
id(wind_dir_heading).publish_state("SE");
} else if (id(wind_direction_voltage).state >= 1.49094 && id(wind_direction_voltage).state <= 1.52106) {
id(wind_dir_heading).publish_state("S");
} else if (id(wind_direction_voltage).state >= 2.08692 && id(wind_direction_voltage).state <= 2.12908) {
id(wind_dir_heading).publish_state("NE");
} else if (id(wind_direction_voltage).state >= 2.5344 && id(wind_direction_voltage).state <= 2.5856) {
id(wind_dir_heading).publish_state("SW");
} else if (id(wind_direction_voltage).state >= 2.871 && id(wind_direction_voltage).state <= 2.929) {
id(wind_dir_heading).publish_state("N");
} else if (id(wind_direction_voltage).state >= 3.05712 && id(wind_direction_voltage).state <= 3.11888) {
id(wind_dir_heading).publish_state("NW");
} else if (id(wind_direction_voltage).state >= 3.15414 && id(wind_direction_voltage).state <= 3.21786) {
id(wind_dir_heading).publish_state("W");
} else {
id(wind_dir_heading).publish_state("");
}
# filters:
# lambda: |-
@@ -655,23 +703,23 @@ sensor:
# on_value:
# lambda: |-
# if (id(wind_direction_voltage).state * (360.0/5.0) >= 10.0 && id(wind_direction_voltage).state * (360.0/5.0) <= 70.0) {
# id(wind_dir).publish_state("45");
# id(wind_dir_heading).publish_state("45");
# } else if (id(wind_direction_voltage).state * (360.0/5.0) = 70.0 && id(wind_direction_voltage).state * (360.0/5.0) <= 120.0) {
# id(wind_dir).publish_state("90");
# id(wind_dir_heading).publish_state("90");
# } else if (id(wind_direction_voltage).state * (360.0/5.0) = 120.0 && id(wind_direction_voltage).state * (360.0/5.0) <= 170.0) {
# id(wind_dir).publish_state("135");
# id(wind_dir_heading).publish_state("135");
# } else if (id(wind_direction_voltage).state * (360.0/5.0) = 170.0 && id(wind_direction_voltage).state * (360.0/5.0) <= 215.0) {
# id(wind_dir).publish_state("180");
# id(wind_dir_heading).publish_state("180");
# } else if (id(wind_direction_voltage).state * (360.0/5.0) = 215.0 && id(wind_direction_voltage).state * (360.0/5.0) <= 262.0) {
# id(wind_dir).publish_state("225");
# id(wind_dir_heading).publish_state("225");
# } else if (id(wind_direction_voltage).state * (360.0/5.0) = 262.0 && id(wind_direction_voltage).state * (360.0/5.0) <= 330.0) {
# id(wind_dir).publish_state("270");
# id(wind_dir_heading).publish_state("270");
# } else if (id(wind_direction_voltage).state * (360.0/5.0) = 330.0 && id(wind_direction_voltage).state * (360.0/5.0) <= 355.0) {
# id(wind_dir).publish_state("315");
# id(wind_dir_heading).publish_state("315");
# } else if (id(wind_direction_voltage).state * (360.0/5.0) = 355.0 && id(wind_direction_voltage).state * (360.0/5.0) <= 360.0) {
# id(wind_dir).publish_state("0");
# id(wind_dir_heading).publish_state("0");
# } else {
# id(wind_dir).publish_state("0");
# id(wind_dir_heading).publish_state("0");
# }
# - platform: ads1115