logo elektroda
logo elektroda
X
logo elektroda

Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module

pincopallino1010 3786 27
ADVERTISEMENT
  • #1 20481396
    pincopallino1010
    Level 5  
    Hi! I recently purchased this product and I have successfully installed the openbeken software after seeing that they changed the module from TYWE3S to CB3S (BK7231N). But now I'm stuck on how to configure it because there is no template for it... Can anyone give me a hand? :)

    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module
  • ADVERTISEMENT
  • Helpful post
    #2 20481947
    p.kaczmarek2
    Moderator Smart Home
    Hello, it looks like a PIR sensor without TuyaMCU, altough you could confirm that by showing the other side of the PCB.

    In case of version without TuyaMCU, you'll have to use deep sleep feature of OpenBeken to preserve battery life, but we already got it working for door sensors and more:
    Door/window sensor without TuyaMCU - deep sleep and energy saving, OpenBeken
    [OpenBeken] SHT Sensor configuration, commands, and deep sleep usage with wake up on pin change
    but before invoking deep sleep, we need to know which GPIOs are used.

    Are you able to determine which GPIO is used for PIR sensor, which is used for button, for battery level, etc?

    @dheenhasty do you think your battery driver can run on that?

    Btw... huh, manufacturer says batteries will last for 6 hours only? I think with OBK they could last longer than that, of course.
    Helpful post? Buy me a coffee.
  • #3 20482135
    pincopallino1010
    Level 5  
    What is TuyaMCU? :O
    I am a little bit scared to reopen it cause the battery pack is soldered underneath the PCB.. but it seems that there is nothing underneath (i've tried to take a picture tho).
    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module
    Do I really need to use the deep sleep feature? Cause I was thinking of connecting it directly to my UPS via USB-C without any battery.
    Talking about the GPIO, I'm completely blind cause when I purchased it I was hoping to receive the ESP8266 model which have this GPIO..
    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module
    So I have no idea how to retrieve them for this model and I was hoping that someone can give me a hand 😐

    EDIT: These could be the pin definitions? https://developer.tuya.com/en/docs/iot/cb3s?id=Kai94mec0s076#title-5-Pin%20definition
    Here also says that
    Quote:
    CB3S is built in with a 32-bit MCU
  • Helpful post
    #4 20482213
    p.kaczmarek2
    Moderator Smart Home
    TuyaMCU is protocol used to communication between WiFi module and external MCU. Some Tuya devices are designed that way. It seems that your is without TuyaMCU.

    Hmm if you are going to power is constantly, then indeed Deep sleep is not required. I that case configuration would be very, very simple.

    You just need to find out which GPIO is used dinput sensor.

    So, the device was using TYWE3S in the past? Here is GPIO13:
    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module
    And here are CB3S GPIOs:
    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module
    Pin numberSymbolI/O typeFunction
    1RSTILow-level reset, high level active (the pin has been pulled high internally), correspond to CEN of the IC
    2ADC3AIADC pin, which corresponds to P23 of the IC
    3CENIEnabling pin, which is pulled high internally to be compatible with other modules
    4P14I/OA common GPIO interface, which corresponds to P14 of the IC
    5P26I/OGPIOP_26, which corresponds to P26 of the IC, PWM 5
    6P24I/OGPIOP_24, which corresponds to P24 of the IC, PWM 4
    7P6I/OGPIOP_6, which corresponds to P6 of the IC, PWM 0
    8VCCPPower supply pin (3.3V)
    9GNDPPower supply reference ground
    10P9I/OGPIOP_9, which corresponds to P9 of the IC, PWM 3
    11TXD2I/OUART2_TXD (used to display the module internal information), which corresponds to P0 of the IC
    12CSNI/OProduction test control pin. If it is used as a common I/O pin, it must be connected to the VCC externally. Do not connect it to the ground before the module is powered on.
    13P8I/OGPIOP_8, which corresponds to P8 of the IC, PWM 2
    14P7I/OGPIOP_7, which corresponds to P7 of the IC, PWM 1
    15RXD1I/OUART1_RXD (user serial interface), which corresponds to P10 of the IC. Do not connect it to the VCC. By default, the MCU serial port should be in low-level or high-impedance state.
    16TXD1I/OUART1_TXD (user serial interface), which corresponds to P11 of the IC. Do not connect it to the VCC. By default, the MCU serial port should be in low-level or high-impedance state.
    17ADC3AI(Not recommended. If needed, please use Pin 2) ADC port, which corresponds to P23 of the IC. Programmed SPI
    18P22I/O(Not recommended ) GPIOP_22, which corresponds to P22 of the IC. Programmed SPI
    19CSNI/OThe pull-up resistor is needed during usage of customers. Do not connect it to the ground before the module is powered on. Correspond to P21 of the IC.
    20P20I/O(Not recommended. ) GPIOP_20, which corresponds to P20 of the IC. Programmed SPI


    I think we can already see which one is GPIO13 equivalent in CB3S. OpenBeken is using P* indexes.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 20482262
    pincopallino1010
    Level 5  
    Ok so if I understand correctly the GPIO13 on the TYWE3S is responsible for taking input from the PIR sensor.
    On the CB3S it corresponds to the pin number 10, so I have to set the P9 pin like this?
    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module

    EDIT: I notice that it remains always on 1 even if I wave my hand on it
    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module
    I have also noticed that if I set this pin
    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module
    The speaker turns on and I see this
    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module
  • #6 20482293
    p.kaczmarek2
    Moderator Smart Home
    It seems that TYWE3S has shown a bottom view while the CB3S has a top view. Your GPIO13 would have CB3S index 7 then, which is P6.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #7 20482307
    pincopallino1010
    Level 5  
    Yay! It worked :)
    So now how can I access that value (I mean the 1 / 0 when the PIR is triggered).
    Cause I wanted to turn on / off a switch based on this value via python script.

    EDIT: And also, what is the difference between these values?
    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module
  • Helpful post
    #8 20482352
    p.kaczmarek2
    Moderator Smart Home
    Hello, if you look into our auto-generated docs:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/README.md
    the IO Pin Roles, to be exact:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/ioRoles.md
    You can find out that:
    DigitalInputthis is a simple digital input pin, it sets the linked channel to current logical value on it, just like digitalRead( ) from Arduino. This input has a internal pull up resistor.
    DigitalInput_nAs DigitalInput as above, but inverted
    ToggleChannelOnTogglethis pin will toggle target channel when a value on this pin changes (with debouncing). you can connect simple two position switch here and swapping the switch will toggle target channel relay on or off
    DigitalInput_NoPupAs DigitalInput, but without internal programmable pullup resistor. This is used for, for example, XR809 water sensor and door sensor.
    DigitalInput_NoPup_nAs DigitalInput_n, but without internal programmable pullup resistor


    The device will do a MQTT publish when a channel value changes, for example:
    
    OBK_DEV_NAME/2/get
    

    with payload equal to channel value.

    You can also use autoexec.bat to create event handlers and custom publishes, for example:
    
    addEventHandler OnChannelChange 1 publishInt mySensorState $CH1
    

    or
    
    addChangeHandler Channel1 == 1 publish myDoor nowClosed
    addChangeHandler Channel1 == 0 publish myDoor nowOpen
    

    You can do much more with scripts, for example, you could send a HTTP GET request to a target HTTP server when a channel value is changed.
    Helpful post? Buy me a coffee.
  • #9 20482373
    pincopallino1010
    Level 5  
    Quote:
    Send a HTTP GET request to a target HTTP server when a channel value is changed.

    Exactly! My idea is to send an HTTP GET request to a Tasmota switch in order to turn it on. How can I achieve this on OpenBeken? :)

    EDIT: Or in a more controlled way (since if the Sonoff will turn on it will turn on the siren) how can I send it to a Debian system in order to manage it via script?
  • #10 20482449
    p.kaczmarek2
    Moderator Smart Home
    If you look into our console commands examples section here:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commandExamples.md
    you can find:
    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #11 20482542
    pincopallino1010
    Level 5  
    OMG thanks a lot! You helped me make a little dream come true :)
  • #12 20482562
    p.kaczmarek2
    Moderator Smart Home
    Btw, please post full final device config from Web App and your scripts as well if you can, so I can add this topic to the supported devices list.

    Also, if you still have it, post some screenshots where device was bought and how the packaging looks like (model number? app name? etc)

    Thanks!
    Helpful post? Buy me a coffee.
  • #13 20482598
    pincopallino1010
    Level 5  
    Quote:
    Btw, please post full final device config from Web App and your scripts as well if you can, so I can add this topic to the supported devices list.

    This is my template (I have only changed the pin)
    
    {
      "vendor": "Tuya",
      "bDetailed": "0",
      "name": "Full Device Name Here",
      "model": "enter short model name here",
      "chip": "BK7231N",
      "board": "TODO",
      "keywords": [
        "TODO",
        "TODO",
        "TODO"
      ],
      "pins": {
        "6": "dInput;1"
      },
      "image": "https://obrazki.elektroda.pl/YOUR_IMAGE.jpg",
      "wiki": "https://www.elektroda.com/rtvforum/topic_YOUR_TOPIC.html"
    }
    


    Quote:
    Also, if you still have it, post some screenshots where the device was bought and how the packaging looks like (model number? app name? etc)

    I have bought it from here (Aliexpress)

    And this is the package
    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module
  • #14 20482701
    p.kaczmarek2
    Moderator Smart Home
    What about those two pin roles from old Tasmota template?
    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module
    Let's try to support them somehow.

    For example, if you set LED channel to the same channel that dInput has, then LED will reflect dInput state.
    Helpful post? Buy me a coffee.
  • #15 20494884
    pincopallino1010
    Level 5  
    I've tried to set the LED channel to the same channel that dinput has, but it seems not doing what we expect :O
  • #17 20496068
    pincopallino1010
    Level 5  
    Literally nothing 🤔
  • #18 20496101
    p.kaczmarek2
    Moderator Smart Home
    Are you sure? It seems.... impossible.
    If you have a dInput set for a given channel, then this dInput will sample logical value on its pin every frame and force-set the channel to 1 (if high) or to 0 (if low).
    Then, if you have a LED on the same channel, the LED will follow the value from the channel. You can also use LED_n for inverted following.

    Maybe... maybe do a little test - set that LED pin channel to something like Channel 5, and then try toggling channel 5 value and see if it blinks on the device. Via web GUI or commands - "toggleChannel 5". The LED should blink. If it's not blinking, then you've selected wrong GPIO.
    Helpful post? Buy me a coffee.
  • #19 20578998
    p.kaczmarek2
    Moderator Smart Home
    I've just got one PIR sensor. Here's dInput + LED result on the same channel, of course on correct GPIO:



    It reacts to movement. Channel switch to 1 for the time movement is there and later, with some delays, returns to 0.
    Helpful post? Buy me a coffee.
  • #20 20641229
    mkmunichmk
    Level 7  

    @p.kaczmarek2, I have the same Tuya PIR device. Is there a template available for it? BR, MK
  • #21 20641851
    p.kaczmarek2
    Moderator Smart Home

    I haven't finished the teardown article about it yet, but here is the JSON:
    Code: JSON
    Log in, to see the code

    Here is text description:
    
    Device configuration, as extracted from Tuya: 
    - Button (channel 0) on P20
    - Status LED on P26
    - PIR sensor on P16
    - Battery Relay on P17
    - Battery Max Voltage: 3000
    - Battery Min Voltage: 2200
    - 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
    

    This is not a final config, it will require some little work to finish it.
    Helpful post? Buy me a coffee.
  • #22 20658473
    pincopallino1010
    Level 5  

    Hi, sorry I haven't replied to you more, but I've been busy these months :/

    I saw that you carried on the work, great! I wonder, is there any way to control the sensitivity of the sensor in such a way to have a wider/narrower range of the sensor range?

    Also, I tried out this configuration, but importing it resets my whole device without setting any pins. Am I doing something wrong?
  • #23 20658569
    p.kaczmarek2
    Moderator Smart Home
    This sensor only provides us a binary signal, telling whether there was something detected or now, therefore it's not possibly to tune it at the WiFi module side.

    PIR sensor configuration automatic import may not be ready yet, you need to enter it manually. Use it to extend what you've already got.

    You will also need to get Deep Sleep running on this device. This is required to preserve battery life. Have you looked into the Deep Sleep mechanism of OpenBeken? We have some threads covering this topic, for example, here:
    https://www.elektroda.com/rtvforum/topic3960149.html
    Helpful post? Buy me a coffee.
  • #24 20658761
    pincopallino1010
    Level 5  

    Um, I see. In which of the two spaces should I enter the configuration?

    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module

    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module

    Regarding deep sleep, since I connected the sensor directly by cable to an UPS I shouldn't need it, right?
  • #25 20658778
    p.kaczmarek2
    Moderator Smart Home
    Hmm ok, you don't need deep sleep if you power device from cables.

    Configuration should be pasted in the first field, but as I said, the PIR data may need to be entered manually, not via importer.
    Helpful post? Buy me a coffee.
  • #26 20658808
    pincopallino1010
    Level 5  

    So I copied and pasted it here and it says this, does that mean it's okay?
    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module

    About the PIR data that may need to be entered manually, do you mean these?

    Configuring Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with CB3S (BK7231N) Module
  • #27 20661910
    p.kaczmarek2
    Moderator Smart Home

    The following screenshot shows that no config was imported from that JSON. It seems that we have to update our importer to cover PIR data. As I said, PIR most likely will have to be done manually, for now... . I will try to look into that in the following days.
    Helpful post? Buy me a coffee.
  • #28 20947461
    pincopallino1010
    Level 5  

    Thank you very much for all the support, I apologize for not being able to respond in time :(

    Unfortunately, the device stopped working suddenly (probably due to some soldering gone wrong) and I bought some sensors that are more suitable for my case... in fact, I asked here if, after flashing them with the new firmware, I need to tweak some other things.

Topic summary

The discussion revolves around configuring the Tuya/SmartLife Alarm PIR Motion Sensor (CT61W) with the CB3S (BK7231N) module after the user successfully installed OpenBeken software. Initial confusion arose regarding the absence of a template for the new module, particularly concerning GPIO pin assignments and the necessity of deep sleep for battery conservation. Participants clarified that the device lacks TuyaMCU, simplifying the configuration if powered continuously. The user identified GPIO mappings and sought assistance in sending HTTP requests to control a Tasmota switch based on PIR sensor triggers. The conversation included troubleshooting GPIO settings, configuring LED indicators, and the limitations of the PIR sensor's binary output. Ultimately, the user shared their configuration template and expressed gratitude for the community's support, despite experiencing hardware failure later on.
Summary generated by the language model.
ADVERTISEMENT