松下(Panasonic)的LED灯,遥控器型号HK9811,使用ESP32-S3接入HomeAssistant实现总控。
一般红外遥控协议使用NEC协议的比较多,松下的资料比较少。踩了不少坑记录一下。
关于Panasonic协议,似乎是一种AEHA协议的实现,两者的时序非常相似
AEHA协议时序如下
- T = 350~500μs (425μs typ.)
引用:http://elm-chan.org/docs/ir_format.html
通过使用红外接收器分析遥控器信号,以及网上查找的资料,确定遥控器编码如下,这款遥控器采用的不是Panasonic标准的48位编码,而是40位编码
Command | Channel 1 | Channel 2 | Channel 3 |
---|---|---|---|
on | 0x344A90B424 | 0x344A90AC3C | 0x344A90BC2C |
full | 0x344A9034A4 | 0x344A902CBC | 0x344A903CAC |
night | 0x344A9074E4 | 0x344A906CFC | 0x344A907CEC |
high | 0x344A9054C4 | 0x344A904CDC | 0x344A905CCC |
low | 0x344A90D444 | 0x344A90CC5C | 0x344A90DC4C |
off | 0x344A90F464 | 0x344A90EC7C | 0x344A90FC6C |
引用:https://github.com/crankyoldgit/IRremoteESP8266/issues/1976#issuecomment-1531687356
之后是编辑EPSHome的yaml文件(硬件采用ESP32-S3开发板,以Channel2的on为例)
红外发送器引脚
红外发送器 | ESP32S3 |
---|---|
VCC | 5V |
GND | GND |
DAT | GPIO10 |
由于ESPHome提供的Panasonic信号为48位的,所以不能使用自带的transmit_panasonic发送,而是通过raw进行发送
esphome.yaml
esphome:
name: esp32s3-dev-1
friendly_name: ESP32S3-Dev-1
esp32:
board: esp32-s3-devkitc-1
framework:
type: arduino
# Enable Home Assistant API
api:
encryption:
key: "xxxxxxxxxxxxxxxxxxxxxx"
ota:
- platform: esphome
password: "xxxxxxxxxxxxxxxxxxxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32S3-Dev-1 Fallback Hotspot"
password: "xxxxxxxxxx"
captive_portal:
# 发送器配置
remote_transmitter:
pin: GPIO10
carrier_duty_percent: 33%
button:
- platform: template
name: "IR Send Test"
on_press:
- remote_transmitter.transmit_raw:
carrier_frequency: 38kHz
code: [
3480, -1740, # Leader (8T, 4T)
# 地址码 0x344A = 0011 0100 0100 1010 (16位)
435, -435, # 0
435, -435, # 0
435, -1305, # 1
435, -1305, # 0
435, -435, # 0
435, -1305, # 1
435, -435, # 0
435, -435, # 0
435, -435, # 0
435, -1305, # 1
435, -435, # 0
435, -435, # 0
435, -1305, # 1
435, -435, # 0
435, -1305, # 1
435, -435, # 0
# 命令码 0x90AC3C = 1001 0000 1010 1100 0011 1100 (24位)
435, -1305, # 1
435, -435, # 0
435, -435, # 0
435, -1305, # 1
435, -435, # 0
435, -435, # 0
435, -435, # 0
435, -435, # 0
435, -1305, # 1
435, -435, # 0
435, -1305, # 1
435, -435, # 0
435, -1305, # 1
435, -1305, # 1
435, -435, # 0
435, -435, # 0
435, -435, # 0
435, -435, # 0
435, -1305, # 1
435, -1305, # 1
435, -1305, # 1
435, -1305, # 1
435, -435, # 0
435, -435, # 0
435 # 结束位 (1T高电平)
]
repeat:
times: 2
wait_time: 15ms
最后踩的一个坑就是买的这个红外发送模块的功率实在太小,标称距离1.3米左右,实测也就半米左右才能有效,而且似乎板子上VCC引脚是空的,接不接5V供电效果都是一样的,应该是使用ESP32提供的电流进行工作的