FAQ
TL;DR: If your BK7231N door sensor re-sleeps after 60 seconds and won’t wake on “closed,” fix it by updating firmware and tuning DSEdge. “The problem has been solved—update firmware and try DSEdge 1, then 0.” [Elektroda, p.kaczmarek2, post #20543519]
Why it matters: This FAQ helps DIYers and integrators quickly restore reliable deep-sleep wake on BK7231N door sensors and set battery/LED features.
Quick Facts
- Hardware: BK7231N, firmware 1.15.665, no TuyaMCU; door input often set on P8 (PWM2) with DoorSnsrWSleep. [Elektroda, oded00, post #20531963]
- Symptom: Sleeps fine, but won’t wake when it fell asleep with channel=0; fixed by DSEdge 1 or 0. [Elektroda, p.kaczmarek2, post #20543519]
- Reset button on P7 can wake device from deep sleep; useful for diagnostics. [Elektroda, oded00, post #20532759]
- External pull resistors can block GPIO wake; measure to VDD/GND and consider NoPup role. [Elektroda, p.kaczmarek2, post #20532769]
- Example setup: Battery on ADC P23 as CH4, LED on P26; publish every 30 s, sleep after 60 s. [Elektroda, spin55, #20533478
How do I fix a BK7231N door sensor that won’t wake from deep sleep?
Update to the latest firmware and adjust DSEdge. Default DSEdge 2 may not match your reed polarity. Try DSEdge 1 first, then DSEdge 0. This resolves the case where sleep on “closed” prevents wake. 1. Update firmware. 2. Set DSEdge 1. 3. If needed, set DSEdge 0. [Elektroda, p.kaczmarek2, post #20543519]
What are DSEdge options and which should I use?
DSEdge selects the wake-up edge for the door GPIO. Some boards wake only on a specific edge due to sensor wiring. The default is 2, but some devices need 1 or 0. Start with DSEdge 1, then try 0 if wake remains unreliable. [Elektroda, p.kaczmarek2, post #20543519]
My sensor only wakes if it fell asleep while channel=1. Why?
Your wake edge likely mismatches the reed switch polarity. Firmware added DSEdge control to handle this. The fix is to update firmware and set DSEdge 1, then 0 if needed. Default 2 can fail on some boards. [Elektroda, p.kaczmarek2, post #20543519]
How do I map and test the reset button as a wake source?
Assign the reset button pin to Btn and test waking from sleep. On the referenced board, P7 is the reset button and successfully wakes the device when pressed. Use this to confirm wake functionality while debugging the door input. [Elektroda, oded00, post #20532759]
How can I find which GPIO the reed switch uses?
Power off and measure resistance between the suspected sensor GPIO and GND, then to VDD. This reveals external pulls affecting polarity. You can also follow PCB traces to the switch. If pulls exist, try the NoPup door-sensor role variant. [Elektroda, p.kaczmarek2, post #20532769]
How do I set up battery measurement and MQTT publishing?
Example: map P23 to ADC as Channel 4 for battery. Use a script to publish every 30 seconds, then sleep after 60 seconds. Commands: addRepeatingEvent 30 -1 publishFloat "4" $CH4; delay_s 60; PinDeepSleep. Adjust intervals to match your needs. [Elektroda, spin55, post #20533478]
How do I control the device LED?
Assign the LED pin to an LED role. Example mapping sets P26 to LED; use LED2 if needed by your firmware. You can then toggle the LED via channels or rules for status indication before deep sleep. [Elektroda, spin55, post #20533478]
Do I need to script the door sensor, or does the driver handle it?
Use the DoorSnsrWSleep driver. It manages door events and sleep automatically, so you do not need a custom script. Scripts help only if you want custom delays or telemetry timing. [Elektroda, p.kaczmarek2, post #20533481]
What’s better for power: a fixed 60 s delay or MQTT-ack-driven sleep?
Fixed delays work, but acknowledged delivery is better. “The perfect system should shut down as soon as MQTT confirms reception.” This minimizes awake time and saves battery versus a 60-second window. [Elektroda, p.kaczmarek2, post #20533598]
What if DoorSnsrWSleep still doesn’t wake after setting DSEdge?
External pull-ups or pull-downs can cancel the intended edge. Check resistance to VDD and GND with a multimeter. If pulls exist, try the NoPup door-sensor role to avoid internal pulls fighting the hardware. [Elektroda, p.kaczmarek2, post #20532769]
Does this device require TuyaMCU to report door status?
No. The referenced sensor works without TuyaMCU. Configure the door input pin with the dedicated door-sensor role and deep-sleep handling in firmware. [Elektroda, oded00, post #20531963]
Which pin should I assign for the door input on this board?
On the reported unit, P8 (PWM2) was used for DoorSnsrWSleep. Your board can differ, so verify by tracing or logs. Confirm wake behavior after mapping. [Elektroda, oded00, post #20531963]
How can I change the go-to-sleep delay manually?
Use a small script. Example: setChannel 3 1; addRepeatingEvent 30 -1 publishFloat "4" $CH4; delay_s 60; PinDeepSleep. Increase or decrease delay_s to control sleep timing and match telemetry cadence. [Elektroda, spin55, post #20533478]