|
本帖最后由 wpw72 于 2024-6-23 07:49 编辑
我在网上买了个手摇晾衣架改电动晾衣架部件,24v直流供电,原控制是433遥控的继电器控制电机正反转模块,该模块尺寸和网上某款5-60v直流供电的esp32双路继电器二次开发板基本一致,用esp32模块替代433模块,二次开发板上IO引出口焊接KF128-2.54的螺钉式接线端子,接按钮和限位开关,2个继电器和电机的接线见图,配置文件抄了其他人的作业,接入hass。主要代码如下,又esp32的IO口较多,还可扩展接入人体存在、温湿度、照度等其他传感器。如有电机过载测量建议,望不吝赐教。
output:
- platform: ledc
pin: ${rtttl_buzzer_pin}
id: rtttl_out
rtttl:
output: rtttl_out
switch:
- platform: gpio
pin: ${relay_up_pin}
interlock: [relay_down]
interlock_wait_time: ${relay_interlock_wait_time}
id: relay_up
# name: up
restore_mode: RESTORE_DEFAULT_OFF
- platform: gpio
pin: ${relay_down_pin}
interlock: [relay_up]
interlock_wait_time: ${relay_interlock_wait_time}
id: relay_down
# name: down
restore_mode: RESTORE_DEFAULT_OFF
binary_sensor:
#上升限位
- platform: gpio
id: up_limit
name: "Up Limit"
icon: mdi:arrow-collapse-up
pin:
number: ${up_limit_pin}
mode:
input: True
pullup: True
inverted: True
filters:
- delayed_on: ${delayed_time}
on_press:
then:
- rtttl.play: 'scale_up:d=32,o=7,b=100:c,c#,d#,e,f#,g#,a#,b'
- switch.turn_off: relay_up
#下降限位
- platform: gpio
id: down_limit
name: "Down Limit"
icon: mdi:arrow-collapse-down
pin:
number: ${down_limit_pin}
mode:
input: True
pullup: True
inverted: True
filters:
- delayed_on: ${delayed_time}
on_press:
then:
- rtttl.play: 'scale_up:d=32,o=7,b=100:b,a#,g#,f#,e,d#,c#,c'
- switch.turn_off: relay_down
#上升按钮
- platform: gpio
pin:
number: ${btn_up_pin}
mode:
input: True
pullup: True
inverted: True
name: "Up"
filters:
- delayed_on: ${delayed_time}
on_press:
then:
- if: #下降过程中按上升按钮,停止下降
condition:
switch.is_on: relay_down
then:
- cover.stop: drying_rack
else:
- if:
condition:
binary_sensor.is_off: up_limit
then:
- cover.open: drying_rack
#下降按钮
- platform: gpio
pin:
number: ${btn_down_pin}
mode:
input: True
pullup: True
inverted: True
name: "Down"
filters:
- delayed_on: ${delayed_time}
on_press:
then:
- if: #上升过程中按下降按钮,停止上升
condition:
switch.is_on: relay_up
then:
- cover.stop: drying_rack
else:
- if:
condition:
binary_sensor.is_off: down_limit
then:
- cover.close: drying_rack
cover:
- platform: feedback
name: "Drying Rack"
id: drying_rack
#up
open_action:
- switch.turn_on: relay_up
- rtttl.play: 'scale_up:d=32,o=7,b=100:c,c#,d#,e,f#,g#,a#,b'
open_duration: ${up_duration}
open_endstop: up_limit
#down
close_action:
- rtttl.play: 'scale_up:d=32,o=7,b=100:b,a#,g#,f#,e,d#,c#,c'
- switch.turn_on: relay_down
close_duration: ${down_duration}
close_endstop: down_limit
#stop
stop_action:
- switch.turn_off: relay_up
- switch.turn_off: relay_down
- rtttl.play: two_short:d=4,o=5,b=100:16e6,16e6
|
-
原433继电器模块
-
esp32继电器模块
-
继电器和电机接线
-
电动模块
-
电机及限位调整
|