Skip to content

Commit

Permalink
feat: Add LED reflecting safety limit
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierBerger authored Dec 20, 2024
2 parents 9c6680c + f9e905b commit ac5b415
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 12 deletions.
9 changes: 7 additions & 2 deletions docs/temperature_limiter_DS18B20.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This package is designed to monitor a temperature coming from a DS18B20 sensor connected on ESP32 and determines if a temperature threshold as been reached or not.

When safety limit is reached, it is possible to turn on a LED. LED configuration has to be added in `substitutions` section as explained bellow.

!!! danger "WARNING: Conduct some tests before letting the system regulate alone"
This temperature limit monitoring and safety limit may have some bug. It is strongly advised to validate the behaviour of your system carefully before letting the system working by its own.

Expand All @@ -22,9 +24,12 @@ This package needs to know the GPIO used by the temperature to get the temperatu

```yaml linenums="1"
substitutions:
# Power meter source -----------------------------------------------------------
# Sensor in home assistant gathering the hot water temperature
# Sensor in home assistant gathering the temperature
DS18B20_pin: GPIO13
# Safety limit LED configuration
red_led_inverted: "False"
red_led_pin: GPIO4
```

Additionnal optional parameters can be set into `substitutions` section such as `DS18B20_address` (which is optional) and `temperature_update_interval` (which is set by default to `5s`).
8 changes: 6 additions & 2 deletions docs/temperature_limiter_home_assistant.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This package is designed to monitor a temperature coming from a sensor in Home Assistant and determines if a temperature threshold as been reached or not.

When safety limit is reached, it is possible to turn on a LED. LED configuration has to be added in `substitutions` section as explained bellow.

!!! danger "WARNING: Conduct some tests before letting the system regulate alone"
This temperature limit monitoring and safety limit may have some bug. It is strongly advised to validate the behaviour of your system carefully before letting the system working by its own.

Expand All @@ -18,9 +20,11 @@ This package needs to know the sensor to use to get the temperature to monitor.

```yaml linenums="1"
substitutions:
# Power meter source -----------------------------------------------------------
# Sensor in home assistant gathering the hot water temperature
# Sensor in home assistant gathering the temperature
temperature_sensor: sensor.hot_water_temperature
# Safety limit LED configuration
red_led_inverted: "False"
red_led_pin: GPIO4
```
!!! warning "Data availability and refresh rate"
This temperature limiter rely on Home Assistant to gather the temperature. It also depends on the rate of sensor update. If a sensor is updated too slowly, the regulation may not work as expected.
2 changes: 2 additions & 0 deletions esp32-standalone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ substitutions:

# Temperature sensor
temperature_sensor: "input_number.test_temperature"
red_led_pin: GPIO4


# Uncomment the following lines if you want to use the source from github
# packages:
Expand Down
1 change: 1 addition & 0 deletions esp32-standalone_DS18B20.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ substitutions:
# Temperature sensor
DS18B20_pin: GPIO13
temperature_update_interval: 1s
red_led_pin: GPIO4

# Uncomment the following lines if you want to use the source from github
# packages:
Expand Down
5 changes: 3 additions & 2 deletions solar_router/temperature_limiter_DS18B20.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<<: !include temperature_limiter_common.yaml

substitutions:
DS18B20_address: "0"
temperature_update_interval: 5s
red_led_inverted: "False"

<<: !include temperature_limiter_common.yaml

one_wire:
- platform: gpio
Expand Down
29 changes: 23 additions & 6 deletions solar_router/temperature_limiter_common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
# then safety_limit is set to False
# ... or the opposit if you want to use it for a cooling system
esphome:
on_boot:
priority: -1000.0
then:
- script.execute: safety_limit_check
on_boot:
priority: -1000.0
then:
- script.execute: safety_limit_check

