logo elektroda
logo elektroda
X
logo elektroda

Deep sleep Problem with Tuya WiFi Door Sensor BK7231N / 2xAAA Battery

cerbero85 714 3
ADVERTISEMENT
  • #1 21394994
    cerbero85
    Level 3  
    Hello,
    I bought a Tuya Wifi Door sensor powered by 2xAAA batteries.


    Circuit board of an electronic device.


    Output of BF7231 Flasher:
    {
       "bt_pin":"20",
       "status_led_pin":"26",
       "rstcnt":"3",
       "basic_pin_pin":"24",
       "module":"CBU",
       "jv":"1.0.4",
       "bt_lv":"0",
       "net_t":"180",
       "samp_type":"1",
       "basic_st":"1",
       "basic_pin_lv":"0",
       "samp_sw_pin":"17",
       "max_V":"3000",
       "min_V":"2000",
       "samp_sw_lv":"1",
       "status_led_lv":"1",
       "samp_pin":"23",
       "crc":"53"
    }


    Device configuration, as extracted from Tuya: 
    - Button (channel 0) on P20
    - Status LED on P26
    - PIR sensor on P24
    - Battery Relay on P17
    - Battery Max Voltage: 3000
    - Battery Min Voltage: 2000
    - Battery ADC on P23
    Device seems to use Battery Driver. See more details here: https://www.elektroda.com/rtvforum/topic3959103.html
    Device seems to be using CBU module, which is using BK7231N.
    And the Tuya section starts, as usual, at 2023424
    



    I did some tests and this setup works:

    {
      "vendor": "Tuya",
      "bDetailed": "0",
      "name": "Tuya Door",
      "model": "DR_01_Sensor",
      "chip": "BK7231N",
      "board": "CB3S",
      "flags": "0",
      "keywords": [
        "door",
        "sensor",
        "battery",
       "Tuya"
      ],
      "pins": {
        "17": "BAT_Relay;1",
       "20": "Btn;0",
        "23": "BAT_ADC;1",   
       "24": "DoorSnsrWSleep;0",
        "26": "WifiLED_n;0"
      },
      "command": "backlog PowerSave 1; startDriver battery; startDriver DoorSensor; dstime 60",
      "image": "https://obrazki.elektroda.pl/7057404500_1705011297.jpg",
      "wiki": "https://www.elektroda.com/rtvforum/viewtopic.php?p=20904497"
    }



    But I have a problem with the wake up from deep sleep mode:
    - when the sensor goes into deep sleep from closed (door closed), when the door is opened the device wakes up
    - when the sensor goes into deep sleep from open (door open), closing or reopening the door the device doesn't wake up (I need to remove a battery for restore it)


    Can anyone help me to wake the device from deep sleep mode when the sensor is open?
    Thanks.
  • ADVERTISEMENT
  • #2 21397934
    cerbero85
    Level 3  
    I read this post: https://www.elektroda.com/rtvforum/topic4023117.html#20875049
    and I understood that the DSEdge command is missing to adjust the wake up edge of the GPIO.

    New config:
    {
      "vendor": "Tuya",
      "bDetailed": "0",
      "name": "Tuya Door",
      "model": "DR_01_Sensor",
      "chip": "BK7231N",
      "board": "CB3S",
      "flags": "0",
      "keywords": [
        "door",
        "sensor",
        "battery",
       "Tuya"
      ],
      "pins": {
        "17": "BAT_Relay;1",
       "20": "Btn;0",
        "23": "BAT_ADC;1",   
       "24": "DoorSnsrWSleep_nPup;0",
        "26": "WifiLED_n;0"
      },
      "command": "backlog PowerSave 1; startDriver battery; startDriver DoorSensor; dstime 60; DSEdge 1",
      "image": "https://obrazki.elektroda.pl/7057404500_1705011297.jpg",
      "wiki": "https://www.elektroda.com/rtvforum/viewtopic.php?p=20904497"
    }
    
  • ADVERTISEMENT
  • #3 21399008
    p.kaczmarek2
    Moderator Smart Home
    Yes, it's DSEdge setting. I wanted to post a reply but I see you resolved it quicker. So, is now everything working good?
    Helpful post? Buy me a coffee.
  • #4 21399189
    cerbero85
    Level 3  
    Thanks p.kaczmarek2.

    Now the deep sleep works fine.

    But I have a double. I calculated the time from wake up (from deep sleep) and from the first received message (mqtt "get" msg) and it is 10 seconds.
    If the door is opened and closed quickly (< 10 seconds) the device doesn't send the sensor changes but sends only the last sensor status after the mqtt connection.

    @p.kaczmarek2 is possible to keep the door sensor status changes that happens in the first 10 seconds and send it when the mqtt connection is established?
ADVERTISEMENT