Module esphome如何为带有集成4继电器的模块esp01编写配置
我从aliexpress获得,但它没有通过引脚切换继电器Module esphome如何为带有集成4继电器的模块esp01编写配置,module,esp8266,relay,Module,Esp8266,Relay,我从aliexpress获得,但它没有通过引脚切换继电器 如何使用esphome控制此继电器模块?在家庭助手社区中找到答案 通过uart进行继电器控制,带有一些数据,需要禁用记录器: 以下是esphome 4继电器esp01模块的yaml格式配置 #启用日志记录 记录器: 波特率:0需要这个来释放UART引脚 通用异步收发器: 波特率:115200#速度至STC15L101EW tx_引脚:GPIO1 rx_引脚:GPIO3 开关: -平台:uart 名称:“A1on” 数据:[0xA0,0x0
如何使用esphome控制此继电器模块?在家庭助手社区中找到答案 通过uart进行继电器控制,带有一些数据,需要禁用记录器: 以下是esphome 4继电器esp01模块的yaml格式配置
#启用日志记录
记录器:
波特率:0需要这个来释放UART引脚
通用异步收发器:
波特率:115200#速度至STC15L101EW
tx_引脚:GPIO1
rx_引脚:GPIO3
开关:
-平台:uart
名称:“A1on”
数据:[0xA0,0x01,0x01,0xA2]
-平台:uart
姓名:“A1off”
数据:[0xA0,0x01,0x00,0xA1]
-平台:uart
姓名:“A2on”
数据:[0xA0、0x02、0x01、0xA3]
-平台:uart
名称:“A2off”
数据:[0xA0、0x02、0x00、0xA2]
-平台:uart
姓名:“A3on”
数据:[0xA0、0x03、0x01、0xA4]
-平台:uart
姓名:“A3off”
数据:[0xA0、0x03、0x00、0xA3]
-平台:uart
名称:“A4on”
数据:[0xA0、0x04、0x01、0xA5]
-平台:uart
名称:“A4off”
数据:[0xA0、0x04、0x00、0xA4]
在此之后,我们得到了8个开关,分别打开和关闭每个继电器(每个继电器上2个)
我有一个单开关,但根据我的单开关的工作原理对其进行了扩展。这将产生4个开关,可以切换开/关。是的,看起来是很好的解决方案。
# Enable logging
logger:
baud_rate: 0 #need this to free up UART pins
uart:
baud_rate: 9600 # speed to STC15L101EW
tx_pin: 1
rx_pin: 3
globals:
- id: on_flag_1
type: int
restore_value: no
initial_value: '0'
- id: on_flag_2
type: int
restore_value: no
initial_value: '0'
- id: on_flag_3
type: int
restore_value: no
initial_value: '0'
- id: on_flag_4
type: int
restore_value: no
initial_value: '0'
switch:
- platform: template
id: relay1
name: "Relay #1"
lambda:
return id(on_flag_1);
turn_on_action:
- uart.write: [0xA0, 0x01, 0x01, 0xA2]
- globals.set:
id: on_flag_1
value: '1'
turn_off_action:
- uart.write: [0xA0, 0x01, 0x00, 0xA1]
- globals.set:
id: on_flag_1
value: '0'
- platform: template
id: relay2
name: "Relay #2"
lambda:
return id(on_flag_2);
turn_on_action:
- uart.write: [0xA0, 0x02, 0x01, 0xA3]
- globals.set:
id: on_flag_2
value: '1'
turn_off_action:
- uart.write: [0xA0, 0x02, 0x00, 0xA2]
- globals.set:
id: on_flag_2
value: '0'
- platform: template
id: relay3
name: "Relay #3"
lambda:
return id(on_flag_3);
turn_on_action:
- uart.write: [0xA0, 0x03, 0x01, 0xA4]
- globals.set:
id: on_flag_3
value: '1'
turn_off_action:
- uart.write: [0xA0, 0x03, 0x00, 0xA3]
- globals.set:
id: on_flag_3
value: '0'
- platform: template
id: relay4
name: "Relay #4"
lambda:
return id(on_flag_4);
turn_on_action:
- uart.write: [0xA0, 0x04, 0x01, 0xA5]
- globals.set:
id: on_flag_4
value: '1'
turn_off_action:
- uart.write: [0xA0, 0x04, 0x00, 0xA4]
- globals.set:
id: on_flag_4
value: '0'