Last active
December 10, 2023 09:19
-
-
Save Kalkran/d924a0ada197fa1c68df3708eae4ce86 to your computer and use it in GitHub Desktop.
ESPHome YAML for Orcon MV using @hubertjanhickinson's PCB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Be sure to check the revisions if necessary. | |
# Last update 2022-08-14. | |
esphome: | |
name: orconmv | |
platform: ESP8266 | |
board: d1_mini | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_pass | |
# Fallback hotspot | |
ap: | |
ssid: "Orcon MV Fallback" | |
password: !secret wifi_pass | |
captive_portal: | |
logger: | |
api: | |
ota: | |
# Pinout | |
# D0 - DHT11 | |
# D1 - PWM in (requested speed) | |
# D2 - Pulse per revolution (tachometer) | |
# | |
# D6 - PWM out (set speed) | |
# D8 - Relay | |
sensor: | |
- platform: dht | |
pin: D0 | |
temperature: | |
name: "Orcon Temperature" | |
humidity: | |
name: "Orcon Humidity" | |
update_interval: 60s | |
- platform: pulse_counter | |
pin: D2 | |
name: Orcon Tachometer | |
id: orcon_mv_tachometer | |
update_interval: 5s | |
accuracy_decimals: 0 | |
internal_filter: 250us | |
unit_of_measurement: rpm | |
- platform: duty_cycle | |
name: "Orcon MV Requested speed" | |
id: orcon_mv_requested_speed | |
internal: true | |
unit_of_measurement: "%" | |
accuracy_decimals: 0 | |
pin: | |
number: D1 | |
mode: INPUT_PULLUP | |
inverted: no | |
update_interval: 20s | |
filters: | |
lambda: "return int(x);" | |
on_value: | |
- lambda: |- | |
// Hacky way to trigger the original code instead of duplicating. | |
if (id(orcon).state) { | |
auto call = id(orcon).turn_on(); | |
call.set_speed(id(orcon).speed); | |
call.perform(); | |
} | |
output: | |
- platform: esp8266_pwm | |
pin: D6 | |
frequency: 1000 Hz | |
id: orcon_mv_pwm_out | |
inverted: true | |
- platform: template | |
id: dummy | |
type: float | |
write_action: | |
- logger.log: "Something was written to dummy." | |
fan: | |
- name: "Orcon" | |
id: "orcon" | |
icon: "mdi:hvac" | |
platform: speed # sliding output | |
output: dummy | |
restore_mode: ALWAYS_ON | |
on_turn_on: | |
- logger.log: "Turning on Orcon" | |
on_turn_off: | |
- logger.log: "Turning off Orcon" | |
- lambda: "id(orcon).speed = 1;" | |
on_speed_set: | |
- logger.log: "Speed changed." | |
- lambda: |- | |
// Set a little margin so we don't keep toggling the relay if | |
// the requested and set speeds are very similar. | |
int margin = 5; | |
// Contains requested speed by the machine (0-100) | |
int req = int(id(orcon_mv_requested_speed).state); | |
// Contains requested speed by the user (0-100) | |
int now = int(id(orcon).speed); | |
// ESP_LOGD("req", "%d", req); | |
// ESP_LOGD("now", "%d", now); | |
if (now > (req - margin)) { | |
id(orcon_mv_control_relay).turn_on(); | |
id(orcon_mv_pwm_out).set_level( | |
float(now / 100.0) | |
); | |
} else { | |
id(orcon_mv_control_relay).turn_off(); | |
id(orcon_mv_pwm_out).set_level(0.0); | |
} | |
switch: | |
- platform: gpio | |
id: orcon_mv_control_relay | |
internal: true | |
name: "Orcon MV Control relay" | |
pin: | |
number: D8 | |
inverted: False | |
- platform: restart | |
name: "Orcon MV ESPHome Restart" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment