本帖最后由 gasment 于 2026-4-6 21:20 编辑
不久前用极联小π更新了一下家里的红外模块
换下来一个能接入涂鸦的wifi版万能红外盒子
搜了下应该是第三方兼容的不是涂鸦官方的玩意,用的不是esp方案,拆开看是CB3S的模块,CB3S也就是BK72xx系列的芯片
这玩意esphome也支持,研究了一下,顺利刷上,把板载组件跑通了
IO使用情况
详细参考涂鸦文档:CB3S 模组规格书-涂鸦开发者平台-涂鸦开发者
刷机注意事项:
- 这个模块有两路uart,连接TXD1/RXD1烧录,连接TXD2/RXD1日志输出
- 板上没有现成的外接焊盘,需要飞线焊接到模块对应引脚
- 给板子usb供电,TXD1/RXD1/GND分别连接到USB串口工具的RX/TX/GND
- 如果无法进入下载模式,尝试短接引脚3与GND
esphome yaml配置(我分开为了4个文件,保存到同一目录下然后esphome run main.yaml即可)
主入口main.yaml:
packages:
- !include network.yaml
- !include onboard_led.yaml
- !include ir.yaml
esphome:
name: "cb3s-ir-controler"
friendly_name: "CB3S红外收发"
bk72xx:
board: cb3s
framework:
version: recommended
logger:
hardware_uart: UART2
level: DEBUG
api:
ota:
- platform: esphome
captive_portal:
web_server:
button:
- platform: restart #重启按钮
name: "Reset Device"
entity_category: "diagnostic"
icon: "mdi:restart"
id: system_reset_bt
sensor:
- platform: uptime #运行时间
type: seconds
id: uptime_seconds
internal: true
text_sensor:
- platform: version #esphome版本
id: esphome_ver
entity_category: "diagnostic"
name: "ESPHome Ver"
hide_timestamp: true
filters:
- lambda: |-
auto s = x;
size_t p = s.find(" (");
if (p != std::string::npos) s = s.substr(0, p);
return s;
- platform: template #运行时间(模板化)
id: uptime_format
name: "Uptime"
entity_category: diagnostic
icon: "mdi:clock-start"
update_interval: 60s
lambda: |-
float secs = id(uptime_seconds).state;
// 如果未初始化或为0,直接返回0d:00h:00m
if (isnan(secs) || secs < 1.0) {
return std::string("0d:00h:00m");
}
uint32_t total_seconds = (uint32_t)secs;
uint32_t days = total_seconds / 86400;
uint32_t hours = (total_seconds % 86400) / 3600;
uint32_t minutes = (total_seconds % 3600) / 60;
char buf[32];
snprintf(buf, sizeof(buf), "%ud:%02uh:%02um", days, hours, minutes);
return std::string(buf);
网路相关配置
network.yaml:
wifi:
ssid: #你的wifi名
password: #你的wifi密码
use_address: cb3s-ir-controler.local
ap:
ssid: "CB3S Fallback"
password: "12345678"
sensor:
- platform: wifi_signal #wifi信号
id: wifi_signal_value
name: "WIFI Signal"
icon: "mdi:wifi"
update_interval: 60s
entity_category: "diagnostic"
text_sensor:
- platform: wifi_info #>wifi信息
ip_address:
entity_category: "diagnostic"
name: "IP"
icon: "mdi:ip"
id: wifi_ip
ssid:
id: wifi_ssid
internal: true
on_value:
then:
- component.update: wifi_ap_template_sensor
bssid:
id: wifi_bssid
internal: true
on_value:
then:
- component.update: wifi_ap_template_sensor
- platform: template #>wifi信息(模板化)
name: "WIFI AP"
entity_category: "diagnostic"
icon: "mdi:wifi-marker"
id: wifi_ap_template_sensor
lambda: |-
if (id(wifi_ssid).state.empty() || id(wifi_bssid).state.empty()) {
return {"- - -"};
}
return (id(wifi_ssid).state + " / " + id(wifi_bssid).state);
update_interval: 60s
板载LED配置:
onboard_led.yaml
switch:
- platform: template #板载LED开关
name: "SYS LED"
id: sys_led_enable
restore_mode: RESTORE_DEFAULT_ON
entity_category: "config"
optimistic: true
output:
- platform: gpio #板载LED输出
pin: GPIO8
id: sys_led
interval:
- interval: 100ms
then:
- lambda: |- #板载LED闪烁逻辑,wifi未连接快闪,已连接慢闪
static uint32_t last = 0;
static int last_wifi_state = -1;
uint32_t now = millis();
bool wifi = wifi::global_wifi_component->is_connected();
bool en = id(sys_led_enable).state;
bool should_be_on = false;
if (!wifi) {
should_be_on = ((now / 200) % 2) == 0;
}
else if (en) {
uint32_t t = now % 1800;
should_be_on = (t < 1000);
}
id(sys_led).set_state(should_be_on);
红外收发配置,仅简单测试配置,需要红外码学习录入功能的可以看下其他esphome红外模块帖子
ir.yaml
########红外收发部分####################################################################
remote_receiver:
- id: IR_receiver
pin:
number: GPIO7
inverted: True
dump: all
remote_transmitter:
pin: GPIO26
carrier_duty_percent: 50%
button: #测试按钮
- platform: template
name: "AC-POWER-TEST"
on_press:
- remote_transmitter.transmit_toshiba_ac:
rc_code_1: 0xB24DBF40906F
rc_code_2: 0xD5660000003B
PS:
空闲IO应该也可以接其他传感器用,未做尝试
✅以上
|