logo elektroda
logo elektroda
X
logo elektroda

[Solved] Door sensor PB-69W issues - wake up / two door contacts / battery monitoring

JardaLCZ 1143 9
ADVERTISEMENT
  • #1 20870367
    JardaLCZ
    Level 5  

    I have an issue with one older sensor with a magnetic reel switch, PB-69W. The template:
    {
    "vendor": "Tuya",
    "bDetailed": "0",
    "name": "Full Device Name Here",
    "model": "Enter Short Model Name Here",
    "chip": "BK7231N",
    "board": "TODO",
    "flags": "0",
    "keywords": [
    "TODO",
    "TODO",
    "TODO"
    ],
    "pins": {
    "7": "DoorSnsrWSleep_nPup;1",
    "9": "WifiLED;5",
    "24": "DoorSnsrWSleep_nPup;2"
    },
    "command": "",
    ...........
    }

    I use two GPIOs (7 - channel 1 for reed switch), (24 - channel 2 for tamper button).
    It works well, goes from sleep to wake up on change and sleeps after timeout (60 sec, but I tried also 30 sec)

    There is an issue that the sensor does not wake up after cca 6-10 hours without change. I have to remove batteries and put them back. Then it works for half a day.

    Build: Created on Dec 17, 2023, at 22:12:49, version 1.17.366
    MAC Address: fc:67:1f:07:ce:d0
    Chipset: BK7231N
    Flags: 0
    Version: 1.17.366

    I also attempted to identify GPIOs for battery monitoring, which did function, but I encountered some issues as detailed here: https://www.elektroda.com/rtvforum/topic3959103.html. My setup was as follows:
    Pin Description Config Channel
    6 reset button dInput_n 3
    7 reel contact DoorSnsrWSleep_nPup 1
    9 WiFi LED WifiLED 5
    21 BAT_ADC battery level 4
    24 tamper contact DoorSnsrWSleep_nPup 2

    Upon realizing the wake-up problem, I disabled the battery driver. I now understand that battery monitoring is a separate issue.

    Thank you for your help. It is not extremely important to solve it, maybe I will throw out this one sensor but I am interested to have one sensor with two door contacts and deep sleep (tamper + reel).
  • ADVERTISEMENT
  • #2 20871461
    p.kaczmarek2
    Moderator Smart Home
    So, to sum up, your sensor wakes up if you "open the door" after 15 minutes, but fails to wake up after 6 or so hours?

    What is the voltage on the battery?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 20872072
    JardaLCZ
    Level 5  

    Update below but I struck through my tests and bad assumption.
    Yes, you are right. If I "open" after longer time (after night), the sensor does not wake up. I tried fresh batteries (3.12 V) and also older batteries (2.5 - 3.0 V) and NiMH 2.2 - 2.6 V. The same results.

    But in the meantime I did a factory reset and RF recovery and tried to set up different GPIO configs without battery monitoring (which is maybe not supported on this device)

    Currently:

    "pins": {
    "6": "DoorSnsrWSleep_nPup;3",
    "7": "dInput_NoPullUp;1",
    "9": "WifiLED;5",
    "24": "dInput_NoPullUp;2"
    },

    This config seems to be better. I am surprised that the sensor wakes up even when I give the pulse on the pin 7 or 24, even if they are not set up as a DoorSnsr*.
    I will write more after night, now it wakes up on all events (pins 6, 7, 24) immediately. I am still learning with BK7231N. I expected that I can wake up the chip only on DoorSnsr* pins.

    IMPORTANT UPDATE:
    I found this behavior or dependence:

    Config is:
    "6": "DoorSnsrWSleep_nPup;3", - Reset button, normally High
    "7": "dInput_NoPullUp;1", - Reel contact, open window = Low
    "24": "dInput_NoPullUp;2" - Tamper button (I use it as a ventilation sensor) open = High

    or this:
    "6": "DoorSnsrWSleep_nPup;3",
    "7": "DoorSnsrWSleep_nPup;1",
    "24": "DoorSnsrWSleep_nPup;2"

    When the sensor goes to sleep with these inputs, it does not wake up on the next change on this specific input:
    6 = reset button Low (pressed)
    7 = reel contact High (window closed)
    24 = tamper contact Low (ventilation closed)

    In other words, the sensor wakes up on a change in input if the input was in this state during going to sleep:
    6 = reset button High (unpressed)
    7 = reel contact Low (window open)
    24 = tamper contact Low (ventilation open).

    If you have documentation or a description of how it works, it can help me. Thanks.
  • ADVERTISEMENT
  • Helpful post
    #4 20872182
    p.kaczmarek2
    Moderator Smart Home
    This is a known issue. The solution is to use DSEdge command to adjust the wake up edge of the GPIO. This is because there are various types of sensors so you need to adjust the settings for your one:
    https://www.elektroda.com/rtvforum/find.php?q=DSEdge
    There are 3 possible DSEdge options, you need to check the other two, except the default one.
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    Make sure that you also set your Button role to a Button, so you can always do an emergency wakeup for the device.
    Helpful post? Buy me a coffee.
  • #5 20872656
    JardaLCZ
    Level 5  
    Thanks for the links, the interesting tips, and the explanation of the DSEdge command. I changed the configuration, and it works now with real contact well. Battery status is okay. The tamper contact wakes up only when it is high when the sensor goes to sleep. It is a minor problem to me now, but advice is welcomed.

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


    Autoexec.bat
    DSTime 30
    DSEdge 0
    addEventHandler OnHold 6 DSTime 600
    Battery_Setup 1800 3000 1.97 2400 4096
  • Helpful post
    #6 20874430
    p.kaczmarek2
    Moderator Smart Home
    Maybe it needs a different DSEdge setting?

    If so, it seems we need to support per-pin DSEdge?
    Helpful post? Buy me a coffee.
  • #7 20875026
    JardaLCZ
    Level 5  

    Yes, DSEdge per pin should help.

    DSEdge 0 is okay for the reel contact (pin 7).
    DSEdge 1 is for the tamper (ventilation) contact (pin 24).

    Note: DSEdge 2 does not fit for either pin 7 or 24 in my application. Only the Reset button (pin 6) wakes up, but it changes DSTime in autoexec.bat, which is okay.
  • ADVERTISEMENT
  • Helpful post
    #8 20875049
    p.kaczmarek2
    Moderator Smart Home
    Wait, I've forget! We already have it.
    You can do:
    
    DSEdge [Edge] [PinIndex] 
    

    And this will work.
    Alternatively, to force-set all DSEdge you do:
    
    DSEdge [Edge]
    

    If you don't specify pin, it sets for all pins.
    Helpful post? Buy me a coffee.
  • Helpful post
    #9 20875105
    JardaLCZ
    Level 5  

    WOW! GREAT! It works perfectly now! Thank you. All issues are solved now. There is a description of my use for others.

    Summary: I am able to monitor two inputs. Open window (reel contact) and open ventilation (tamper contact). The sensor wakes up on every change. If I hold the "reset" button during start, the DSTime (time to go sleep) is increased to 600 seconds. I use it for debugging or testing.

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


    Updated autoexec.bat
    
    DSTime 30
    DSEdge 0 7
    DSEdge 1 24
    addEventHandler OnHold 6 DSTime 600
    Battery_Setup 1800 3000 1.97 2400 4096
    


    The sensor and the installation. It has to be near the bottom of the window. You have to find the right position of the magnet. The reel has to be closed when the ventilation is opened.
    Image of an electronic module held in a hand. Close-up of an open battery holder with two AA batteries inside.
    Sensor mounted on the interior window frame.

    The window opened - the reel contact and the tamper contact are opened:
    White sensors mounted on a window, one on the sash, the other on the frame.
    Sensor mounted on window frame.

    The ventilation only opened - the tamper contact opened
    Sensor mounted on the frame of an open window.
  • #10 20875109
    JardaLCZ
    Level 5  

    The problem is solved. See the previous post where my application of the sensor PB-69W (PB69W) is.

Topic summary

The discussion revolves around issues with the PB-69W door sensor, specifically its failure to wake up after prolonged periods of inactivity (6-10 hours). The user initially experienced problems with the sensor not waking up after a set timeout, requiring battery removal to reset. Various battery voltages were tested, but the issue persisted. After a factory reset and reconfiguration of GPIO settings, the user found improved performance, with the sensor waking up on multiple pin events. The DSEdge command was identified as a solution to adjust wake-up settings for different GPIOs, leading to successful monitoring of both door and tamper contacts. The final configuration allowed the sensor to wake up on any change, with an extended sleep timeout for debugging purposes.
Summary generated by the language model.
ADVERTISEMENT