logo elektroda
logo elektroda
X
logo elektroda

P06 Tuya PIR Motion Sensor Review: CBU Module, BK7231N, and MCU Insights

divadiow 1686 20
ADVERTISEMENT
  • Helpful post
    #1 21121587
    divadiow
    Level 34  
    Here I'll post my findings relating to the P06 Tuya PIR motion sensor. This device takes 2 AA batteries and 5v USB using a micro-USB connector.

    This item was purchased from https://www.aliexpress.com/item/1005004083257831.html from the NVWU store

    Screenshot of an AliExpress product page featuring the Tuya PIR motion sensor.

    Opening we see it comes with a CBU module. Unlike this P06 which comes with an XR3 (which is what I was hoping for). We also see it's accompanied by a Tuya MCU.

    View of the P06CBU-V1.3 motion sensor circuit board with the date 2022-12-22. Circuit board with P06 Tuya PIR electronic module. Circuit board of the P06 Tuya PIR device with markings and a micro-USB port. PCB from a Tuya PIR P06 motion sensor with connected wires.

    from TX2:

    Code: Text
    Log in, to see the code


    As expected the RX1/TX1 communication with the Tuya MCU gets in the way of dump/flash

    Screenshot of TuyaMCU Explorer/Analyzer software for OpenBeken.

    There is no continuity between RX/TX and any of the MCU legs but instead there is continuity to the small resistors beside the MCU. So, I severed the RX trace just where it leaves the CBU, after which the dump could be obtained, attached. Being Tuya MCU, there's no pin extraction

    Screenshot from Tuya Config Quick Viewer showing GPIO configuration in JSON format.

    firmware version 2.1.0 so no good for cloudcutter.

    Flashed with OBK and then soldered a little pb bridge over the cut RX.

    And that's as far as I can go tonight.
  • ADVERTISEMENT
  • #2 21121692
    p.kaczmarek2
    Moderator Smart Home
    So it can work with both batteries and USB? But it's battery-powered flavour of TuyaMCU, so it always sleeps anyway? How is the connection handled? Do batteries discharge when 5V USB is connected?
    Helpful post? Buy me a coffee.
  • #3 21121759
    divadiow
    Level 34  
    good questions. The manual isn't much help

    User manual for PIR motion sensor WiFi model P06 lying on a carpet. Leaflet with setup instructions for the Smart Life app with a QR code.
    Device setup instruction showing app screenshots for connecting to a Wi-Fi router. Motion sensor instruction manual with list of features and Wi-Fi setup.

    apart from this perhaps

    A section of user instructions describing how to connect a device via Micro USB port.

    I should probably flash back to factory to see what default behaviour is. You'd think there'd be safeguards in place to stop damage if both battery and USB were live, right?!
  • Helpful post
    #4 21121843
    p.kaczmarek2
    Moderator Smart Home
    Those safeguards would be in hardware, not software, so there is no need to flash. It depends on the connection circuit. The simplest (but no so efficient) way would be to use some dodes.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 21122644
    divadiow
    Level 34  
    curious, the only dpID appears to be
    Code: Text
    Log in, to see the code
  • #6 21122804
    p.kaczmarek2
    Moderator Smart Home
    so what kind of values does this enum have?
    Helpful post? Buy me a coffee.
  • #7 21122815
    divadiow
    Level 34  
    actually dpID 3 too

    Code: JSON
    Log in, to see the code
  • #8 21122839
    p.kaczmarek2
    Moderator Smart Home
    Battery enum is nothing new.
    So, pir state is an enum but has only two values possible?
    Helpful post? Buy me a coffee.
  • #10 21122974
    divadiow
    Level 34  
    Code: Text
    Log in, to see the code


    im still fiddling.

    autoexec

    Code: Text
    Log in, to see the code
  • #11 21122988
    p.kaczmarek2
    Moderator Smart Home
    I think that you need a tmSensor driver as well, as it is a TuyaMCU low power protocol. Not the classic TuyaMCU
    Helpful post? Buy me a coffee.
  • #12 21122998
    divadiow
    Level 34  
    ah! genius.

    Code: Text
    Log in, to see the code


    Screenshot displaying information about OpenBK7231N and channel status.

    I did try ReadOnlyLowMidHigh on setChannelType 3 ReadOnly but that didn't reveal anything in the GUI.

    Also, if there are only two dpIDs, I can't do anything with the LED or Btn? that's it, PIR and a rubbish battery indicator?
  • ADVERTISEMENT
  • #13 21123016
    p.kaczmarek2
    Moderator Smart Home
    Are LED and Btn connected to MCU or to WiFI module?
    Helpful post? Buy me a coffee.
  • #14 21123029
    divadiow
    Level 34  
    I can't seem to trace from resistor I am getting continuity from on one side. It's all right next to the MCU. I don't have continuity from CBU to any components. Button is as above to MCU.

    and no sign of pin assignments in binary

    Code: JSON
    Log in, to see the code


    posting this for ref too

    Screenshot of TuyaMCU Explorer/Analyzer program on the Elektrodka platform displaying WiFi data packets.
  • #15 21123063
    p.kaczmarek2
    Moderator Smart Home
    Well, I am almost certain that the button at least must be connected to MCU. You can press it and MCU may send then a special packet to WiFI module, which is used for pairing.

    The same probably goes for the LED>...
    Helpful post? Buy me a coffee.
  • #16 21123104
    divadiow
    Level 34  
    yes. I expected that too but that was not the experience. button pushes didn't seem to produce any MCU packets.

    I've gone back to factory and hooked up a second USB-TTL so I can properly see what factory is doing. Also, believe it or not, I've not really done much with TuyaMCU Analyser, so good practice,

    Electronic setup on a wooden desk with connected USB-TTL devices on a test board.

    COM10 = USBTTL_RX - RX test pad on PIR device
    COM22 = USBTTL_RX - TX test pad on PIR device

    boot log:

    Screenshot of TuyaMCU Explorer/Analyzer tool with Wi-Fi data packets.

    Added after 2 [minutes]:

    and a bit of Tuya app info too while I'm here

    Screenshot of a mobile app showing a detected motion sensor. App settings screen with motion detection and low battery alarms enabled. Device update screen showing no updates available. Motion sensor app screen indicating Motion detected.

    Added after 24 [minutes]:

    change from motion detected to no motion detected status:

    Screenshot of TuyaMCU Explorer showing decoded packets incoming and outgoing from the WiFi module. Tuya app screen on a smartphone displaying No motion detected.

    and reverse:

    Screenshot of TuyaMCU Explorer tool showing packet data.

    Added after 3 [minutes]:

    unpairing/wipe data and reboot from Tuya app. LED fast flash;

    Screenshot of TuyaMCU Explorer/Analyzer program with communication between Wi-Fi module and MCU.

    Added after 7 [minutes]:

    motion detected = dpId=1 Enum V=0
    no motion = dpId=1 Enum V=1

    Added after 3 [minutes]:

    odd. button short, long or very long presses produce nothing. not even a ringbuffer count change. It also doesn't reset/unpair the device to default.

    Added after 1 [hours] 18 [minutes]:

    CEN has a trace but the path is missing a component so ultimately doesn't have continuity to the MCU leg highlighted

    Two images of circuit boards from an electronic device, showing test points.
  • Helpful post
    #17 21125392
    p.kaczmarek2
    Moderator Smart Home
    Thank you for sharing. This is very strange that the RESET button does not seem to work.

    The CEN trace without component, on the other hand, seems normal. They don't need CEN. They just cut the power to the whole module.
    Helpful post? Buy me a coffee.
  • #18 21125436
    divadiow
    Level 34  
    yes. and there's continuity still from both sides of the button through to the MCU leg. the far side beeps fine when the button is pushed.

    nothing new in log out when button is pushed.

    Added after 18 [minutes]:

    divadiow wrote:
    I did try ReadOnlyLowMidHigh on setChannelType 3 ReadOnly but that didn't reveal anything in the GUI


    is ReadOnlyLowMidHigh not correct for this?

    Added after 10 [minutes]:

    OK so with the autoexec above (tmsensor now added) we get this on USB power

    Screenshot of the OpenBK interface showing PIR sensor and battery level information.

    when no motion PIR = 1 and this is changed when the MCU sends this:

    Code: Text
    Log in, to see the code


    motion detected PIR = 0 - MCU sends this

    Code: Text
    Log in, to see the code


    Added after 4 [minutes]:

    after 30s of the sensor being covered after motion, it will go back to no motion detected. The MCU flashes the red LED once when motion is detected and again when asserting no motion state
  • ADVERTISEMENT
  • Helpful post
    #19 21125502
    p.kaczmarek2
    Moderator Smart Home
    I can indeed see that this channel type is missing http display. Can you check this commit, after it builds?
    https://github.com/openshwprojects/OpenBK7231...mmit/a70bd96ee1275ec3b65572c56166b8d532404f8a
    Helpful post? Buy me a coffee.
  • Helpful post
    #20 21125503
    divadiow
    Level 34  
    -on 5v USB the device stays online all the time
    -on battery the MCU deep sleeps until a motion event then sleeps - then 30s later a no-motion event. For each event it boots and stays awake long enough for OBK to load for a few seconds
    -with batteries inserted and USB powered it will stay awake, presumably using USB as power source
    -if USB removed with batteries inserted the batteries do not take over. The device has to have all power removed and a power source added again

    at 3.0v (according to my PSU) battery level = 2
    at 2.9v (according to my PSU) battery level = 2
    at 2.8v (according to my PSU) battery level = 1
    at 2.7v (according to my PSU) battery level = 1
    at 2.6v (according to my PSU) battery level = 1
    at 2.5v (according to my PSU) battery level = 1
    at 2.4v (according to my PSU) battery level = 1
    at 2.3v (according to my PSU) battery level = 0
    at 2.2v (according to my PSU) battery level = 0

    Added after 14 [minutes]:

    p.kaczmarek2 wrote:
    Can you check this commit, after it builds?

    Screen displaying information about the device OpenBK_BK7231N_CBU_PIR_P06, including PIR channel status and battery level.

    :D

    Added after 2 [minutes]:

    does this mean there could be ReadOnlyMotion for 0 + 1 byte translation to plain-text status? What was the case for doing ReadOnlyLowMidHigh for battery and not other RO enum values?

    Added after 7 [hours] 2 [minutes]:

    WiFi PIR motion sensor with packaging and accessories

    https://github.com/OpenBekenIOT/webapp/pull/127
  • #21 21125800
    p.kaczmarek2
    Moderator Smart Home
    How does it know it's connected to 5V?

    ReadOnlyLowMidHigh was added because we had a LowMidHigh type for kitchen fans, which was both read and write enabled. It was showing a radio buttons on http panel and user was able to choose the level himself just by clicking.
    Motion, on the other hand, it's always just a read-only type, so there is no need to special "read only" version in this case.
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around the P06 Tuya PIR motion sensor, which operates on both 2 AA batteries and 5V USB power via a micro-USB connector. Users explore the internal components, including the CBU module and Tuya MCU, and discuss the device's behavior when powered by USB versus batteries. Key points include the device's deep sleep mode on battery power, the interaction between battery and USB power sources, and the functionality of the PIR sensor and battery state enums. Users also analyze the connection circuit and the potential need for hardware safeguards to prevent damage when both power sources are connected. The conversation highlights the importance of the TuyaMCU driver for proper operation and the challenges faced in tracing connections for buttons and LEDs.
Summary generated by the language model.
ADVERTISEMENT