globals:
- id: used_for_cooling
Expand Down Expand Up @@ -67,6 +67,7 @@ script:
if ( isnan( id(safety_temperature).state ) ){
// Can't read temperature. Activatinf safety limit.
id(safety_limit) = true;
id(red_led).turn_on();
return;
}
if(id(safety_limit))
Expand Down Expand Up @@ -97,7 +98,7 @@ script:
// Temperature has enough decreased we stop the cooling system
if (id(safety_temperature).state <= id(stop_temperature).state)
{
// Limit is no more reached, regulation can restart
// Limit is reached, stop regulation
id(safety_limit) = true;
}
}
Expand All @@ -106,8 +107,24 @@ script:
// Temperature has enough increased we stop the heating system
if (id(safety_temperature).state >= id(stop_temperature).state)
{
// Limit is no more reached, regulation can restart
// Limit is reached, stop regulation
id(safety_limit) = true;
}
}
}
if ( id(safety_limit) )
{
id(red_led).turn_on();
}
else
{
id(red_led).turn_off();
}
output:
- id: red_led
platform: gpio
pin:
number: ${red_led_pin}
inverted: ${red_led_inverted}

2 changes: 2 additions & 0 deletions solar_router/temperature_limiter_home_assistant.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# ----------------------------------------------------------------------------------------------------
# Define sensor for temperaturewer collection
# ----------------------------------------------------------------------------------------------------
substitutions:
red_led_inverted: "False"

<<: !include temperature_limiter_common.yaml

Expand Down
95 changes: 95 additions & 0 deletions wt32-eth01-standalone_triac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# ----------------------------------------------------------------------------------------------------
# ESPHome configuration - This part depends on your hardware target
# ----------------------------------------------------------------------------------------------------

esphome:
name: wt32-eth01-2
friendly_name: wt32-eth01-2

esp32:
board: wt32-eth01
framework:
type: arduino

# Enable logging
logger:
baud_rate: 115200
level: INFO
logs:
component: ERROR
light: ERROR
http_request.arduino: ERROR

# Enable Home Assistant API
api:
encryption:
key: !secret wt32_eth01_2_api_encryption_key

# Enable over-the-air updates
ota:
- platform: esphome
password: !secret wt32_eth01_2_ota_password

# WiFi connection
# To activate WiFi :
# Uncomment this section parameters and comment RJ45 ethernet section
#wifi:
# ssid: !secret wifi_ssid
# password: !secret wifi_password
# # If you have a WiFi activity plannification, you may have to update the reboot timeout (Default: 15min)
# reboot_timeout: 24h

# Configure RJ45 ethernet
# To activate RJ45 ethernet :
# Uncomment this section parameters and comment WiFi section
ethernet:
type: LAN8720
mdc_pin: GPIO23
mdio_pin: GPIO18
clk_mode: GPIO0_IN
phy_addr: 1
power_pin: GPIO16

# Activate web interface
web_server:
port: 80

# ----------------------------------------------------------------------------------------------------
# Customisation
# ----------------------------------------------------------------------------------------------------
# This part of the script is designed to be use for customisation. It shouldn't be necessary to
# edit other part of the script to perform configuration.

substitutions:
# Power meter source -----------------------------------------------------------
# Define ip address of Power Meter (Fronius Inverter)
power_meter_ip_address: "192.168.1.21"

# Regulator configuration
# Define GPIO pin connected to AC Dimmer for gate and zero crossing detection.
regulator_gate_pin: GPIO17 # TXD
regulator_zero_crossing_pin: GPIO39

# LEDs -------------------------------------------------------------------------
# Green LED is reflecting regulation status
# Yellow LED is reflecting power meter status
green_led_pin: GPIO32 # CFG
yellow_led_pin: GPIO14

# Temperature sensor
DS18B20_pin: GPIO02
temperature_update_interval: 1s
red_led_pin: GPIO4

packages:
common:
<<: !include solar_router/common.yaml
power_meter:
<<: !include solar_router/power_meter_fronius.yaml
regulator:
<<: !include solar_router/regulator_triac.yaml
solar_router:
<<: !include solar_router/engine.yaml
temperature_limiter:
<<: !include solar_router/temperature_limiter_DS18B20.yaml

0 comments on commit ac5b415

Please sign in to comment.