logo elektroda
logo elektroda
X
logo elektroda

[BK7231N] Configuring Tuya CO400A-A004 (Carbon Monoxide Detector) with (OpenBeken)

sofaking 1251 20
ADVERTISEMENT
  • #1 21265316
    sofaking
    Level 2  
    I just got a Carbon Monoxide Detector from AliExpress and wanted to free this thing from the cloud. 

    Basic Information:
    Brand: Tuya?
    Model: CO400A-A004
    Chip: BK7231N (CBU)
    Local vendor: AliExpress

    Teardown Photos:
    Interior of a carbon monoxide detector with visible PCB board. Interior of a carbon monoxide detector with visible electronic components. Packaging of the Tuya WiFi carbon monoxide detector.

    i already flashed OpenBeken on the device since i did this for my smoke detectors i also ordered before, which had the same chip. But now i'm stuck configuring the device (pin setup) to use it with Homeassistant. 

    Heres the UART output of the device with the original firmware still in place

    
    V:BK7231N_1.0.1
    REG:cpsr     spsr     r13      r14
    SVC:000000D3          00401C1C 000033AC
    IRQ:000000d2 00000010 00401e0c eff55bff
    FIR:000000d1 00000010 00401ffc ee5d3aff
    SYS:000000df          0040192c 00000158
    ST:00000003
    J 0x10000
    [01-01 18:12:15 TUYA Info][lr:0xa59f9] mqc app init ...
    [01-01 18:12:15 TUYA Info][lr:0xaeec7] thread_create name:sys_timer,stackDepth:4096,totalstackDepth:4096,priority:5
    [01-01 18:12:15 TUYA Info][lr:0xaeec7] thread_create name:cmmod,stackDepth:4096,totalstackDepth:8192,priority:4
    [01-01 18:12:15 TUYA Debug][lr:0xaed53] Thread:sys_timer Exec Start. Set to Running Stat
    [01-01 18:12:15 TUYA Debug][lr:0xa59a7] mq_pro:5 cnt:1
    [01-01 18:12:15 TUYA Debug][lr:0xa59a7] mq_pro:31 cnt:2
    [01-01 18:12:15 TUYA Err][lr:0x9f603] logseq empty
    [01-01 18:12:15 TUYA Debug][lr:0xae837] svc online log init success
    [01-01 18:12:15 TUYA Info][lr:0xaeec7] thread_create name:wk_th-0,stackDepth:5120,totalstackDepth:13312,priority:3
    [01-01 18:12:15 TUYA Err][lr:0x97d3d] wd_protected_read fails gw_bi -1
    [01-01 18:12:15 TUYA Debug][lr:0x97fff] gw base read finish:-1
    [01-01 18:12:15 TUYA Debug][lr:0xa2c1d] ty bt cmmod regist ok:1
    [01-01 18:12:15 TUYA Debug][lr:0xa2f19] upd adv para, send conn_req beacon.
    [PLATFORM DEBUG]!!!!!!!!!!tuya_os_adapt_bt_port_init
    [01-01 18:12:15=1
                     [01-01 18:12:15 TUYA Notice][lr:0xa2d07] tyx1a,status:0x0
    [01-01 18:12:15 TUYA Debug][l[PLATFORM NOTICE]STACK Ir
    [PLATFORM NOTICE]bk_N tuya_rst:0
    [PLATFORMrTE DB SUCCESS
    [01-01  12:15 TUYA Notice][lr:18:12:15 TUYA Notice][l0x59af7] system reset rr:0x59af7] system reseteason:[(null)]
     reason:[(null)]
    [01-01 18:12:15 TUYA Debug][lr:0xa2f19] upd adv para, send conn_req beacon.
    [01-01 18:12:15 TUYA Notice][PLATFORM DEBUG]!!!!!!![a_os_adapt_bt_reset_ad!!!tuya_os_adapt_bt_resv
    [01-01 18:12:15 TUYAe. Path: (null)
     Debug][lr:0xc5e75] init fs. Path: (null)
    [01-01 18:12:15 TUYA Debug][lr:0xc3443] *****************kvs_init.
    [01-01 18:12:15 TUYA Notice][lr:0xc538f] key_addr: 0x1ee000   block_sz 4096
    [01-01 18:12:15 TUYA Notice][lr:0xa3031] ble adv upd!
    [PLATFORM NOTICE]!!!!!!!!!!tuya_before_netcfg_cb
    [PLATFORM D[01-01 18:12:15 TUYA NoE:15 TUYA Notice][lr:0xtice][lr:0xc5463] get kc5463] get key:
    estatus:0x0
    0xd3 0x1e 0xdc 0[PLATFORM DEBUG]UNKNOW xLATFORM DEBUG]UNKNOW EVEVENT:16
    [PLATFORM DEBENT:16
    0x68 0x59 0x3f UG]UNKNOW EVENT:16
    0x8b 0x9e 0x8b 0x83 0xac 0[PLATFORM DEBUG]UNKNOW xLATFORM DEBUG]UNKNOW EEVENT:16
    [PLATFORM DEBUG]UNKNOW EVENT:16
    VENT:16
    0xaa 0x42 0x1c
    [01-01 18:12:15 TUYA Debug][lr:0x9df79] mf_core_init success
    [01-01 18:12:15 TUYA Info][lr:0xaeec7] thread_create name:mf_test,stackDepth:5120,totalstackDepth:18432,priority:4
    [01-01 18:12:15 TUYA Debug][lr:0xaed53] Thread:cmmod Exec Start. Set to Running Stat
    [01-01 18:12:15 TUYA Debug][lr:0xaed47] enter Thread:mf_test func call
    [01-01 18:12:15 TUYA Debug][lr:0xaed53] Thread:mf_test Exec Start. Set to Running Stat
    [01-01 18:12:15 TUYA Debug][lr:0xaed53] Thread:wk_th-0 Exec Start. Set to Running Stat
    [01-01 18:12:15 TUYA Debug][lr:0x9d26d] mf thread delete
    [01-01 18:12:15 TUYA Debug][lr:0xaef53] Del Thrd:mf_test
    [01-01 18:12:15 TUYA Notice][lr:0x5824d] mf_init succ
    [01-01 18:12:15 TUYA Debug][lr:0x5a51b] close_wake_led data_exist:0,led_pin:0
    [01-01 18:12:15 TUYA Info][lr:0xaeec7] thread_create name:que_up_task,stackDepth:2048,totalstackDepth:20480,priority:3
    [01-01 18:12:15 TUYA Debug][lr:0x5b089] hw_table_json_init,uf_param_flag:1 over
    [01-01 18:12:15 TUYA Err][lr:0xcabff] uf_write err 1
    [01-01 18:12:15 TUYA Notice][lr:0x58667] app_json_data_loading data:(null),len:
    [01-01 18:12:15 TUYA Debug][lr:0x584b9] value:1.0.0,len:5
    [01-01 18:12:15 TUYA Debug][lr:0x58541] key:,jv:       value:1.0.0        len:5
    [01-01 18:12:15 TUYA Debug][lr:0x584b9] value:CBU,len:3
    [01-01 18:12:15 TUYA Debug][lr:0x58541] key:,module       value:CBU        len:3
    [01-01 18:12:15 TUYA Debug][lr:0x584b9] value:24,len:2
    [01-01 18:12:15 TUYA Debug][lr:0x58541] key:,bt_pin:       value:24        len:1
    [01-01 18:12:15 TUYA Debug][lr:0x584b9] value:6,len:1
    [01-01 18:12:15 TUYA Debug][lr:0x58541] key:,status_led_pin       value:6        len:1
    [01-01 18:12:15 TUYA Debug][lr:0x584b9] value:3,len:1
    [01-01 18:12:15 TUYA Debug][lr:0x58541] key:,rstcnt       value:3        len:1
    [01-01 18:12:15 TUYA Debug][lr:0x584b9] value:26,len:2
    [01-01 18:12:16 TUYA Debug][lr:0x58541] key:,basic_pin_pin       value:26        len:1
    [01-01 18:12:16 TUYA Debug][lr:0x584b9] value:0,len:1
    [01-01 18:12:16 TUYA Debug][lr:0x58541] key:,bt_lv       value:0        len:1
    [01-01 18:12:16 TUYA Debug][lr:0x584b9] value:180,len:3
    [01-01 18:12:16 TUYA Debug][lr:0x58541] key:,net_t       value:180        len:1
    [01-01 18:12:16 TUYA Debug][lr:0x584b9] value:1,len:1
    [01-01 18:12:16 TUYA Debug][lr:0x58541] key:,samp_type       value:1        len:1
    [01-01 18:12:16 TUYA Debug][lr:0x584b9] value:1,len:1
    [01-01 18:12:16 TUYA Debug][lr:0x58541] key:,basic_st       value:1        len:1
    [01-01 18:12:16 TUYA Debug][lr:0x584b9] value:0,len:1
    [01-01 18:12:16 TUYA Debug][lr:0x58541] key:,basic_pin_lv       value:0        len:1
    [01-01 18:12:16 TUYA Debug][lr:0x584b9] value:20,len:2
    [01-01 18:12:16 TUYA Debug][lr:0x58541] key:,samp_sw_pin       value:20        len:1
    [01-01 18:12:16 TUYA Debug][lr:0x584b9] value:6130,len:4
    [01-01 18:12:16 TUYA Debug][lr:0x58541] key:,max_V       value:6130        len:2
    [01-01 18:12:16 TUYA Debug][lr:0x584b9] value:5435,len:4
    [01-01 18:12:16 TUYA Debug][lr:0x58541] key:,min_V       value:5435        len:2
    [01-01 18:12:16 TUYA Debug][lr:0x584b9] value:1,len:1
    [01-01 18:12:16 TUYA Debug][lr:0x58541] key:,status_led_lv       value:1        len:1
    [01-01 18:12:16 TUYA Debug][lr:0x584b9] value:1,len:1
    [01-01 18:12:16 TUYA Debug][lr:0x58541] key:,tamper_st       value:1        len:1
    [01-01 18:12:16 TUYA Debug][lr:0x584b9] value:17,len:2
    [01-01 18:12:16 TUYA Debug][lr:0x58541] key:,net_led_pin       value:17        len:1
    [01-01 18:12:16 TUYA Notice][lr:0x5844d] ,tamper_pin_lv is not exist  1
    [01-01 18:12:16 TUYA Debug][lr:0x584b9] value:1,len:1
    [01-01 18:12:16 TUYA Debug][lr:0x58541] key:,net_led_lv       value:1        len:1
    [01-01 18:12:16 TUYA Notice][lr:0x5844d] ,tamper_pin_pin is not exist  1
    [01-01 18:12:16 TUYA Debug][lr:0x583e5] check_wake_pin pin:24
    [01-01 18:12:16 TUYA Debug][lr:0x583e5] check_wake_pin pin:26
    [01-01 18:12:16 TUYA Debug][lr:0x583e5] check_wake_pin pin:255
    [01-01 18:12:16 TUYA Err][lr:0x583ff] wake_pin is not exit,param_pin:255
    [01-01 18:12:16 TUYA Debug][lr:0x585d7] tamper_pin not exist, config_wake_gpio is error,err_num:-1
    [01-01 18:12:16 TUYA Err][lr:0x5858b] pin not exist,check_common_pin error
    [01-01 18:12:16 TUYA Err][lr:0x58605] wifi_led not exist,config_common_pin is error,err_num:-1
    [01-01 18:12:16 TUYA Debug][lr:0x58635] hw_config_info_check init sucess,op_ret:0
    [01-01 18:12:16 TUYA Debug][lr:0x586b5] ##########firmware config##########
    [01-01 18:12:16 TUYA Debug][lr:0x586bd] hw_table->json_verson is:1.0.0CBU
    [01-01 18:12:16 TUYA Debug][lr:0x586c5] hw_table->module is:CBU
    [01-01 18:12:16 TUYA Debug][lr:0x586cb] ##########gate config##########
    [01-01 18:12:16 TUYA Debug][lr:0x586d5] io_driver_type is:0
    [01-01 18:12:16 TUYA Debug][lr:0x586dd] io_pin is:26
    [01-01 18:12:16 TUYA Debug][lr:0x586e5] gate led_type is:1
    [01-01 18:12:16 TUYA Debug][lr:0x586eb] ##########tamper config##########
    [01-01 18:12:16 TUYA Debug][lr:0x586f5] io_driver_type is:2
    [01-01 18:12:16 TUYA Debug][lr:0x586ff] io_pin is:255
    [01-01 18:12:16 TUYA Debug][lr:0x5870b] tamper led_type is:1
    [01-01 18:12:16 TUYA Debug][lr:0x58711] ##########key config##########
    [01-01 18:12:16 TUYA Debug][lr:0x5871b] key_driver_type is:0
    [01-01 18:12:16 TUYA Debug][lr:0x58725] button.port is:24
    [01-01 18:12:16 TUYA Debug][lr:0x5872d] key_press_time is:3
    [01-01 18:12:16 TUYA Debug][lr:0x58733] ##########led config##########
    [01-01 18:12:16 TUYA Debug][lr:0x5873b] wifi_led io_driver_type is:1
    [01-01 18:12:16 TUYA Debug][lr:0x58743] wifi_led io_pin is:17
    [01-01 18:12:16 TUYA Debug][lr:0x5874d] wifi_led.led_type is:0
    [01-01 18:12:16 TUYA Debug][lr:0x58755] status_led io_driver_type is:1
    [01-01 18:12:16 TUYA Debug][lr:0x5875f] status_led io_pin is:6
    [01-01 18:12:16 TUYA Debug][lr:0x58765] ##########adc config##########
    [01-01 18:12:16 TUYA Debug][lr:0x58771] adc_io is:20
    [01-01 18:12:16 TUYA Debug][lr:0x5877d] samp_type is:1
    [01-01 18:12:16 TUYA Debug][lr:0x58785] max_voltage is:6130
    [01-01 18:12:16 TUYA Debug][lr:0x5878d] min_voltage is:5435
    [01-01 18:12:16 TUYA Debug][lr:0x58793] ##########net timeout time config##########
    [01-01 18:12:16 TUYA Debug][lr:0x5879b] wifi_timeout is:180
    [01-01 18:12:16 TUYA Debug][lr:0x5a485] app_wakeup_pin_init uf_data,led_pin:6,wifi_led_pin:17,key_pin:24,gate_pin:26,tamper_pin:255
    [01-01 18:12:16 TUYA Notice][lr:0x5a5f1] wakeup_gpio_value:5000000
    [01-01 18:12:16 TUYA Debug][lr:0xaec91] del list not empty...deleting
    [01-01 18:12:16 TUYA Debug][lr:0xaeca9] Thread:mf_test is still running..
    [01-01 18:12:16 TUYA Debug][lr:0xaed53] Thread:que_up_task Exec Start. Set to Running Stat
    [01-01 18:12:16 TUYA Debug][lr:0x5a633] gpio_pin:26 level is :1,wakeup_result:1
    [01-01 18:12:16 TUYA Debug][lr:0x5b0d7] hw_table_json_init,uf_param_flag:1 over
    [01-01 18:12:16 TUYA Notice][lr:0x59b37] app_init wakeup_type:1
    [01-01 18:12:16 TUYA Debug][lr:0x5a8f5] hw_app_config_init gate_pin:26,tamper:255
    [01-01 18:12:16 TUYA Debug][lr:0xb19fb] pinname:6
    [01-01 18:12:16 TUYA Debug][lr:0x5a833] hw_led_init sucess
    [01-01 18:12:16 TUYA Debug][lr:0x5a99b] wake_pin_first_init data_not_exist_result:1
    [01-01 18:12:16 TUYA Debug][lr:0xb19fb] pinname:6
    [01-01 18:12:16 TUYA Debug][lr:0x5a597] power_on_led_add data_exist:0
    [01-01 18:12:16 TUYA Debug][lr:0x5afd3] timer_group[0] timer
    [01-01 18:12:16 TUYA Debug][lr:0x5afd3] timer_group[1] timer
    [01-01 18:12:16 TUYA Debug][lr:0x5afd3] timer_group[2] timer
    [01-01 18:12:16 TUYA Debug][lr:0x5afd3] timer_group[3] timer
    [01-01 18:12:16 TUYA Debug][lr:0x5afd3] timer_group[4] timer
    [01-01 18:12:16 TUYA Debug][lr:0x5afd3] timer_group[5] timer
    [01-01 18:12:16 TUYA Debug][lr:0xaed95] Thread:mf_test Exec Finish. Set to Del Stat
    [01-01 18:12:16 TUYA Debug][lr:0xaec91] del list not empty...deleting
    [01-01 18:12:16 TUYA Debug][lr:0xaecbd] Final Free Thread:mf_test, is_self:1
    [01-01 18:12:16 TUYA Debug][lr:0xaeccf] delay to delete thread self
    [01-01 18:12:16 TUYA Debug][lr:0x5b15d] adc_value_avg:3944,vol_value:3177
    [01-01 18:12:16 TUYA Debug][lr:0x5aee7] adc_read_value:6354,value:3177
    [01-01 18:12:16 TUYA Debug][lr:0x58b9d] res_key_manage 1
    [01-01 18:12:16 TUYA Debug][lr:0x5825b] gwcm_mode 1
    [01-01 18:12:16 TUYA Debug][lr:0x58269] low_power select
    [01-01 18:12:16 TUYA Debug][lr:0x9835b] gw_wsm read success
    [01-01 18:12:16 TUYA Notice][lr:0x582b5] current product ssid name:tuya_mdev_test1
    [01-01 18:12:16 TUYA Debug][lr:0xaecfd] finally delete thread self
    [01-01 18:12:16 TUYA Debug][lr:0xb19fb] pinname:6
    [01-01 18:12:17 TUYA Debug][lr:0x5ab23] status_led_flash_timer_cb cur_wifi_stat:2
    [01-01 18:12:17 TUYA Notice][lr:0x5aa35] wifi_status:2
    [01-01 18:12:17 TUYA Debug][lr:0xb19fb] pinname:6
    [01-01 18:12:18 TUYA Debug][lr:0x582cf] wf_assign_ap_scan failed(-1)
    [01-01 18:12:18 TUYA Debug][lr:0x5835f] no tuya_mdev_test1!
    [01-01 18:12:18 TUYA Debug][lr:0x58365] device_init in
    [01-01 18:12:19 TUYA Notice][lr:0x59bbd] device_init suecss,heap_size:78064
    [01-01 18:12:19 TUYA Debug][lr:0xaae93] tuya svc upgrade init success!
    [PLATFORM NOTICE]bk_rst:3 tuya_rst:0
    [01-01 18:12:19 TUYA Notice][lr:0x9c28b] Last reset reason: 0
    [01-01 18:12:19 TUYA Debug][lr:0xb1d53] init watchdog, interval: 60
    [01-01 18:12:19 TUYA Debug][lr:0xb1d91] watch_dog_interval:60, monitor_detect_interval:600
    [01-01 18:12:19 TUYA Info][lr:0xaeec7] thread_create name:health_monitor,stackDepth:1536,totalstackDepth:22016,priority:5
    [01-01 18:12:19 TUYA Debug][lr:0xaed53] Thread:health_monitor Exec Start. Set to Running Stat
    [01-01 18:12:19 TUYA Debug][lr:0x97fff] gw base read finish:0
    [01-01 18:12:19 TUYA Debug][lr:0xa67fd] tls register constant ed577421f8c9b494 KA9wrHOfG2AiSvm0AqXCN87TzZr6rJNH 5NN6OXjpuotfK10wcYfvAbe8rL70URkDL5Qip
    [01-01 18:12:19 TUYA Debug][lr:0xa66f5] load tls_ca_cnt fail. no ca in local db
    [01-01 18:12:19 TUYA Notice][lr:0x9c3fb] serial_no:b8060d88b3ba
    [01-01 18:12:19 TUYA Debug][lr:0x9835b] gw_wsm read success
    [01-01 18:12:19 TUYA Notice][lr:0x9c433] gw_cntl.gw_wsm.stat:0
    [01-01 18:12:19 TUYA Notice][lr:0x9c4c1] gw_cntl.gw_wsm.nc_tp:0
    [01-01 18:12:19 TUYA Notice][lr:0x9c4c9] gw_cntl.gw_wsm.md:0
    [01-01 18:12:19 TUYA Debug][lr:0xb0339] set_dns_cache_priority:0
    [01-01 18:12:19 TUYA Debug][lr:0x98895] gw_di read success
    [01-01 18:12:19 TUYA Debug][lr:0x9ab1f] stride from flash: 0.
    [01-01 18:12:19 TUYA Debug][lr:0x9ab37] no actived, no upgrade:0
    [01-01 18:12:19 TUYA Notice][lr:0x9c6b7] gw_cntl.gw_if.abi:0 input:0
    [01-01 18:12:19 TUYA Notice][lr:0x9c6c3] gw_cntl.gw_if.product_key:uade6fhqmx2hbyna, input:uade6fhqmx2hbyna
    [01-01 18:12:19 TUYA Notice][lr:0x9c6cf] gw_cntl.gw_if.tp:0, input:0
    [01-01 18:12:19 TUYA Debug][lr:0x98dd1] gw_ai read success
    [01-01 18:12:19 TUYA Debug][lr:0xb04a5] set_dns_region:1
    [01-01 18:12:19 TUYA Debug][lr:0x9cabf] enter success_proc
    [01-01 18:12:19 TUYA Debug][lr:0xa59a7] mq_pro:11 cnt:3
    [01-01 18:12:19 TUYA Debug][lr:0xa59a7] mq_pro:41 cnt:4
    [01-01 18:12:19 TUYA Debug][lr:0xa59a7] mq_pro:100 cnt:5
    [01-01 18:12:19 TUYA Debug][lr:0xa59a7] mq_pro:27 cnt:6
    [01-01 18:12:19 TUYA Notice][lr:0xa2d5b] ty bt upd product:uade6fhqmx2hbyna 0
    [01-01 18:12:19 TUYA Notice][lr:0xa31b7] upd product_id type:0 uade6fhqmx2hbyna ed577421f8c9b494 KA9wrHOfG2AiSvm0AqXCN87TzZr6rJNH
    [01-01 18:12:19 TUYA Debug][lr:0x99729] nc_tp:0, md:0
    [01-01 18:12:19 TUYA Debug][lr:0xb316d] register wifi network monitor. interval:1
    [01-01 18:12:20 TUYA Debug][lr:0x5adbb] ---------------------------------------send_uart_data_timer_cb
    [01-01 18:12:20 TUYA Debug][lr:0xb3039] wifi netstat changed to:0  -->>
    [01-01 18:12:20 TUYA Notice][lr:0x59a49] wifi status:0
    [01-01 18:12:20 TUYA Notice][lr:0x59a55] heap free size:77960
    [01-01 18:12:20 TUYA Notice][lr:0x5aa35] wifi_status:0
    [01-01 18:12:20 TUYA Debug][lr:0x5accd] set_sleep_time wf_stat:1,stat:0
    [01-01 18:12:20 TUYA Debug][lr:0xb3053] wifi netstat changed to:0  <<--
    [01-01 18:12:21 TUYA Debug][lr:0x5b15d] adc_value_avg:3946,vol_value:3179
    [01-01 18:12:21 TUYA Debug][lr:0x5aee7] adc_read_value:6358,value:3179
    [01-01 18:12:21 TUYA Debug][lr:0x5adbb] ---------------------------------------send_uart_data_timer_cb
    [01-01 18:12:22 TUYA Debug][lr:0x5adbb] ---------------------------------------send_uart_data_timer_cb
    [01-01 18:12:22 TUYA Debug][lr:0x5ae29] location = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[1] = AA
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[2] = 13
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[3] = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[4] = 18
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[5] = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[6] = 7
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[7] = 1
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[8] = 36
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[9] = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[10] = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[11] = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[12] = 4
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[13] = 5C
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[14] = 92
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[15] = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[16] = 1
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[17] = 1
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[18] = 55
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[19] = 5C
    [01-01 18:12:22 TUYA Debug][lr:0x5ae59] g_hw_config.co_info.co_value = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ae65] g_hw_config.co_info.fault_value = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ad5f] -----------------------------------------------first network = 1
    [01-01 18:12:23 TUYA Debug][lr:0x5b15d] adc_value_avg:3949,vol_value:3181
    [01-01 18:12:23 TUYA Debug][lr:0x5aee7] adc_read_value:6362,value:3181
    [01-01 18:12:23 TUYA Debug][lr:0x5a393] power_off_timer now
    [01-01 18:12:23 TUYA Debug][lr:0x59925] -----------------------------------------------wifi_flag = 0
    [01-01 18:12:23 TUYA Notice][lr:0x59795] enter sleep mode,sleep_timer is 0
    


    i also attached the original firmware i backuped before flashing OpenBeken.

    Any help configuring this device would be much appreciated.

    Thanks in advance
  • ADVERTISEMENT
  • #2 21265350
    DeDaMrAz
    Level 19  
    Create autoexec.bat file in webapp Filesystem tab.

    startDriver TuyaMCU
    //try with 9600 first if it doesn't work try 115200
    tuyaMcu_setBaudRate 9600
    tuyaMcu_defWiFiState 4


    then go to webapp logging and send command - tuyaMcu_sendQueryState

    monitor the output so we can maybe grab dpID's and try to figure something out.
  • #3 21265886
    sofaking
    Level 2  
    thanks for the quick reply. i only get the following log output when i do that (tried both baudrates with the same result)

    
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 0, product_information_valid=0, self_processing_mode = 1, wifi_state_valid = 0, wifi_state_timer=0
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 0, product_information_valid=0, self_processing_mode = 1, wifi_state_valid = 0, wifi_state_timer=0
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 0, product_information_valid=0, self_processing_mode = 1, wifi_state_valid = 0, wifi_state_timer=0
    


    also tried the config extract method from here but this only outputs the following json

    
    {
       "abi":"0",
       "id":"null",
       "swv":"1.0.2",
       "bv":"40.00",
       "pv":"2.2",
       "lpv":"3.4",
       "pk":"uade6fhqmx2hbyna",
       "firmk":"null",
       "cadv":"1.0.3",
       "cdv":"1.0.0",
       "dev_swv":"1.0.2",
       "s_id":"null",
       "dtp":"0",
       "sync":"0",
       "attr_num":"0",
       "mst_tp_0":"0",
       "mst_ver_0":"null",
       "mst_tp_1":"0",
       "mst_ver_1":"null",
       "mst_tp_2":"0",
       "mst_ver_2":"null",
       "mst_tp_3":"0",
       "mst_ver_3":"null "
    }
    


    does this mean that it might not be a tuya mcu device?
  • #4 21265916
    DeDaMrAz
    Level 19  
    Your boot log lead me to believe it is a TuyaMCU device and so do the pictures but I can't clearly see where UART traces lead ( I thought it want to whatever that chip is).

    I am confused but form your log we can see some pin setup

    [01-01 18:12:16 TUYA Debug][lr:0x586b5] ##########firmware config##########
    [01-01 18:12:16 TUYA Debug][lr:0x586bd] hw_table->json_verson is:1.0.0CBU
    [01-01 18:12:16 TUYA Debug][lr:0x586c5] hw_table->module is:CBU
    [01-01 18:12:16 TUYA Debug][lr:0x586cb] ##########gate config##########
    [01-01 18:12:16 TUYA Debug][lr:0x586d5] io_driver_type is:0
    [01-01 18:12:16 TUYA Debug][lr:0x586dd] io_pin is:26
    [01-01 18:12:16 TUYA Debug][lr:0x586e5] gate led_type is:1
    [01-01 18:12:16 TUYA Debug][lr:0x586eb] ##########tamper config##########
    [01-01 18:12:16 TUYA Debug][lr:0x586f5] io_driver_type is:2
    [01-01 18:12:16 TUYA Debug][lr:0x586ff] io_pin is:255
    [01-01 18:12:16 TUYA Debug][lr:0x5870b] tamper led_type is:1
    [01-01 18:12:16 TUYA Debug][lr:0x58711] ##########key config##########
    [01-01 18:12:16 TUYA Debug][lr:0x5871b] key_driver_type is:0
    [01-01 18:12:16 TUYA Debug][lr:0x58725] button.port is:24
    [01-01 18:12:16 TUYA Debug][lr:0x5872d] key_press_time is:3
    [01-01 18:12:16 TUYA Debug][lr:0x58733] ##########led config##########
    [01-01 18:12:16 TUYA Debug][lr:0x5873b] wifi_led io_driver_type is:1
    [01-01 18:12:16 TUYA Debug][lr:0x58743] wifi_led io_pin is:17
    [01-01 18:12:16 TUYA Debug][lr:0x5874d] wifi_led.led_type is:0
    [01-01 18:12:16 TUYA Debug][lr:0x58755] status_led io_driver_type is:1
    [01-01 18:12:16 TUYA Debug][lr:0x5875f] status_led io_pin is:6
    [01-01 18:12:16 TUYA Debug][lr:0x58765] ##########adc config##########
    [01-01 18:12:16 TUYA Debug][lr:0x58771] adc_io is:20
    [01-01 18:12:16 TUYA Debug][lr:0x5877d] samp_type is:1
    [01-01 18:12:16 TUYA Debug][lr:0x58785] max_voltage is:6130
    [01-01 18:12:16 TUYA Debug][lr:0x5878d] min_voltage is:5435


    But there is also some UART traffic in there...

    [01-01 18:12:20 TUYA Notice][lr:0x5aa35] wifi_status:0
    [01-01 18:12:20 TUYA Debug][lr:0x5accd] set_sleep_time wf_stat:1,stat:0
    [01-01 18:12:20 TUYA Debug][lr:0xb3053] wifi netstat changed to:0  <<--
    [01-01 18:12:21 TUYA Debug][lr:0x5b15d] adc_value_avg:3946,vol_value:3179
    [01-01 18:12:21 TUYA Debug][lr:0x5aee7] adc_read_value:6358,value:3179
    [01-01 18:12:21 TUYA Debug][lr:0x5adbb] ---------------------------------------send_uart_data_timer_cb
    [01-01 18:12:22 TUYA Debug][lr:0x5adbb] ---------------------------------------send_uart_data_timer_cb
    [01-01 18:12:22 TUYA Debug][lr:0x5ae29] location = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[1] = AA
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[2] = 13
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[3] = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[4] = 18
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[5] = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[6] = 7
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[7] = 1
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[8] = 36
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[9] = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[10] = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[11] = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[12] = 4
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[13] = 5C
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[14] = 92
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[15] = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[16] = 1
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[17] = 1
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[18] = 55
    [01-01 18:12:22 TUYA Debug][lr:0x5ae3b] recieve_uart_data[19] = 5C
    [01-01 18:12:22 TUYA Debug][lr:0x5ae59] g_hw_config.co_info.co_value = 0
    [01-01 18:12:22 TUYA Debug][lr:0x5ae65] g_hw_config.co_info.fault_value = 0


    I would have to have better board pictures to figure that out. Sorry for now I have no idea.
  • ADVERTISEMENT
  • #5 21265929
    sofaking
    Level 2  
    I will try to make some better pictures tomorrow. I can also check the traces with the multimeter but as far as I can remember I did a little probing on the board today and the CBU RX2/TX2 pins are connected to the chip on the bottom right on the picture.
  • ADVERTISEMENT
  • #6 21265935
    DeDaMrAz
    Level 19  
    I managed to order one of these to play around with, if nothing happens before when it arrives I will update you on the setup.
  • #7 21265959
    divadiow
    Level 34  
    Hi. I bought one a few months ago but never got round to looking at it.

    That 48 pin chip is a Holtek BA45F6746

    Close-up of a 48-pin Holtek BA45F6746 chip on a circuit board. Close-up of a circuit board with a Holtek BA45F6746 chip and other electronic components.

    Code: Text
    Log in, to see the code


    https://www.holtek.com/page/vg/BA45F6746

    in this device, in part, to drive the LCD on the front one assumes.

    WiFi carbon monoxide detector with LCD display.

    The fw version, 1.0.2, is not patched. A cloudcutter profile was added in April for it.

    Added after 3 [minutes]:

    looks like you got the battery-only version like me. Mine has a white rubber stopper where the USB connector would have gone.
    Image of the interior of a gas detector showing the circuit board and components.

    Added after 1 [hours] 3 [minutes]:

    Close-up of a circuit board with Holtek BA45F6746 chip and yellow labels for GND, VCC. Pin diagram of the 48-pin Holtek BA45F6746 chip.
  • #8 21266187
    divadiow
    Level 34  
    ha. should have checked underneath first re test pads
    Close-up of a purple printed circuit board with an LCD display and a test button. Close-up of a circuit board with an LCD screen and various electronic components. Printed circuit board with an LCD display and other electronic components.
  • #9 21266214
    sofaking
    Level 2  
    when I press the test button (center front of the device) I get this output in the log

    
    Info:TuyaMCU:Consumed 121 unwanted non-header byte in Tuya MCU buffer
    Info:TuyaMCU:Skipped data (part) 00 00 F8 00 FE 00 FE 00 FE 00 FE 00 00 F8 00 00 00 E0 00 00 00 E0 00 FE 00 00 00 E0 00 FE 00 FE 00 00 00 E0 00 00 00 00 00 00 00 00 00 00 80 00 FE 00 00 00 00 00 00 00 FE 00 00 00 00 00 00 00 00 F8 00 00 F8 00 FE 00 00 F8 00 00 00 00 00 00 00 00 00 00 80
    Info:TuyaMCU:Consumed 62 unwanted non-header byte in Tuya MCU buffer
    Info:TuyaMCU:Skipped data (part) 00 FE 00 FE 00 FE 00 00 F8 00 00 F8 00 00 00 00 00 00 00 00 00 00 80 00 FE 00 00 00 00 00 00 00 00 F8 00 FE 00 00 00 00 00 00 00 00 F8 00 FE 00 FE 00 FE 00 FE 00 FE 00 FE 00 00 F8 00 FE 
    ExtraDebug:TuyaMCU:TuyaMCU heartbeat_valid = 0, product_information_valid=0, self_processing_mode = 1, wifi_state_valid = 0, wifi_state_timer=0
    Info:TuyaMCU:Consumed 183 unwanted non-header byte in Tuya MCU buffer
    Info:TuyaMCU:Skipped data (part) 00 00 F8 00 FE 00 FE 00 FE 00 FE 00 00 F8 00 00 00 E0 00 00 00 E0 00 FE 00 00 00 E0 00 FE 00 FE 00 00 00 E0 00 00 00 00 00 00 00 00 00 00 80 00 FE 00 00 00 00 00 00 00 FE 00 00 00 00 00 00 00 00 F8 00 00 F8 00 FE 00 00 F8 00 00 00 00 00 00 00 00 00 00 80
    


    i also probed the connections now.

    BA45F6746 PIN19 is connected to TX1 on the CBU
    BA45F6746 PIN20 is connected to RX1 on the CBU
  • #10 21267187
    sofaking
    Level 2  
    i flashed back the stock firmware to check the DPids using this guide and got the following values

    
    {
        "1": "Co State",
        "2": "Co Value",
        "11": "Fault",
        "15": "Battery Percentage"
    }
    


    
    co_status	Enum	
    {
        "range": [
            "normal",
            "alarm"
        ]
    }
    co_value	Integer	
    {
        "unit": "ppm",
        "min": 0,
        "max": 1000,
        "scale": 0,
        "step": 1
    }
    battery_percentage	Integer	
    {
        "unit": "%",
        "min": 0,
        "max": 100,
        "scale": 0,
        "step": 1
    }
    
  • #11 21267322
    piotrszulc1
    Level 9  
    I've got this detector some time ago and I don't think it's tuya-mcu. The detection and the LCD are handled by a separate chip (probably the already mentioned Holtek) and only the following information is available to the CBU (at least that's what I found out so far):
    P24 (inverted + pullup) - Button (the "pin button" at the side, not the big one in the front)
    P26 (inverted) - Fire alarm active
    P6 - status LED (only the blue one)
    P20 - battery relay
    P23 - battery ADC

    The remaining two LEDs are and the big button in front are handled by Holtek.
    I tested it a bit as follows:
    - Holding the big front button activates the test alarm (blinking red LED and sound) and sets P26 (low)
    - Burning a piece of paper under the detector makes it show some numbers on the LCD going up. Once they go above a threshold (I think it was 120 - what unit is this?), the alarm scenario activates (same as above) and does not deactivate until the values go back down below another threshold.

    In esphome I was able to set up deep sleep on CBU to wakeup on P24 and P26 (button or fire).
  • #12 21267359
    divadiow
    Level 34  
    >>21267322

    thank you for adding your findings

    Added after 8 [minutes]:

    >>21267187

    just to echo this. here is the storage area info before pairing to Tuya app

    Code: JSON
    Log in, to see the code


    Added after 6 [minutes]:

    and then after when config has been pulled to device. I had to attach as txt file because the site would not submit it as post text.
  • #13 21267382
    divadiow
    Level 34  
    piotrszulc1 wrote:
    I don't think it's tuya-mcu

    indeed. TuyaMCU devices usually (always?) have a different MCU version number to the Main Module version in the app when paired. No TuyaMCU = same version listed for both.
    Screen indicating no updates available, showing the main module and MCU module version as V1.0.2.

    Added after 1 [minutes]:

    the question is, is the MCU talking to the CBU over RX/TX at all?

    Added after 6 [minutes]:

    certainly no TuyaMCU analyser hits

    TuyaMCU Explorer/Analyzer program interface with options for analyzing data in hex format.
  • ADVERTISEMENT
  • #14 21267461
    piotrszulc1
    Level 9  
    Hmm if this is available via tuya API, then it must also be possible to get this value on CBU:

    Quote:

    co_value Integer
    {
    "unit": "ppm",
    "min": 0,
    "max": 1000,
    "scale": 0,
    "step": 1
    }


    Maybe there actually is a UART connection with Holtek?
  • #15 21267503
    divadiow
    Level 34  
    OK sure. yes.

    I have a logic analyser but haven't really mastered its use yet.
  • #16 21267895
    sofaking
    Level 2  
    i've had a few more test runs with the original firmware. the following communication seems to happen on boot/reset when i sniff on the rx/tx lines of the cbu

    This is sent from the CBU to the MCU
    
    00000000 01010101 00000111 00000011 00000001 00000000 00000000 01100000 01010101 00000111 00000011 00000001 00000000 00000000 01100000 01010101 00000111 00000011 00000001 00000000 00000000 01100000
    


    or in hex
    
    0 55 7 3 1 0 0 60 55 7 3 1 0 0 60 55 7 3 1 0 0 60
    


    not sure what this does though maybe some init for the MCU to trigger the UART sends or is it something CBU specific (for flashing etc?)

    when i press the test button on the front this data is sent from the MCU to the CBU

    
    10101010 00010011 00010100 00011011 00000000 00000111 00000001 00110110 00000000 00000000 00000000 00000011 01010000 10010000 00000000 00000001 00000001 01010101 01100100
    10101010 00010011 00010100 00011011 00000000 00000111 00000001 00110110 00000000 00000000 00000000 00000011 01010000 10010000 00000000 00000001 00000001 01010101 01100100
    10101010 00010011 00010100 00011011 00000000 00000111 00000001 00110110 00000000 00000000 00000000 00000011 01010000 10010000 00000000 00000001 00000001 01010101 01100100
    10101010 00010011 00010101 00011011 00000000 00000111 00000001 00110110 00000000 00000000 00000000 00000011 01010000 10010000 00000000 00000001 00000001 01010101 01100101
    


    or in hex

    
    AA 13 14 1B 0 7 1 36 0 0 0 3 50 90 0 1 1 55 64
    AA 13 14 1B 0 7 1 36 0 0 0 3 50 90 0 1 1 55 64
    AA 13 14 1B 0 7 1 36 0 0 0 3 50 90 0 1 1 55 64
    AA 13 15 1B 0 7 1 36 0 0 0 3 50 90 0 1 1 55 65
    


    now i also tested what happens when the CO value is not zero (don't ask me how i did it but it involved a plastic cup, a straw and cigarette smoke :D). The uart part of the log looks like this with CO levels on 0

    
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[1] = AA
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[2] = 13
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[3] = 14
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[4] = 1B
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[5] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[6] = 7
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[7] = 1
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[8] = 36
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[9] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[10] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[11] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[12] = 3
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[13] = 50
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[14] = 91
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[15] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[16] = 1
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[17] = 1
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[18] = 55
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[19] = 65
    [01-01 01:00:05 TUYA Debug][lr:0x5ae59] g_hw_config.co_info.co_value = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae65] g_hw_config.co_info.fault_value = 0
    


    and this happens when the CO value is higher

    
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[1] = AA
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[2] = 13
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[3] = 14
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[4] = 5B
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[5] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[6] = 7
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[7] = 1
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[8] = 36
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[9] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[10] = 55
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[11] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[12] = DB
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[13] = 5C
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[14] = 91
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[15] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[16] = 1
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[17] = 1
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[18] = 55
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[19] = DE
    [01-01 01:00:05 TUYA Debug][lr:0x5ae59] g_hw_config.co_info.co_value = 85
    [01-01 01:00:05 TUYA Debug][lr:0x5ae65] g_hw_config.co_info.fault_value = 0
    


    this led me to believe that the CO value is set in uart data index 10 (55 hex = 85 dec)

    also i saw that the tuya smartlife app won't report the CO value, I think unless the alarm limit is reached (not sure what that value is but certainly nothing you could trigger with a cigarette i guess). the only way i could get the original firmware to read out the co value was to reset the device. probably only the alarm will trigger the sleep timer to wake the device for a UART readout.

    Added after 56 [minutes]:

    so i'm back on OpenBeken after this debugging session and had success with doing the following

    1) added  autoexec.bat with the following content (not sure if the uartSendHex is needed at this point)

    
    uartInit 9600
    uartSendHex 00 55 07 03 01 00 00 60 55 07 03 01 00 00 60 55 07 03 01 00 00 60
    


    2) went to log and sent the following command again
    
    uartSendHex 00 55 07 03 01 00 00 60 55 07 03 01 00 00 60 55 07 03 01 00 00 60
    


    then this happens on the OpenBeken log

    
    Debug:CMD:cmd [uartSendHex 00 55 07 03 01 00 00 60 55 07 03 01 00 00 60 55 07 03 01 00 00 60]
    Info:CMD:[WebApp Cmd 'uartSendHex 00 55 07 03 01 00 00 60 55 07 03 01 00 00 60 55 07 03 01 00 00 60' Result] OK
    Info:CMD:UART received:
    Info:CMD:UART received: AA 13 14 1B 00 07 01 36 00 00 00 04 5D 92 00 01 01 55 74
    Info:MAIN:Time 361, idle 184173/s, free 74792, MQTT 0(22), bWifi 1, secondsWithNoPing 291, socks 2/38
    Info:CMD:UART received: AA 13 14 1B 00 07 01 36 00 00 00 04 5D 92 00 01 01 55 74
    Info:MAIN:Time 362, idle 188786/s, free 74792, MQTT 0(22), bWifi 1, secondsWithNoPing 292, socks 2/38
    Info:CMD:UART received: AA 13 15 1B 00 07 01 36 00 00 00 04 5C 92 00 01 01 55 74
    Info:MAIN:Time 363, idle 182937/s, free 74792, MQTT 0(22), bWifi 1, secondsWithNoPing 293, socks 2/38
    


    so this seems to be the command to read out the current CO value *yay*.

    also when the test button is pressed i get

    
    Info:CMD:UART received: AA 13 14 1B 00 07 01 36 00 00 00 04 5D 92 00 01 01 55 74
    Info:CMD:UART received: AA 13 15 1B 00 07 01 36 00 00 00 04 5D 92 00 01 01 55 75
    
  • #17 21268258
    piotrszulc1
    Level 9  
    @sofaking that's a very interesting find, thanks!

    I have found that Holtek actually offers a reference design and it comes with an example implementation. This code actually sends a bunch of values via uart and the content starts with 0xAA:

    Quote:

    S_RS232_SEND(0XAA); //0
    S_RS232_SEND(35); //1
    S_RS232_SEND(R_SYS_FG.byte); //2
    S_RS232_SEND(R_CO_AL_REF_H); //3
    S_RS232_SEND(R_CO_AL_REF_L); //4
    S_RS232_SEND(R_CO_AL_BD_H); //5
    S_RS232_SEND(R_CO_AL_BD_L); //6
    S_RS232_SEND(R_CO_LD_H); //7
    S_RS232_SEND(R_CO_LD_L); //8
    S_RS232_SEND(R_CO_AD_DATA_H); //9
    S_RS232_SEND(R_CO_AD_DATA_L); //10
    S_RS232_SEND(R_BAT_CHECK_DELAY); //11
    S_RS232_SEND(R_BAT_ADC); //12
    S_RS232_SEND(R_START_DELAY_H); //13
    S_RS232_SEND(R_CO_LD_FG); //14
    S_RS232_SEND(R_LED_FG.byte); //15
    S_RS232_SEND(R_MODE_INI_FG.byte); //16
    S_RS232_SEND(R_COERR_DAT[2]); //17
    S_RS232_SEND(R_COERR_DAT[1]); //18
    S_RS232_SEND(R_COERR_DAT[0]); //19
    S_RS232_SEND(R_CO_SYS_FG.byte); //20
    S_RS232_SEND(R_CO_BD_FG.byte); //21
    S_RS232_SEND(R_LED_WAIT_DELAY); //22
    S_RS232_SEND(_opvos); //23
    S_RS232_SEND(00); //24
    S_RS232_SEND(R_CO_PWON_H); //25
    S_RS232_SEND(R_CO_PWON_L); //26
    S_RS232_SEND(00); //27
    S_RS232_SEND(00); //28
    S_RS232_SEND(00); //29
    S_RS232_SEND(00); //30
    S_RS232_SEND((C_SOFT_VERSION>>8)); //31
    S_RS232_SEND((C_SOFT_VERSION&0XFF));//32
    S_RS232_SEND(0x55); //33
    S_RS232_SEND(R_RS_CHEAKSUM); //34


    I wonder if Tuya implementation is based on this code :)

    Added after 36 [minutes]:

    The last byte in @sofaking's data sets really seems to be a checksum, calculated exactly the same as it is in the "reference design" code, ie.: Add up all preceding bytes and get the lowest byte of the sum.
  • #18 21273620
    divadiow
    Level 34  
    The SWS pad is interesting. SWS labelled pads I thought were for Telink Single Wire Slave protocol communications. It traces to RX2 on the CBU.
  • #19 21275571
    piotrszulc1
    Level 9  
    So I've noticed that this:
    Quote:

    0 55 7 3 1 0 0 60 55 7 3 1 0 0 60 55 7 3 1 0 0 60


    Is just the same command sent 3 times (checksum 60 matches) and all is preceded with a single 0.

    Also I have found that this:
    Quote:

    [01-01 01:00:05 TUYA Debug][lr] recieve_uart_data[14] = 91


    holds the current temperature. I yet don't know how exactly it is encoded, but I experimented a bit with high (heater) and low (outside) temperatures and I've noticed it changes consistently. The lowest value I observed so far was 0x90 (chilly), the highest was 0xA2 (hot to the hand). Now I've put it into the freezer (-17 C), we'll see how low it can go :)

    Btw. I've build an esphome-based setup for testing, if anyone is interested - here it is:
    
    uart:
      - id: holtek_uart
        rx_pin: RX1
        tx_pin: TX1
        baud_rate: 9600
        debug:
          direction: BOTH
          dummy_receiver: true
          sequence:
            - lambda: UARTDebug::log_hex(direction, bytes, ' ');
    
    button:
      - platform: template
        id: holtek_trigger
        name: "Trigger Holtek"
        on_press:
          then:
            - lambda: |-
                std::vector<uint8_t> data_to_write = {0x00, 0x55,
                                                      id(byte_1).state,
                                                      id(byte_2).state,
                                                      id(byte_3).state,
                                                      id(byte_4).state,
                                                      id(byte_5).state
                                                      };
    
                uint8_t checksum = 0;
                for (auto & byte: data_to_write)
                {
                  checksum  = byte;
                }
                data_to_write.push_back(checksum);
                id(holtek_uart).write_array(&data_to_write.front(), data_to_write.size());
    
    number:
      - platform: template
        id: byte_1
        name: "Byte 1"
        optimistic: true
        min_value: 0
        max_value: 255
        initial_value: 7
        step: 1
      - platform: template
        id: byte_2
        name: "Byte 2"
        optimistic: true
        min_value: 0
        max_value: 255
        initial_value: 3
        step: 1
      - platform: template
        id: byte_3
        name: "Byte 3"
        optimistic: true
        min_value: 0
        max_value: 255
        initial_value: 1
        step: 1
      - platform: template
        id: byte_4
        name: "Byte 4"
        optimistic: true
        min_value: 0
        max_value: 255
        initial_value: 0
        step: 1
      - platform: template
        id: byte_5
        name: "Byte 5"
        optimistic: true
        min_value: 0
        max_value: 255
        initial_value: 0
        step: 1
    
    


    Pressing the "Trigger holtek" button sends the following values to the Holtek chip: [00 55 Byte1 Byte2 Byte3 Byte4 Byte5 Checksum]
    I've noticed it sometimes takes a few retries for the chip to answer (maybe it sleeps?).
    And so far I was not able to make the chip answer to anything but exactly the bytes that @sofaking discovered (bytes 7 3 1 0 0)

    Added after 3 [minutes]:

    Oh, an I believe the temperature is actually the internal temperatre of the chip itself, because there was a significant time delay (up to a minute?) in reaction: the ambient temperature was already at "room temperature", but the values reported via uart were still getting up.

    Added after 36 [minutes]:

    Unfortunately, after visiting the freezer, the device went into fault state for a while (. When it finally recovered, the value reported on byte 14 was initially 0, then 8A and going higher up to 91 (room temperature, ca. 23 degrees celsius).

    Some more observations:
    The device chip sends always exactly 3 separate responses, and usually it coincides with the "fire alarm" pin (P26) to go low. The second response has also always the same (lowest) bit of the 3rd byte toggle: high->low->high:

    
    19:32:54
    [D]
    [button:010]
    'Trigger Holtek' Pressed.
    19:32:55
    [D]
    [uart_debug:114]
    >>> 00 55 07 03 01 00 00 60
    19:32:55
    [D]
    [binary_sensor:036]
    'Fire': Sending state ON
    19:32:56
    [D]
    [uart_debug:114]
    <<< AA 13 14 1B 00 09 01 36 00 00 00 04 5C 91 00 01 01 55 74
    19:32:56
    [D]
    [binary_sensor:036]
    'Fire': Sending state OFF
    19:32:57
    [D]
    [uart_debug:114]
    <<< AA 13 15 1B 00 09 01 36 00 00 00 04 5C 91 00 01 01 55 75
    19:32:58
    [D]
    [uart_debug:114]
    <<< AA 13 14 1B 00 09 01 36 00 00 00 05 5C 91 00 01 01 55 75
    


    So this bit probably means the same: fire alarm

    Added after 2 [minutes]:

    According to the manual of this device, the working temperature range is: -10C to +55C

    Added after 29 [minutes]:

    Ok, the last one for today:
    After the battery is replaced there's a coundown on the display, and during this time Byte 3 is always at 0. After that it either holds value 0x14 or 0x15
  • Helpful post
    #20 21353854
    Samezrp1
    Level 13  
    Today I came across this topic by chance, in a separate here .
    have tried to understand the device a little.
    A lot of information is repeated, but maybe my findings will inspire someone.

    Below found commands sent by the MCU:
    
    standard operation
    [14:53:38:095] Read data (COM23)     aa 13 00 18 00 0a 01 36 00 00 03 48 00 00 00 01 01 55 b8 
    [14:53:39:122] Read data (COM23)     aa 13 00 18 00 0a 01 36 00 00 03 1d 00 00 00 01 01 55 8d 
    [14:53:40:149] Read data (COM23)     aa 13 00 18 00 0a 01 36 00 00 02 d5 00 00 00 01 01 55 44 
    [14:57:21:570] Read data (COM23)     aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69 
    [14:57:22:595] Read data (COM23)     aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69 
    [14:57:23:619] Read data (COM23)     aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69 
    [15:00:41:652] Read data (COM23)     aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69 
    [15:00:42:689] Read data (COM23)     aa 13 15 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 6a 
    [15:00:43:699] Read data (COM23)     aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69 
    [15:00:45:755] Read data (COM23)     aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69 
    [15:00:46:792] Read data (COM23)     aa 13 15 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 6a 
    [15:00:47:808] Read data (COM23)     aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69 
    [15:04:12:111] Read data (COM23)     aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69 
    [15:04:13:147] Read data (COM23)     aa 13 15 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 6a 
    [15:04:14:163] Read data (COM23)     aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69 
    test
    [18:13:36:478] Read data (COM23)     aa 13 15 1b 00 0a 01 36 00 03 00 13 4b 97 00 01 01 55 7d 
    [18:13:37:495] Read data (COM23)     aa 13 14 1b 00 0a 01 36 00 03 00 14 4b 97 00 01 01 55 7d 
    [18:13:38:528] Read data (COM23)     aa 13 14 1b 00 0a 01 36 00 03 00 15 4b 97 00 01 01 55 7e 
    [18:13:39:558] Read data (COM23)     aa 13 14 1b 00 0a 01 36 00 04 00 17 4b 97 00 01 01 55 81 
    [18:13:40:596] Read data (COM23)     aa 13 15 1b 00 0a 01 36 00 05 00 19 4b 97 00 01 01 55 85 
    [18:13:41:614] Read data (COM23)     aa 13 14 1b 00 0a 01 36 00 04 00 16 4b 97 00 01 01 55 80 
    [18:13:42:641] Read data (COM23)     aa 13 14 1b 00 0a 01 36 00 04 00 16 4b 97 00 01 01 55 80 
    [18:13:43:670] Read data (COM23)     aa 13 14 1b 00 0a 01 36 00 04 00 16 4b 97 00 01 01 55 80 
    [18:13:44:708] Read data (COM23)     aa 13 15 1b 00 0a 01 36 00 04 00 16 4b 97 00 01 01 55 81 
    
    .

    TuyaMCU only sends back:
    
    55 07 03 01 00 00 60
    
    .


    edit1:
    from the last log, there is a CO value on the place 10 string.
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[1] = AA
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[2] = 13
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[3] = 14
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[4] = 1B
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[5] = 0
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[6] = A
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[7] = 1
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[8] = 5
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[9] = 0
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[10] = A8
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[11] = 39
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[12] = 41
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[13] = 0
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[14] = 88
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[15] = 1C
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[16] = 41
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[17] = 0
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[18] = 88
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[19] = 39
    [01-01 18:12:20 TUYA Debug][lr:0x5ae59] g_hw_config.co_info.co_value = 168
    [01-01 18:12:20 TUYA Debug][lr:0x5ae65] g_hw_config.co_info.fault_value = 0
    
    .
    recieve_uart_data[10] = 0xA8 = 168 .
    
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[1] = AA
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[2] = 13
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[3] = 14
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[4] = 1B
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[5] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[6] = A
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[7] = 1
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[8] = 36
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[9] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[10] = 3
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[11] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[12] = 15
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[13] = 4B
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[14] = 97
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[15] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[16] = 1
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[17] = 1
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[18] = 55
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[19] = 7E
    [01-01 01:00:05 TUYA Debug][lr:0x5ae59] g_hw_config.co_info.co_value = 3
    [01-01 01:00:05 TUYA Debug][lr:0x5ae65] g_hw_config.co_info.fault_value = 0
    
    .
    g_hw_config.co_info.co_value = 0x03 = 3

    edit2:
    I have added my images, with the soldered TuyaMCU, so that you can trace the paths plus my findings.


    edit3:
    I pressed test 3x in a row and watched the outputs. You can see that the UART to TuyaMCU is sending messages 6 times. This is only reported once in the log, and presumably an average is calculated from this.
    
    first test press
                                     01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 CR
    [22:13:55:004] Read data (COM23) aa 13 15 1b 00 0a 01 36 00 00 00 0a 4a 97 00 01 01 55 70        
    [22:13:56:022] Read data (COM23) aa 13 14 1b 00 0a 01 36 00 00 00 0a 4a 97 00 01 01 55 6f        
    [22:13:57:054] Read data (COM23) aa 13 14 1b 00 0a 01 36 00 00 00 0b 4a 97 00 01 01 55 70        
    [22:13:58:084] Read data (COM23) aa 13 14 1b 00 0a 01 36 00 00 00 0d 4a 97 00 01 01 55 72        
    [22:13:59:122] Read data (COM23) aa 13 15 1b 00 0a 01 36 00 00 00 0e 4a 97 00 01 01 55 74        
    [22:14:00:141] Read data (COM23) aa 13 14 1b 00 0a 01 36 00 00 00 0d 4a 97 00 01 01 55 72        
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[1] = AA
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[2] = 13
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[3] = 14
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[4] = 1B
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[5] = 0
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[6] = A
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[7] = 1
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[8] = 5
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[9] = 0
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[10] = A8
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[11] = 39
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[12] = 41
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[13] = 0
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[14] = 88
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[15] = 1C
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[16] = 41
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[17] = 0
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[18] = 88
    [01-01 18:12:20 TUYA Debug][lr:0x5ae3b] recieve_uart_data[19] = 39
    [01-01 18:12:20 TUYA Debug][lr:0x5ae59] g_hw_config.co_info.co_value = 168
    [01-01 18:12:20 TUYA Debug][lr:0x5ae65] g_hw_config.co_info.fault_value = 0
    
    second test press
                                     01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 CR
    [22:15:43:341] Read data (COM23) aa 13 14 1b 00 0a 01 36 00 00 00 03 4f 99 00 01 01 55 6f        
    [22:15:44:368] Read data (COM23) aa 13 14 1b 00 0a 01 36 00 00 00 03 4f 99 00 01 01 55 6f        
    [22:15:45:399] Read data (COM23) aa 13 14 1b 00 0a 01 36 00 00 00 03 4f 99 00 01 01 55 6f        
    [22:15:48:485] Read data (COM23) aa 13 14 1b 00 0a 01 36 00 00 00 03 4f 99 00 01 01 55 6f        
    [22:15:49:512] Read data (COM23) aa 13 14 1b 00 0a 01 36 00 00 00 03 4f 99 00 01 01 55 6f        
    [22:15:50:550] Read data (COM23) aa 13 15 1b 00 0a 01 36 00 00 00 03 4f 99 00 01 01 55 70        
    [01-01 01:00:04 TUYA Debug][lr:0x5ae3b] recieve_uart_data[1] = AA
    [01-01 01:00:04 TUYA Debug][lr:0x5ae3b] recieve_uart_data[2] = 13
    [01-01 01:00:04 TUYA Debug][lr:0x5ae3b] recieve_uart_data[3] = 14
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[4] = 1B
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[5] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[6] = A
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[7] = 1
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[8] = 36
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[9] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[10] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[11] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[12] = 3
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[13] = 4B
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[14] = 97
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[15] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[16] = 1
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[17] = 1
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[18] = 55
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[19] = 69
    [01-01 01:00:05 TUYA Debug][lr:0x5ae59] g_hw_config.co_info.co_value = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae65] g_hw_config.co_info.fault_value = 0
    
    third test press
                                     01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 CR
    [22:16:31:825] Read data (COM23) aa 13 15 1b 00 0a 01 36 00 00 00 03 50 98 00 01 01 55 70        
    [22:16:32:845] Read data (COM23) aa 13 14 1b 00 0a 01 36 00 00 00 03 50 98 00 01 01 55 6f        
    [22:16:33:876] Read data (COM23) aa 13 14 1b 00 0a 01 36 00 00 00 03 50 98 00 01 01 55 6f        
    [22:16:34:906] Read data (COM23) aa 13 14 1b 00 0a 01 36 00 00 00 03 50 98 00 01 01 55 6f        
    [22:16:35:946] Read data (COM23) aa 13 15 1b 00 0a 01 36 00 00 00 03 50 98 00 01 01 55 70        
    [22:16:36:966] Read data (COM23) aa 13 14 1b 00 0a 01 36 00 00 00 03 50 98 00 01 01 55 6f 
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[1] = AA
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[2] = 13
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[3] = 14
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[4] = 1B
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[5] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[6] = A
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[7] = 1
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[8] = 36
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[9] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[10] = 3
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[11] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[12] = 15
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[13] = 4B
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[14] = 97
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[15] = 0
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[16] = 1
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[17] = 1
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[18] = 55
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[19] = 7E
    [01-01 01:00:05 TUYA Debug][lr:0x5ae59] g_hw_config.co_info.co_value = 3
    [01-01 01:00:05 TUYA Debug][lr:0x5ae65] g_hw_config.co_info.fault_value = 0
    
    .
  • Helpful post
    #21 21356890
    Samezrp1
    Level 13  
    Cd of exploration.

    1. I disassembled the circuit and sent my commands instead of MCU messages:
    Close-up of a PCB with electronic components and a CBU connector. .

    2. I sent the same wo messages, in (almost) the same order, the change was due to the different behaviour of the application on the same commands.
    I started by resetting the device and playing around after the reboot:

    yesterday's results
    01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 CR
    aa 13 14 1b 00 0a 01 36 00 01 01 03 4b 97 00 01 01 55 6B alarm 168
    aa 13 14 1b 00 0a 01 36 00 20 01 03 4b 97 00 01 01 55 6A alarm 168
    aa 13 14 1b 00 0a 01 38 00 20 01 03 4b 97 00 01 01 55 6A normal 32
    aa 13 14 1b 00 0a 01 39 00 21 01 03 4b 97 00 01 01 55 8E normal 33
    aa 13 14 1b 00 0a 01 50 00 21 01 03 4b 97 00 01 01 55 A5 no change
    aa 13 14 1b 00 0a 01 36 01 21 01 03 4b 97 00 01 01 55 8C alarm 289
    aa 13 14 1b 00 0a 01 36 01 21 00 03 4b 97 00 01 01 55 8B alarm 168
    aa 13 14 1b 00 0a 01 36 01 23 00 03 4b 97 00 01 01 55 8D alarm 168
    aa 13 14 1b 00 0a 01 36 01 23 01 03 4b 97 01 01 01 55 8F alarm 168
    aa 13 14 1b 00 0a 01 36 01 23 01 03 4b 97 00 01 01 55 8E alarm 168
    aa 13 14 1b 00 0a 01 37 01 23 01 03 4b 97 00 01 01 55 8F alarm 291
    aa 13 14 1b 00 0a 01 38 01 23 00 03 4b 97 01 01 01 55 90 ponowne wysłanie stan 168 - tak jak test
    aa 13 14 1b 00 0a 01 39 01 23 00 03 4b 97 01 01 01 55 91 uaktualnia 291
    aa 13 14 1b 01 0a 01 40 01 23 00 03 4b 97 01 01 01 55 99 uaktualnia 291
    aa 13 14 1b 00 0a 01 41 01 24 00 03 4b 97 00 00 00 55 99 uaktualnia 292
    aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69 reset to normal
    aa 13 14 1b 01 0a 01 37 00 00 00 03 4b 97 01 00 00 55 6A no change
    aa 13 14 1b 11 0a 11 37 00 00 00 03 4b 97 11 11 11 55 BC alarm 168
    aa 13 14 20 00 0a 01 36 00 00 00 03 4b 97 00 01 01 20 39 tylko powiadomienie alarm 168 fault
    aa 13 14 20 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 6E no change
    aa 13 15 20 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 6F device fault
    aa 13 15 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 6a normal, 0 ppm


    today's:
    01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 CR
    aa 13 14 1b 00 0a 01 36 00 01 01 03 4b 97 00 01 01 55 6B normal 1 ppm
    aa 13 14 1b 00 0a 01 36 00 20 01 03 4b 97 00 01 01 55 6A normal 32 ppm
    aa 13 14 1b 00 0a 01 38 00 20 01 03 4b 97 00 01 01 55 6A alarm 168 ppm
    aa 13 14 1b 00 0a 01 39 00 21 01 03 4b 97 00 01 01 55 8E normal 33 ppm
    aa 13 14 1b 00 0a 01 50 00 21 01 03 4b 97 00 01 01 55 A5 no change
    aa 13 14 1b 00 0a 01 36 01 21 01 03 4b 97 00 01 01 55 8C alarm 168 ppm
    aa 13 14 1b 00 0a 01 36 01 21 00 03 4b 97 00 01 01 55 8B alarm 168 ppm
    aa 13 14 1b 00 0a 01 36 01 23 00 03 4b 97 00 01 01 55 8D alarm 289 ppm
    aa 13 14 1b 00 0a 01 36 01 23 01 03 4b 97 01 01 01 55 8F alarm 168 ppm
    aa 13 14 1b 00 0a 01 36 01 23 01 03 4b 97 00 01 01 55 8E alarm 168 ppm
    aa 13 14 1b 00 0a 01 37 01 23 01 03 4b 97 00 01 01 55 8F alarm 291 ppm
    aa 13 14 1b 00 0a 01 38 01 23 00 03 4b 97 01 01 01 55 90 ponowne wysłanie stan 168 - tak jak test
    aa 13 14 1b 00 0a 01 39 01 23 00 03 4b 97 01 01 01 55 91 uaktualnia 291 ppm
    aa 13 14 1b 01 0a 01 40 01 23 00 03 4b 97 01 01 01 55 99 uaktualnia 291 ppm
    aa 13 14 1b 00 0a 01 41 01 24 00 03 4b 97 00 00 00 55 97 uaktualnia 292 ppm
    aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69 reset to normal
    aa 13 14 1b 01 0a 01 37 00 00 00 03 4b 97 01 00 00 55 6A no change
    aa 13 14 1b 11 0a 11 37 00 00 00 03 4b 97 11 11 11 55 BC alarm 168 ppm
    aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69 nadal alarm 168 ppm
    aa 13 15 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 70 normal 0 ppm
    aa 13 14 20 00 0a 01 36 00 00 00 03 4b 97 00 01 01 20 39 fault/alarm
    aa 13 14 20 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 6E fault/normal
    aa 13 15 20 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 6F fault/alarm 168 ppm
    aa 13 15 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 6a alarm 168 ppm
    aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69
    
    .

    from the correlations noted:
    - CO value in ppm is sent on bytes 09 and 10, int16;
    -in order for the system to notice the change after the value has been updated, byte 08 must be changed (must be a different value than the previous one);
    -generally byte 11 is responsible for triggering the alarm, but looking at command no. 6 from yesterday after triggering the alarm 11=0x01 and sending a different value on bytes 09 and 10 and setting byte 11 to 00 does not cancel the alarm, but only updates the CO value, but only if bit 08 is changed;
    -in lines 18-20 you can see that if byte 03 is not changed (from 14 to 15 or vice versa), the system does not return to the normal state;
    -Byte 04 is responsible for fault, 1b is normal, I changed it to 20 to give fault;

    Logs from today with commands also in xls file.
    You can see from it that in the alarm state the system is put to sleep for 180 seconds and reports an alarm every 3 minutes.
    You can also see that there are commands appearing from somewhere that I definitely did not send. Very strange. It doesn't look like interference. I'm talking values in red in Sheet7. In such cases, regardless of the data I send, TuyaMCU sends as CO value 168ppm.
    [01-01 01:00:05 TUYA Debug][lr:0x5ae3b] recieve_uart_data[10] = A8
    .
    The same one that is sent when pressing Test. At the same time, in my case pressing this button does nothing, because the Tx from the MCU is disconnected.

    The way the system works is that after starting the system, passing the countdown, the system enters sleep mode for 28800 seconds.

    Normal conditions: .
    Rises after 28800 sec
    Forces a report with the command:
    55 07 03 01 00 00 60
    .
    repeated 3 times,
    goes to sleep for another 28800 sec.

    Alarm state: .
    the system is woken up by the MCU via P26
    here I am not sure if getting up forces a report or if the MCU itself sends a report
    goes to rest for 180 seconds
    and so on and so forth until an alarm condition exists

    Reset/test .
    Pressing reset wakes up TuyaMCU
    waking up forces a report
    for test additionally MCU performs test procedure (as after power-on, without countdown)

    If you have ideas on what else to test let me know. Remember that it is best to run tests after the boot and standby procedure, which (it looks like) is done by a series of commands:

    01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 CR
    aa 13 00 18 00 0a 01 36 00 00 03 48 00 00 00 01 01 55 b8
    aa 13 00 18 00 0a 01 36 00 00 03 1d 00 00 00 01 01 55 8d
    aa 13 00 18 00 0a 01 36 00 00 02 d5 00 00 00 01 01 55 44
    aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69
    aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69
    aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69
    aa 13 14 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 69
    aa 13 15 1b 00 0a 01 36 00 00 00 03 4b 97 00 01 01 55 6a
    .

    the last two lines I am not sure of. With that said, I've actually been writing all along about how the Tuya application interprets the commands sent, de facto as we know which bytes correspond to fault and CO != 0 this should be enough to run the device without the cloud, the battery status is monitored and reported by the CBU.

Topic summary

The discussion revolves around configuring the Tuya CO400A-A004 carbon monoxide detector, which utilizes the BK7231N chip, with OpenBeken for local control, bypassing cloud dependency. Users share their experiences with flashing the device, UART communication, and troubleshooting pin setups for integration with Home Assistant. Various UART outputs and logs are analyzed to understand the device's communication protocols, including interactions with a Holtek BA45F6746 microcontroller responsible for detection and display functions. Participants also discuss the significance of specific commands and data structures observed during testing, aiming to establish a reliable setup for local monitoring and control.
Summary generated by the language model.
ADVERTISEMENT