logo elektroda
logo elektroda
X
logo elektroda

Tuya Water Leakage Sensor CB3S: Configuration and Firmware Details

vitya123 588 2
ADVERTISEMENT
  • #1 21354467
    vitya123
    Level 6  
    Yet another BK7231N based device freed up!

    This is a Tuya Water/leakage/water sensor. Several similar ones have been posted to the LIST, but not the exact same type. So here we go:

    The process is the same as most of the BK7231N based devices, so instead of going through each step again, I'll just post some key points of the process and the config needed to run the device successfully.

    Here is a product image from the marketplace:
    Tuya water sensor with 80 dB alarm and WiFi functionality.

    After removing the battery compartment cover, this is what we see:
    PCB of a device with a CB3S module inside a casing.

    The back side of the PCB:
    The interior PCB of a Tuya BK7231N water sensor with electronic components.

    These are the points we need to re-program the device:
    PCB of a device with CB3S module, showing solder points and wires.
    The white wire is the monitoring output. All the other points used are clearly marked on the board. I used the battery terminals to power the device with an external power supply.

    I attached the backup of the original firmware.

    Here is the bootlog with the original firmware:

    V:BK7231N_1.0.1
    REG:cpsr     spsr     r13      r14
    SVC:000000D3          00401C1C 000033AC
    IRQ:000000d2 00000010 00401e0c f3ccd9ee
    FIR:000000d1 00000010 00401ffc dd6fe74f
    SYS:000000df          0040192c 00000158
    ST:00000000
    J 0x10000
    [01-01 18:12:15 TUYA Info][lr:0xa650d] mqc app init ...
    [01-01 18:12:15 TUYA Info][lr:0xaf86f] thread_create name:sys_timer,stackDepth:4096,totalstackDepth:4096,priority:5
    [01-01 18:12:15 TUYA Info][lr:0xaf86f] thread_create name:cmmod,stackDepth:4096,totalstackDepth:8192,priority:4
    [01-01 18:12:15 TUYA Debug][lr:0xaf6fb] Thread:sys_timer Exec Start. Set to Running Stat
    [01-01 18:12:15 TUYA Debug][lr:0xa64bb] mq_pro:5 cnt:1
    [01-01 18:12:15 TUYA Debug][lr:0xa64bb] mq_pro:31 cnt:2
    [01-01 18:12:15 TUYA Err][lr:0xa00db] logseq empty
    [01-01 18:12:15 TUYA Debug][lr:0xaf1df] svc online log init success
    [01-01 18:12:15 TUYA Info][lr:0xaf86f] thread_create name:wk_th-0,stackDepth:5120,totalstackDepth:13312,priority:3
    [01-01 18:12:15 TUYA Err][lr:0x987ed] wd_protected_read fails gw_bi -1
    [01-01 18:12:15 TUYA Debug][lr:0x98aaf] gw base read finish:-1
    [01-01 18:12:15 TUYA Debug][lr:0xa36f5] ty bt cmmod regist ok:1
    [01-01 18:12:15 TUYA Debug][lr:0xa39f1] 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:0xa37df] tyx1a,status:0x0
    [01-01 18:12:15 TUYA Debug][l[PLATFORM NOTICE]STACK r
    [01-01 18:12:15 TUYAIug][lr:0x5a3ef] < TUYA Debug][lr:0x5a3ef] < T IOT SDK V:2.3.1 BS:40.0UYA IOT SDK V:2.3.1 BS:0_PT:2.2_LAN:3.3_CAD:1.40.00_PT:2.2_LAN:3.3_CA0.3_CD:1.0.0 >
    < BUILDD:1.0.3_CD:1.0.0 >
    < B AT:2021_12_21_18_23_21UILD AT:2021_12_21_18_2 BY ci_manage FOR ty_io3_21 BY ci_manage FOR tt_sdk_bk7231nl AT BK723y_iot_sdk_bk7231nl AT BK1NL >
    IOT DEFS < WIFI_7231NL >
    IOT DEFS < WIGW:1 DEBUG:1 KV_FILE:0 FI_GW:1 DEBUG:1 KV_FILESHUTDOWN_MODE:0 LITTLE_:0 SHUTDOWN_MODE:0 LITT[PLATFORM NOTICE]CREATELE_[01-01 18:12:15 TUYA ice][lr:0x5a431] power Notice][lr:0x5a431] pow_on wake up
    er_on wake up
    [PLATFORM DEBUG]!!!!!!!!!!tuya_os_adapt_b[01-01 18:12:15 TUYA NotConfig = ,bt_pin:24,sttice][lr:0x5a1a7] pConfatus_led_pin:26,rstcnt:ig = ,bt_pin:24,status_3,nxtalm_t:3,basic_pin_led_pin:26,rstcnt:3,nxtapin:8,bt_lv:0,bz_pin_pilm_t:3,basic_pin_pin:8,n:7,net_t:180,samp_typebt_lv:0,bz_pin_pin:7,ne:1,bz_pin_lv:1,basic_stt_t:180,samp_type:1,bz_:1,basic_pin_lv:1,alarmpin_lv:1,basic_st:1,bas_type:2,samp_sw_pin:14,ic_pin_lv:1,alarm_type:2max_V:3000,min_V:1800,s,samp_sw_pin:14,max_V:3ound_p000,min_V:1800,sound_p[01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,bt_pin:-----val:24
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,status_led_pin:-----val:26
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,basic_pin_pin:-----val:8
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,samp_sw_pin:-----val:14
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,bt_lv:-----val:0
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,status_led_lv:-----val:1
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,basic_pin_lv:-----val:1
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,basic_st:-----val:1
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,tamper_st:-----val:1
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,rstcnt:-----val:3
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,net_t:-----val:180
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,samp_type:-----val:1
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,max_V:-----val:3000
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,min_V:-----val:1800
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,beep_t:-----val:15
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,nxtalm_t:-----val:3
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,samp_pin:-----val:23
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,sound_pin:-----val:6
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,bz_pin_pin:-----val:7
    [01-01 18:12:15 TUYA Notice][lr:0x5991f] key:,alarm_type:-----val:2
    [01-01 18:12:15 TUYA Notice][lr:0x5994d] g_hw_abs_tb.res_key.pin is:24,
    [01-01 18:12:15 TUYA Notice][lr:0x5a1bd] OEM FIRMWARE,FREE POINTER
    [01-01 18:12:15 TUYA Err][lr:0x599ef] config wfst_pin value err:1
    [01-01 18:12:15 TUYA Notice][lr:0x599f5] no tamper stat pin!
    [01-01 18:12:15 TUYA Err][lr:0x5986f] config wfst_pin value err:0
    [01-01 18:12:15 TUYA Notice][lr:0x5999b] no led2 pin!,sigle led!
    [01-01 18:12:15 TUYA Notice][lr:0x5a297] FLASH LED 1
    [01-01 18:12:15 TUYA Notice][lr:0xcae51] protected data not enabled
    [01-01 18:12:15 TUYA Notice][lr:0xc57bb] sf protected init err, need backup
    [01-01 18:12:15 TUYA Notice][lr:0xc57d7] key_addr: 0x1ee000   block_sz 4096
    [01-01 18:12:15 TUYA Notice][lr:0xa3b09] ble adv upd!
    [PLATFORM NOTICE]!!!!!!!!!!tuya_before_netcfg_cb
    [PLATFORM DEBUG]UNKNOW EVENT:17
    [PLATFORM DEBUG]UNKNOW EVENT:1[01-01 18:12:15 TUYA No6:0xc58a7] get key:
    tus:0x0r:0xc58a7] get key:[PLATFORM DEBUG]UNKNOW
    0x64 0xed 0xdEVENT:16
    [PLATFORM DEBfTFORM DEBUG]UNKNOW EVEUG]UNKNOW EVENT:16
    NT:16
    0x35 0x8a 0xa1 0xe4[PLATFORM FORM DEBUG]UN DEBUG]UNKNOW EVENT:16
    KNOW EVENT:16
    0x51 0x88 0x50 0x0 0x63 0x3c 0x8e 0x33 0xe1
    [01-01 18:12:15 TUYA Notice][lr:0xc5d43] kv valid but protected invalid, format it
    [01-01 18:12:15 TUYA Notice][lr:0xcae51] protected data not enabled
    [01-01 18:12:16 TUYA Notice][lr:0x581ed] mf_init succ
    [01-01 18:12:16 TUYA Notice][lr:0x5a3a9] OEM FIRMWARE,READ FLASH KV REGION
    [01-01 18:12:16 TUYA Notice][lr:0xcae51] protected data not enabled
    [01-01 18:12:16 TUYA Notice][lr:0x58255] current product ssid name:tuya_mdev_test1
    [01-01 18:12:18 TUYA Notice][lr:0x5a501] SysGetHeapSize() is:80992
    [PLATFORM NOTICE]bk_rst:0 tuya_rst:0
    [01-01 18:12:18 TUYA Notice][lr:0x9cd3f] Last reset reason: 0
    [01-01 18:12:18 TUYA Notice][lr:0xcae51] protected data not enabled
    [01-01 18:12:18 TUYA Notice][lr:0x9ceaf] serial_no:4ca919feef53
    [01-01 18:12:18 TUYA Notice][lr:0xcae51] protected data not enabled
    [01-01 18:12:18 TUYA Notice][lr:0x9cee7] gw_cntl.gw_wsm.stat:0
    [01-01 18:12:18 TUYA Notice][lr:0x9cf75] gw_cntl.gw_wsm.nc_tp:0
    [01-01 18:12:18 TUYA Notice][lr:0x9cf7d] gw_cntl.gw_wsm.md:0
    [01-01 18:12:18 TUYA Notice][lr:0x9d16b] gw_cntl.gw_if.abi:0 input:0
    [01-01 18:12:18 TUYA Notice][lr:0x9d177] gw_cntl.gw_if.product_key:key4cngfa3qtqsk7, input:key4cngfa3qtqsk7
    [01-01 18:12:18 TUYA Notice][lr:0x9d183] gw_cntl.gw_if.tp:0, input:0
    [01-01 18:12:18 TUYA Notice][lr:0x9d193] gw_cntl.gw_if.firmware_key:key4cngfa3qtqsk7, input:key4cngfa3qtqsk7
    [01-01 18:12:18 TUYA Notice][lr:0xa3833] ty bt upd product:key4cngfa3qtqsk7 1
    [01-01 18:12:18 TUYA Notice][lr:0xa3c8f] upd product_id type:1 key4cngfa3qtqsk7 d112e2251ab91bb4 oGHHRSHP0bXxJDNrEsWv7SrXXhPv3lMc
    [01-01 18:12:18 TUYA Notice][lr:0x5a309] JSON Config finish
    [01-01 18:12:18 TUYA Notice][lr:0x5b3cd] led_flash_init success
    [01-01 18:12:18 TUYA Notice][lr:0x5b519] Now status is 4
    [01-01 18:12:18 TUYA Notice][lr:0x5a575] this is not a IO_Wake_event
    [01-01 18:12:18 TUYA Notice][lr:0x5a6a3] first network
    [01-01 18:12:18 TUYA Notice][lr:0x5a06d] wifi status is :0
    [01-01 18:12:18 TUYA Notice][lr:0x5a079] SysGetHeapSize() is:69760
    [01-01 18:12:18 TUYA Notice][lr:0x59781] wifi status is :0
    [01-01 18:12:18 TUYA Notice][lr:0x5978b] is_net_work_connect 0
    [01-01 18:12:18 TUYA Notice][lr:0x5b49b] sleep_tim is 10
    [01-01 18:12:18 TUYA Notice][lr:0x58c39] upload adc low val is:1800
    [01-01 18:12:18 TUYA Notice][lr:0x58c41] upload adc high val is:3000
    [01-01 18:12:18 TUYA Notice][lr:0x58c49] g_hw_abs_tb.adc_col.ele_val is:3172
    [01-01 18:12:18 TUYA Notice][lr:0x5a06d] wifi status is :0
    [01-01 18:12:18 TUYA Notice][lr:0x5a079] SysGetHeapSize() is:73896
    [01-01 18:12:18 TUYA Notice][lr:0x59781] wifi status is :0
    [01-01 18:12:18 TUYA Notice][lr:0x5978b] is_net_work_connect 0
    [01-01 18:12:18 TUYA Notice][lr:0x5b493] led_power_off_tm stop success
    [01-01 18:12:18 TUYA Notice][lr:0x5b49b] sleep_tim is 10
    [01-01 18:12:19 TUYA Notice][lr:0x5b151] close led
    [01-01 18:12:19 TUYA Notice][lr:0x5b1ad] count is 9
    [01-01 18:12:19 TUYA Notice][lr:0x5b1b7] last stat is 4
    [01-01 18:12:20 TUYA Notice][lr:0x5b1ad] count is 8
    [01-01 18:12:20 TUYA Notice][lr:0x5b1b7] last stat is 4
    [01-01 18:12:21 TUYA Notice][lr:0x5b1ad] count is 7
    [01-01 18:12:21 TUYA Notice][lr:0x5b1b7] last stat is 4
    [01-01 18:12:22 TUYA Notice][lr:0x5b1ad] count is 6
    [01-01 18:12:22 TUYA Notice][lr:0x5b1b7] last stat is 4
    [01-01 18:12:23 TUYA Notice][lr:0x5b1ad] count is 5
    [01-01 18:12:23 TUYA Notice][lr:0x5b1b7] last stat is 4
    [01-01 18:12:24 TUYA Notice][lr:0x5b1ad] count is 4
    [01-01 18:12:24 TUYA Notice][lr:0x5b1b7] last stat is 4
    [01-01 18:12:25 TUYA Notice][lr:0x5b1ad] count is 3
    [01-01 18:12:25 TUYA Notice][lr:0x5b1b7] last stat is 4
    [01-01 18:12:26 TUYA Notice][lr:0x5b1ad] count is 2
    [01-01 18:12:26 TUYA Notice][lr:0x5b1b7] last stat is 4
    [01-01 18:12:27 TUYA Notice][lr:0x5b1ad] count is 1
    [01-01 18:12:27 TUYA Notice][lr:0x5b1b7] last stat is 4
    [01-01 18:12:28 TUYA Notice][lr:0x5b1ad] count is 0
    [01-01 18:12:28 TUYA Notice][lr:0x5b1b7] last stat is 4
    [01-01 18:12:28 TUYA Notice][lr:0x5b151] close led
    [01-01 18:12:28 TUYA Notice][lr:0x59c51] enter sleep mode,sleep_timer is 28800
    


    The Tuya template:
    {
       "bt_pin":"24",
       "status_led_pin":"26",
       "rstcnt":"3",
       "nxtalm_t":"3",
       "basic_pin_pin":"8",
       "bt_lv":"0",
       "bz_pin_pin":"7",
       "net_t":"180",
       "samp_type":"1",
       "bz_pin_lv":"1",
       "basic_st":"1",
       "basic_pin_lv":"1",
       "alarm_type":"2",
       "samp_sw_pin":"14",
       "max_V":"3000",
       "min_V":"1800",
       "sound_pin":"6",
       "samp_sw_lv":"1",
       "beep_t":"15",
       "status_led_lv":"1",
       "samp_pin":"23",
       "tamper_st":"1",
       "crc":"31"
    }
    


    Which translates to this:
    Quote:
    Device configuration, as extracted from Tuya:
    - Button (channel 0) on P24
    - Status LED on P26
    - PIR sensor on P8
    - Buzzer on P7
    - Battery Relay on P14
    - Battery Max Voltage: 3000
    - Battery Min Voltage: 1800
    - Battery ADC on P23
    Device seems to use Battery Driver. See more details here: https://www.elektroda.com/rtvforum/topic3959103.html
    No module information found.
    And the Tuya section starts, as usual, at 2023424


    Bootlog after conversion:
    V:BK7231N_1.0.1
    REG:cpsr     spsr     r13      r14
    SVC:000000D3          00401C1C 000033AC
    IRQ:000000d2 00000010 00401e0c f3ccd9ee
    FIR:000000d1 00000010 00401ffc dd6fe76f
    SYS:000000df          0040192c 00000158
    ST:00000000
    J 0x10000
    bk_misc_init_start_type 0 0
    prvHeapInit-start addr:0x4144d8, size:113448
    [Flash]id:0xeb6015
    sctrl_sta_ps_init
    cset:0 0 0 0
    Entering initLog()...
    Commands registered!
    initLog() done!
    Info:MAIN:Main_Init_Before_Delay
    Info:CFG:####### Boot Count 2 #######
    Warn:CFG:CFG_InitAndLoad: Correct config has been loaded with 1 changes count.
    Error:CMD:lfs is absent
    Info:GEN:PIN_SetupPins pins have been set up.
    Info:MAIN:Main_Init_Before_Delay done
    
    Main_Init_Before_Delay done
    Info:MAIN:Main_Init_Delay
    
    Main_Init_Delay
    
    delaying start
    bandgap_calm_in_efuse=0x70
    [load]bandgap_calm=0x70->0x30,vddig=4->5
    [FUNC]rwnxl_init
    [bk]tx_tx#Startup delayed 0ms#
    delayed 0ms#
    [FUNC]intc_init
    [FUNC]calibration_main
    gpio_level=1,txpwr_state=15
                               user define rfcali mode:1
    get #Startup delayed 10ms#
    rtup delayed 10ms#
    #Startup delayed 20ms#
    #Startup delayed 30ms#
    #Startup delayed 40ms#
    #Startup delayed 50ms#
    #Startup delayed 60ms#
    #Startup delayed 70ms#
    #Startup delayed 80ms#
    #Startup delayed 90ms#
    #Startup delayed 100ms#
    #Startup delayed 110ms#
    #Startup delayed 120ms#
    #Startup delayed 130ms#
    #Startup delayed 140ms#
    #Startup delayed 150ms#
    #Startup delayed 160ms#
    #Startup delayed 170ms#
    #Startup delayed 180ms#
    #Startup delayed 190ms#
    #Startup delayed 200ms#
    #Startup delayed 210ms#
    #Startup delayed 220ms#
    #Startup delayed 230ms#
    #Startup delayed 240ms#
    #Startup delayed 250ms#
    #Startup delayed 260ms#
    #Startup delayed 270ms#
    #Startup delayed 280ms#
    #Startup delayed 290ms#
    #Startup delayed 300ms#
    #Startup delayed 310ms#
    #Startup delayed 320ms#
    #Startup delayed 330ms#
    #Startup delayed 340ms#
    #Startup delayed 350ms#
    #Startup delayed 360ms#
    #Startup delayed 370ms#
    DPLL Unlock
    DPLL Unlock
    #Startup delayed 380ms#
    #Startup delayed 390ms#
    #Startup delayed 400ms#
    #Startup delayed 410ms#
    #Startup delayed 420ms#
    #Startup delayed 430ms#
    #Startup delayed 440ms#
    #Startup delayed 450ms#
    #Startup delayed 460ms#
    DPLL Unlock
    DPLL Unlock
    #Startup delayed 470ms#
    calibration_main over
                         flash txpwr table:0xf
    dif g and n20 ID in flash:4
    dif g and n40 ID in flash:4
    read txpwr tab from flash success
    temp in flash is:244
    xtal in flash is:70
    xtal_cali:70
    --init_xtal = 70
                    [FUNC]ps_i#Startup delayed 480ms#
    nlayed 480ms#
    [FUNC]func_init_extended OVER!!!
    
    start_type:0
    Version:
    Initializing TCP/IP stack
    #Startup delayed 490ms#
    app_init finished
    #Startup delayed 500ms#
    #Startup delayed 510ms#
    #Startup delayed 520ms#
    #Startup delayed 530ms#
    #Startup delayed 540ms#
    #Startup delayed 550ms#
    #Startup delayed 560ms#
    #Startup delayed 570ms#
    #Startup delayed 580ms#
    #Startup delayed 590ms#
    #Startup delayed 600ms#
    #Startup delayed 610ms#
    #Startup delayed 620ms#
    #Startup delayed 630ms#
    #Startup delayed 640ms#
    #Startup delayed 650ms#
    #Startup delayed 660ms#
    #Startup delayed 670ms#
    #Startup delayed 680ms#
    #Startup delayed 690ms#
    #Startup delayed 700ms#
    #Startup delayed 710ms#
    #Startup delayed 720ms#
    #Startup delayed 730ms#
    #Startup delayed 740ms#
    
    starting....
    Info:MAIN:Main_Init_Delay done
    
    Main_Init_Delay done
    Info:MAIN:Main_Init_After_Delay
    Info:MAIN:Using SSID []
    Info:MAIN:Using Pass []
    Info:MQTT:MQTT_RegisterCallback called for bT obk19FEEF53/ subT obk19FEEF53/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT bekens_n/ subT bekens_n/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/obk19FEEF53/ subT cmnd/obk19FEEF53/+
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/bekens_n/ subT cmnd/bekens_n/+
    Info:MQTT:MQTT_RegisterCallback called for bT obk19FEEF53/ subT obk19FEEF53/+/get
    Error:CMD:LFS_ReadFile: lfs is absent
    Info:CMD:CMD_StartScript: failed to get file autoexec.bat
    Info:MAIN:Main_Init_After_Delay done
    cal_bias!
    DPLL Unlock
    cal dpll!
    temperature_type=1
                      temp_code:-29 - adc_code:352 - adc_trend:[13]:244->[3]:344
    Info:MAIN:Time 1, idle 254483/s, free 80728, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    temp_code:-28 - adc_code:351 - adc_trend:[3]:344->[2]:354
    Info:MAIN:Time 2, idle 441512/s, free 80728, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 3, idle 187297/s, free 80728, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 4, idle 186067/s, free 80728, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 5, idle 187189/s, free 80728, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:no flash configuration, use default
    Info:MAIN:set ip info: 192.168.4.1,255.255.255.0,192.168.4.1
    Info:MAIN:ssid:OpenBK7231N_19FEEF53  key: mode:0
    hostapd_main_exiting
    hostapd_exit_handler
    hostapd_exit_done
    Soft_AP_start
    [saap]MM_RESET_REQ
    [bk]tx_txdesc_flush
    [saap]ME_CONFIG_REQ
    [saap]ME_CHAN_CONFIG_REQ
    [saap]MM_START_REQ
    hapd_intf_add_vif,type:3, s:0, id:0
    apm start with vif:0
    me_set_ps_disable:840 0 0 1 0 0
    ------beacon_int_set:100 TU
    set_active param 0
                      [msg]APM_STOP_CFM
                                       update_ongoing_1_bcn_update
    vif_idx:0, ch_idx:0, bcmc_idx:1
    update_ongoing_1_bcn_update
    enter low level!
    mac 4c:a9:19:fe:ef:52
    leave low level!
    net_wlan_add_netif done!, vif_idx:0
    uap_ip_start
    
    configuring interface uap (with Static IP)WARN: TCPIP mutex is NOT locked (1) caller 53C9F
    def netif is no ap's netif, sending boardcast or no-subnet ip packets may failed
    sending broadcast_deauth:5
    Info:MAIN:Time 6, idle 181781/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Boot complete time reached (5 seconds)
    Info:CFG:####### Set Boot Complete #######
    temp_code:-26 - adc_code:346 - adc_trend:[2]:354->[3]:344
    Info:MAIN:Time 7, idle 175467/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 8, idle 185701/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 9, idle 185898/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 10, idle 184082/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=00:00:00:00:00:00
    Info:GEN:sta: 0, softap: 1, b/g/n
    Info:GEN:softap:ssid=OpenBK7231N_19FEEF53,channel=1,dhcp=1,cipher_type:OPEN
    Info:GEN:ip=192.168.4.1,gate=192.168.4.1,mask=255.255.255.0,dns=192.168.4.1
    Info:MAIN:Time 11, idle 365883/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 12, idle 185618/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 13, idle 195475/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 14, idle 185917/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 15, idle 177406/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 16, idle 184789/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 17, idle 185224/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 18, idle 191977/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 19, idle 185336/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 20, idle 191641/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=00:00:00:00:00:00
    Info:GEN:sta: 0, softap: 1, b/g/n
    Info:GEN:softap:ssid=OpenBK7231N_19FEEF53,channel=1,dhcp=1,cipher_type:OPEN
    Info:GEN:ip=192.168.4.1,gate=192.168.4.1,mask=255.255.255.0,dns=192.168.4.1
    Info:MAIN:Time 21, idle 181812/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 22, idle 182402/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    temp_code:-21 - adc_code:337 - adc_trend:[3]:344->[4]:334
    Info:MAIN:Time 23, idle 186872/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    temp_code:-24 - adc_code:343 - adc_trend:[4]:334->[3]:344
    Info:MAIN:Time 24, idle 188744/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 25, idle 183513/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 26, idle 183196/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 27, idle 193029/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 28, idle 183598/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 29, idle 184429/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 30, idle 185005/s, free 73000, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=00:00:00:00:00:00
    Info:GEN:sta: 0, softap: 1, b/g/n
    Info:GEN:softap:ssid=OpenBK7231N_19FEEF53,channel=1,dhcp=1,cipher_type:OPEN
    Info:GEN:ip=192.168.4.1,gate=192.168.4.1,mask=255.255.255.0,dns=192.168.4.1
    ▒▒▒▒▒▒▒7▒▒▒▒▒▒▒6▒▒▒󲳚▒▒v▒▒6▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒626▒▒▒▒▒▒62▒▒ ▒▒▒▒▒▒26▒▒▒▒▒▒▒▒▒&▒Ɠ2▒6▒22▒▒3▒▒▒S▒▒2▒▒▒▒▒▒▒▒2▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒L▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒
    @▒@D@▒  ▒@▒▒▒
    V:BK7231N_1.0.1
    REG:cpsr     spsr     r13      r14
    SVC:000000D3          00401C1C 000033AC
    IRQ:000000d2 00000010 00401e0c f3ccd9fe
    FIR:000000d1 00000010 00401ffc dd6fe7ef
    SYS:000000df          0040192c 00000158
    ST:00000000
    J 0x10000
    bk_misc_init_start_type 0 0
    prvHeapInit-start addr:0x4144d8, size:113448
    [Flash]id:0xeb6015
    sctrl_sta_ps_init
    cset:0 0 0 0
    Entering initLog()...
    Commands registered!
    initLog() done!
    Info:MAIN:Main_Init_Before_Delay
    Info:CFG:####### Boot Count 3 #######
    Warn:CFG:CFG_InitAndLoad: Correct config has been loaded with 1 changes count.
    Error:CMD:lfs is absent
    Info:GEN:PIN_SetupPins pins have been set up.
    Info:MAIN:Main_Init_Before_Delay done
    
    Main_Init_Before_Delay done
    Info:MAIN:Main_Init_Delay
    
    Main_Init_Delay
    
    delaying start
    bandgap_calm_in_efuse=0x70
    [load]bandgap_calm=0x70->0x30,vddig=4->5
    [FUNC]rwnxl_init
    [bk]tx_txdesc_fl#Startup delayed 0ms#
    u0ms#
    [FUNC]intc_init
    [FUNC]calibration_main
    gpio_level=1,txpwr_state=15
                               user define rfcali mode:1
    get rfcali_#Startup delayed 10ms#
    mayed 10ms#
    DPLL Unlock
    DPLL Unlock
    #Startup delayed 20ms#
    #Startup delayed 30ms#
    #Startup delayed 40ms#
    #Startup delayed 50ms#
    #Startup delayed 60ms#
    #Startup delayed 70ms#
    #Startup delayed 80ms#
    #Startup delayed 90ms#
    #Startup delayed 100ms#
    #Startup delayed 110ms#
    #Startup delayed 120ms#
    #Startup delayed 130ms#
    #Startup delayed 140ms#
    #Startup delayed 150ms#
    #Startup delayed 160ms#
    #Startup delayed 170ms#
    #Startup delayed 180ms#
    #Startup delayed 190ms#
    #Startup delayed 200ms#
    #Startup delayed 210ms#
    #Startup delayed 220ms#
    #Startup delayed 230ms#
    #Startup delayed 240ms#
    #Startup delayed 250ms#
    #Startup delayed 260ms#
    #Startup delayed 270ms#
    #Startup delayed 280ms#
    #Startup delayed 290ms#
    #Startup delayed 300ms#
    #Startup delayed 310ms#
    #Startup delayed 320ms#
    #Startup delayed 330ms#
    #Startup delayed 340ms#
    #Startup delayed 350ms#
    #Startup delayed 360ms#
    #Startup delayed 370ms#
    DPLL Unlock
    #Startup delayed 380ms#
    DPLL Unlock
    #Startup delayed 390ms#
    #Startup delayed 400ms#
    #Startup delayed 410ms#
    #Startup delayed 420ms#
    #Startup delayed 430ms#
    #Startup delayed 440ms#
    #Startup delayed 450ms#
    #Startup delayed 460ms#
    #Startup delayed 470ms#
    calibration_main over
                         flash txpwr table:0xf
    dif g and n20 ID in flash:4
    dif g and n40 ID in flash:4
    read txpwr tab from flash success
    temp in flash is:244
    xtal in flash is:70
    xtal_cali:70
    --init_xtal = 70
                    #Startup delayed 480ms#
    [FUNC]ps_init
    [FUNC]func_init_extended OVER!!!
    
    start_type:0
    Version:
    Initializing TCP/IP#Startup delayed 490ms# ms#
    
    app_init finished
    #Startup delayed 500ms#
    #Startup delayed 510ms#
    #Startup delayed 520ms#
    #Startup delayed 530ms#
    #Startup delayed 540ms#
    #Startup delayed 550ms#
    #Startup delayed 560ms#
    #Startup delayed 570ms#
    #Startup delayed 580ms#
    #Startup delayed 590ms#
    #Startup delayed 600ms#
    #Startup delayed 610ms#
    #Startup delayed 620ms#
    #Startup delayed 630ms#
    #Startup delayed 640ms#
    #Startup delayed 650ms#
    #Startup delayed 660ms#
    #Startup delayed 670ms#
    #Startup delayed 680ms#
    #Startup delayed 690ms#
    #Startup delayed 700ms#
    #Startup delayed 710ms#
    #Startup delayed 720ms#
    #Startup delayed 730ms#
    #Startup delayed 740ms#
    
    starting....
    Info:MAIN:Main_Init_Delay done
    
    Main_Init_Delay done
    Info:MAIN:Main_Init_After_Delay
    Info:MAIN:Using SSID []
    Info:MAIN:Using Pass []
    Info:MQTT:MQTT_RegisterCallback called for bT obk19FEEF53/ subT obk19FEEF53/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT bekens_n/ subT bekens_n/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/obk19FEEF53/ subT cmnd/obk19FEEF53/+
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/bekens_n/ subT cmnd/bekens_n/+
    Info:MQTT:MQTT_RegisterCallback called for bT obk19FEEF53/ subT obk19FEEF53/+/get
    Error:CMD:LFS_ReadFile: lfs is absent
    Info:CMD:CMD_StartScript: failed to get file autoexec.bat
    Info:MAIN:Main_Init_After_Delay done
    cal_bias!
    DPLL Unlock
    cal dpll!
    temperature_type=1
                      temp_code:-26 - adc_code:347 - adc_trend:[13]:244->[3]:344
    Info:MAIN:Time 1, idle 256618/s, free 80640, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 2, idle 187662/s, free 80640, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 3, idle 186803/s, free 80640, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 4, idle 185646/s, free 80640, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:Time 5, idle 186730/s, free 80640, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 2/38
    Info:MAIN:no flash configuration, use default
    Info:MAIN:set ip info: 192.168.4.1,255.255.255.0,192.168.4.1
    Info:MAIN:ssid:OpenBK7231N_19FEEF53  key: mode:0
    hostapd_main_exiting
    hostapd_exit_handler
    hostapd_exit_done
    Soft_AP_start
    [saap]MM_RESET_REQ
    [bk]tx_txdesc_flush
    [saap]ME_CONFIG_REQ
    [saap]ME_CHAN_CONFIG_REQ
    [saap]MM_START_REQ
    hapd_intf_add_vif,type:3, s:0, id:0
    apm start with vif:0
    me_set_ps_disable:840 0 0 1 0 0
    ------beacon_int_set:100 TU
    set_active param 0
                      [msg]APM_STOP_CFM
                                       update_ongoing_1_bcn_update
    vif_idx:0, ch_idx:0, bcmc_idx:1
    update_ongoing_1_bcn_update
    enter low level!
    mac 4c:a9:19:fe:ef:52
    leave low level!
    net_wlan_add_netif done!, vif_idx:0
    uap_ip_start
    
    configuring interface uap (with Static IP)WARN: TCPIP mutex is NOT locked (1) caller 53C9F
    def netif is no ap's netif, sending boardcast or no-subnet ip packets may failed
    sending broadcast_deauth:5
    Info:MAIN:Time 6, idle 179471/s, free 72920, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Boot complete time reached (5 seconds)
    Info:CFG:####### Set Boot Complete #######
    Info:MAIN:Time 7, idle 177353/s, free 72920, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 8, idle 185497/s, free 72920, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 9, idle 185077/s, free 72920, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 10, idle 182749/s, free 72920, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=00:00:00:00:00:00
    Info:GEN:sta: 0, softap: 1, b/g/n
    Info:GEN:softap:ssid=OpenBK7231N_19FEEF53,channel=1,dhcp=1,cipher_type:OPEN
    Info:GEN:ip=192.168.4.1,gate=192.168.4.1,mask=255.255.255.0,dns=192.168.4.1
    Info:MAIN:Time 11, idle 186912/s, free 72920, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 12, idle 185091/s, free 72920, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 13, idle 197729/s, free 72920, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 14, idle 183437/s, free 72920, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 15, idle 180451/s, free 72920, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 16, idle 184447/s, free 72920, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 17, idle 185794/s, free 72920, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 18, idle 185373/s, free 72920, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 19, idle 184294/s, free 72920, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:MAIN:Time 20, idle 185264/s, free 72920, MQTT 0(0), bWifi 0, secondsWithNoPing -1, socks 5/38
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=00:00:00:00:00:00
    Info:GEN:sta: 0, softap: 1, b/g/n
    Info:GEN:softap:ssid=OpenBK7231N_19FEEF53,channel=1,dhcp=1,cipher_type:OPEN
    Info:GEN:ip=192.168.4.1,gate=192.168.4.1,mask=255.255.255.0,dns=192.168.4.1
    


    Configuration:
    {
      "vendor": "Tuya",
      "bDetailed": "0",
      "name": "Full Device Name Here",
      "model": "enter short model name here",
      "chip": "BK7231N",
      "board": "TODO",
      "flags": "1152",
      "keywords": [
        "TODO",
        "TODO",
        "TODO"
      ],
      "pins": {
        "8": "dInput_NoPullUp;2",
        "14": "BAT_Relay;3",
        "23": "BAT_ADC;1",
        "24": "Btn;0",
        "26": "WifiLED;0"
      },
      "command": "",
      "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
      "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"
    }


    Autoexec.bat:
    // Powersave mode
    PowerSave 1
    // Battery config
    startdriver battery
    Battery_Setup 2200 3000 2.46
    
    // Measure battery every 2s
    Battery_cycle 2
    
    //DeepSleep (PinDeepSleep) wake configuration command. 0 means always wake up on rising edge, 1 
    //means on falling, 2 means if state is high, use falling edge, if low, use rising. Default is 2. Second 
    //argument is optional and allows to set per-pin DSEdge instead of setting it for all pins.
    DSEdge 0
    
    // Add event to make button hold launch safe mode
    addEventHandler OnHold 20 SafeMode
    setChannelLabel 2 Sensor
    
    // Define a function to check MQTT connection and sleep if not connected.
    //!!CONFIGURE MQTT BEFORE SAVING/RUNNING THIS SCRIPT!!
    start:
    // Check if MQTT is connected
    if $MQTTState==0 then "goto connected" else "goto notconnected"
    delay_s 1
    
    // If not connected, sleep for 5 minutes and retry. delay for 30s for maintenance window
    notconnected:
    delay_s 30
    PinDeepSleep 300
    goto start
    
    // Label for when MQTT is connected
    connected:
    
    // Extra delay, to be sure
    delay_s 1
    
    // Publish water state at least once after boot
    publishChannel 2
    
    // All good, sleep for 1 day or next sensor after 60s
    delay_s 60
    PinDeepSleep 86400


    Happy water detecting!!! :)
  • ADVERTISEMENT
  • #3 21438437
    groove6j
    Level 8  
    I also enable flags 2 and 10, otherwise the values seem not to update when the sensor wakes up after sleeping. I have the same sensor and it works perfect.
ADVERTISEMENT