Elektroda.com
Elektroda.com
X

[BK7231N / CB3S] AliExpress Generic PIR Sensor HW4008-W: Setup, Template, Features & Details

ThatGuyinOz 1101 5
  • Purchased:from this link:
    https://www.aliexpress.com/item/4000785415902.html?spm=a2g0o.order_detail.order_detail_item.3.28fcf19cv5xMHt
    Cost:
    ~$AUD16

    [BK7231N / CB3S] AliExpress Generic PIR Sensor HW4008-W: Setup, Template, Features & Details
    [BK7231N / CB3S] AliExpress Generic PIR Sensor HW4008-W: Setup, Template, Features & Details
    [BK7231N / CB3S] AliExpress Generic PIR Sensor HW4008-W: Setup, Template, Features & Details [BK7231N / CB3S] AliExpress Generic PIR Sensor HW4008-W: Setup, Template, Features & Details

    [BK7231N / CB3S] AliExpress Generic PIR Sensor HW4008-W: Setup, Template, Features & Details
    (USB TTL converter to show scale)


    Inputs:
    1 x hidden switch marked "reset"
    Power:
    External micro USB connector
    Internal 2 x AAA batteries

    Template:

    Code: json
    Log in, to see the code


    The board has a model number HW4008-W printed on it
    The "reset" switch is actually just attached to P7, it is not a hardware reset.
    Both inputs activate on pull to Gnd.

    Flashing:
    I used the BK7231Flasher Easy UART flasher after soldering RX/TX/3.3/Gnd wires.
    I used an external PSU for 3.3v ( node MCU board powered from PC USB)
    I had to set the UART speed to 115200 to avoid transfer failures

    Flags :
    I set Flag 10 - [MQTT] Broadcast self state on MQTT connect = On
    I set Flag 37 - [WiFi] Quick connect to WiFi on reboot (TODO: check if it works for you and report on github) = On

    Other Settings:
    I have set both inputs to be "Door Sensor With Sleep" (DoorSnsrWSleep, with pullup)
    I set startup value for 1 = 50. this makes the led illuminate dimly to show motion detection, with a small power saving.
    I set startup value for 2 = 1. This seemed to be required to help door sensor driver.
    After testing I set Startup Command text to "DSTime 10" to force shutdown for power saving reasons. (default is 60 sec)

    Operation:
    At motion detection I see first MQTT packet after 5-6 sec. unit goes to sleep about 5 sec later.

    I would like to set a static IP address and see if that makes the initial connection faster but i cannot find the Command or setting anywhere.
    [edit] I found the very obvious button on the main Config page... I'll update if it makes the first MQTT packet faster shortly.

    Cool? Ranking DIY
    About Author
    ThatGuyinOz
    Level 1  
    Offline 
    ThatGuyinOz wrote 1 posts with rating 2. Been with us since 2023 year.
  • #2
    p.kaczmarek2
    Moderator Smart Home
    Yes, both Quick Connect flag and static IP can increase the connection time to MQTT server. It should be about 5 seconds or maybe even less. We're constantly improving it.
  • #3
    ionoleinic
    Level 10  
    I have the same device, but for me this configuration isn't working...
    I dont understand, why p26 should be pwm?? i think it should be wifi_led.
    Why 2 DoorSnsrWSleep? (P7 abd P8)
    I tried this:
    P7 - Btn 1
    P8 - dInput (Pir)
    P26 - WifiLed_n
    P24 - Rel 1
    Also dont working... What type of input i should put on P8?
  • #4
    p.kaczmarek2
    Moderator Smart Home
    This device is battery powered and it's not TuyaMCU, which means we need to utilize deep sleep in order to preserve battery life. Otherwise batteries would drain in a matter of days.

    Using doorsensorwithdeepsleep driver is a good way to do that easily. Door sensor driver was designed for door sensor, but suprisingly, it also works good enough for PIR sensors.

    The users seems to have set two door sensor pins, one for PIR, and second for button. I do not recommend that. Please just use door sensor pin role for PIR pin. Then just set Button role for button. That button will still wake device from deep sleep. No worries there.

    Configure DSEdge setting if device does not want to wake up in one state.

    If you are unsure about your GPIO, please get Tuya Config partition from our Web App and post it here.

    I don't know the role of P26, but maybe users intention was to dim LED with PWM, which is of course possible, but not necessary.
  • #5
    ionoleinic
    Level 10  
    DoorSensor Driver only boot up wifi module? It does not change rel state?
    P26 is a Led.

    Code: json
    Log in, to see the code


    Added after 17 [minutes]:

    The rel output is not changing.
    The logs:
    [BK7231N / CB3S] AliExpress Generic PIR Sensor HW4008-W: Setup, Template, Features & Details

    the main page:
    [BK7231N / CB3S] AliExpress Generic PIR Sensor HW4008-W: Setup, Template, Features & Details

    Pin config:
    [BK7231N / CB3S] AliExpress Generic PIR Sensor HW4008-W: Setup, Template, Features & Details
  • #6
    auntlydia
    Level 8  
    Hi, from the photos above I believe I have the same device. It comes with battery state too. For me these settings have worked:

    - motion pin: p8 (dInput_n or DoorSnsrWSleep and Flag 42) (Channel 1)
    - button pin: p7 (btn) (Channel 1)
    - LED pin: p26 (LED_n or WiFiLED, whatever suits your need) (Channel 1)
    - Battery pin: p23 (Bat_ADC) (Channel 2)

    Once the device was successfully set up, I disabled the LED to make the device's appearance in my home more subtle and also save some power. For me it works best when used with constant 5V power supply via the MicroUSB port (instead of batteries), as we don't need DeepSleep state here and we have instant motion triggering, which is a lot more convenient for daily usage. I used the 230V wiring of my ceiling light and installed it right next to it with a ac-->dc stepdown converter.
    [BK7231N / CB3S] AliExpress Generic PIR Sensor HW4008-W: Setup, Template, Features & Details

    Also, here I attach the Tuya GPIO Config, in case anyone needs it.