logo elektroda
logo elektroda
X
logo elektroda

Configuring PIR Sensor with CB3S Module and Tuya Chip: Step-by-Step Guide

vitya123 
Here is a config guide for a PIR sensor that is not yet on the LIST.
This is the product pic borrowed from the marketplace:
White PIR motion sensor with a smartphone app and Tuya and Alexa logos.
after removing the PCB from the case this is what we find:
Image of the PIR sensor PCB with the SOIC chip removed. PIR sensor module with visible components on the PCB, including the CB3S module and PIR lens.

The UART lines (Tx and Rx) we use for programming the CB3S module are shared by the CB3S module and the Tuya chip (the 8 pin SOIC chip at the top left). This means we need to free these pins temporarily. This can be done in a few ways:

1. Remove the SOIC chip temporarily
2. Remove the CB3S module temporarily
3. Break the Rx/Tx lines temporarily

I opted for the first option and removed the SOIC chip with hot air. I also soldered on a few wires to strategically important places:
CB3S module with attached wires on a PCB.
Red: 3.3V, Black: GND, White: Monitor/Debug

Close-up of a PCB with a CB3S module and PIR sensor, showing soldered wires.
Blue: Tx, Green: Rx. You can also see the SOIC chip removed in the top left corner.

Note: The 3.3V can be connected to the battery terminal, but the GND must be connected directly to the CB3S module, otherwise it will reset every few seconds if you don't press the button every few seconds...

Using the flasher utility is straightforward. Make a backup, then upload the new firmware.
This is the Autoexec.bat file I use (with help of this forum):

startDriver TuyaMCU
startDriver tmSensor
setChannelType 1 readonly
//Link dpid al canal 1
linkTuyaMCUOutputToChannel 1 val 1
setChannelType 3 readonly
//Link dpid al canal 3
linkTuyaMCUOutputToChannel 3 val 3
SetChannel 1 2


No special configuration is needed, just change the MQTT settings and any flags you need and that's it:
Screenshot of OpenBK7231N software system console.

At the end don't forget to remove the temporary wires and reattach the 8 pin SOIC chip.

Finished!

Here is a more detailed guide: https://diy.viktak.com/2025/02/tuya-pir-sensor-conversion-to-open-source-walkthrough.html

About Author
vitya123 wrote 51 posts with rating 10 , helped 1 times. Been with us since 2024 year.

Comments

@GUTEK@ 22 Dec 2024 21:22

Thanks for the description. I bought this sensor a few months ago and somehow it's been lying around, I had no idea where to use it. I reprogrammed it as described, it works fine. In HA it added me... [Read more]

vitya123 23 Dec 2024 09:01

I'm not sure. I don't have it with me right now, so I can't check, but I think it is the "reset" button on it. Can you please try and confirm this? [Read more]

spin55 23 Dec 2024 10:41

Yes, it is the battery value in Enum format and it takes three possible values: 0,1,2, which the script models to Low,Mid,High format if you modify it like this: startDriver TuyaMCU startDriver tmSensor setChannelType... [Read more]

@GUTEK@ 19 Jan 2025 19:02

I'm a bit late writing back. I set the detector like this: flags: 7, 10, 19, 35, 37 autoexec.bat file: startDriver TuyaMCU startDriver tmSensor setChannelType 1 Motion_n setChannelLabel 1 Motion linkTuyaMCUOutputToChannel... [Read more]

%}