logo elektroda
logo elektroda
X
logo elektroda

[BK7231N - CBU] Tuya Night Light with WiFi: Pin Configuration, PWM, dInput, ADC, PIR Sensitivity

Andy41 2415 6
ADVERTISEMENT
  • Tuya night light with WIFI

    [BK7231N - CBU] Tuya Night Light with WiFi: Pin Configuration, PWM, dInput, ADC, PIR Sensitivity

    Source: https://de.aliexpress.com/item/1005004997029225.html

    The night light is made by Tuya-module CBU.

    All needed pin are accessable. You can flash it without dismount the module
    [BK7231N - CBU] Tuya Night Light with WiFi: Pin Configuration, PWM, dInput, ADC, PIR Sensitivity [BK7231N - CBU] Tuya Night Light with WiFi: Pin Configuration, PWM, dInput, ADC, PIR Sensitivity

    Pin definition for the module as cbu.txt

    These pins are used:
    P26 - PWM1 - red
    P24 - PWM2 - green
    P6 - PWM3 - blue
    P8 - PWM4 - cool white
    P7 - PWM5 - warmwhite
    P14 - dInput - PIR-signal
    P20 - dInput_n - button
    P23 - ADC - brightness (0 = bright; 4096 = dark)
    P9 - PWM - sensitivity of PIR, 0-max, 255-min

    I do not use HA but IP-Symcon. That is why I can not say something to HA-integration.

    Some inner pictures:
    [BK7231N - CBU] Tuya Night Light with WiFi: Pin Configuration, PWM, dInput, ADC, PIR Sensitivity [BK7231N - CBU] Tuya Night Light with WiFi: Pin Configuration, PWM, dInput, ADC, PIR Sensitivity [BK7231N - CBU] Tuya Night Light with WiFi: Pin Configuration, PWM, dInput, ADC, PIR Sensitivity

    I use the device as a simple status signal. In my case for the count of open windows in the case of exit the apartment.

    pins explained:
    P26; P24; P6; P8; P7
    standard PWM output for R,G,B,CW,WW

    P20
    buttom at the right side of the device
    negated

    P23
    analog brightness signal
    0 - sun light
    200-400 approx. room light in the evening
    4096 - no lights

    P14
    PIR signal with approx. 5sec switch-off delay

    P9
    output corresponds with pin SENS of the PIR-module BS-612
    there is a small capacitor between signal and ground (no value known).
    0 Volt - highest sensitivity
    3 Volt - low sensitivity
    I do not know if you can output this as PWM or you have to set it as a standard digital output.

    Other signal pin were not found.

    Cool? Ranking DIY
    About Author
    Andy41
    Level 3  
    Offline 
    Andy41 wrote 7 posts with rating 1, helped 1 times. Been with us since 2023 year.
  • ADVERTISEMENT
  • #2 20605020
    p.kaczmarek2
    Moderator Smart Home
    Thank you for a very detailed review. I wasn't aware about the PIR setting.
    Can you provide us two more things for analysis?
    First, a Tuya Config partition file, extracted like on the tutorial:
    https://www.youtube.com/watch?v=WunlqIMAdgw&ab_channel=Elektrodacom
    And second, template in JSON form, from Web App in OBK. Thanks!
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 20605792
    Andy41
    Level 3  
    Hi,

    now, I have made some changes.
    - translated to english

    - added some more necessary files

    - PWM-pins changed from 0-4 to 1-5

    - pins explained

    - Tuya-config added
    here are only the PWMs 1-5 found. Why?
    the other pins were found with tests.
    Pin9 was found by look at the pcb.

    The extract of the cfg was not so easy, because I use only archlinux and no Windows.

    Thanks
    Andreas
  • ADVERTISEMENT
  • #4 20605949
    p.kaczmarek2
    Moderator Smart Home
    The Pin9 is present in the JSON, it was just not converted to text (not listed on human-readable interpretation)
    
    	"pirin_pin":"14",
    	"pirsense_pin":"9",
    

    This is because I haven't seen that kind of JSON before. It's the first time I get TuyaConfig from a such device. This is why your contribution is very helpful and informative. I learned some new things here, thank you!

    You can do some experiments with that PIR PWM control. Set GPIO role to PWM, set some channel for that (one that is not used by other pins) and use SetChannel <index> <value> to set PWM value.

    Regarding archilinux - it may be possible to run that program with Wine or compile it with Mono, but I don't know much about it. If anyone reading has some Mono experience, feel free to contribute.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 20605964
    Andy41
    Level 3  
    Hi,

    thank you for your answer.
    Pin 9 is found - Ok.

    But can you give me the information, how "tuya" this pin uses.
    PWM or 0/1 ?

    Andreas
  • #6 20605976
    p.kaczmarek2
    Moderator Smart Home
    I have no idea how is this pin used. This is totally new to me. As I said, your device is a new thing for me and I will later improve my flasher to extract GPIO specified in your Tuya partition.

    You will have to check yourself if it's a PWM or digital pin. Is only capacitor there?

    You can check either via OBK and adjust PWM value from console or you can try probing Tuya product with Tuya firmware with a simple scope to see if it's a PWM.
    Helpful post? Buy me a coffee.

Topic summary

The discussion centers on a Tuya night light module (CBU) with WiFi, focusing on its pin configuration and functionality. The module exposes accessible pins allowing flashing without disassembly. Key pins include PWM outputs for RGB and white LEDs (P26, P24, P6, P8, P7), digital inputs for PIR sensor signal (P14) and button (P20), an ADC input for brightness sensing (P23), and a PWM pin (P9) controlling PIR sensitivity. The author provided detailed pin mappings, English translations, and Tuya configuration files extracted on Arch Linux. The presence of pin 9 in the JSON TuyaConfig was confirmed, though its exact usage (PWM or digital) remains uncertain. Suggestions include testing pin 9 as PWM via OpenBeken (OBK) firmware or probing with an oscilloscope. The discussion also references the challenge of extracting Tuya config partitions on non-Windows systems and the potential use of Wine or Mono for related tools. A GitHub commit link related to OpenBeken webapp was shared for further reference.
Summary generated by the language model.
ADVERTISEMENT