Anyhow, I just flashed original tuya firmware over OBK, hooked it up to my wifi and tuya cloud and it worked.
Then I flashed again OBK, now as config was re-init'ed, no problem anymore.
Czy wolisz polską wersję strony elektroda?
Nie, dziękuję Przekieruj mnie tam| Pin number | Symbol | I/O type | Function | 1 | P14 | I/O | Common GPIO, which can be reused as SPI_SCK (Correspond to Pin 11 of the IC) | 2 | P16 | I/O | Common GPIO, which can be reused as SPI_MOSI (Correspond to Pin 12 of the IC) | 3 | P20 | I/O | Common GPIO (Correspond to Pin 20 of the IC) | 4 | P22 | I/O | Common GPIO (Correspond to Pin 18 of the IC) | 5 | ADC | I/O | ADC, which corresponds to P23 on the internal IC (Correspond to Pin 17 of the IC) | 6 | RX2 | I/O | UART_RX2, which corresponds to P1 on the internal IC. (Correspond to Pin 28 of the IC) | 7 | TX2 | I/O | UART_TX2, which is used for outputting logs and corresponds to P0 of the internal IC (Correspond to Pin 29 of the IC) | 8 | P8 | I/O | Support hardware PWM (Correspond to Pin 24 of the IC) | 9 | P7 | I/O | Support hardware PWM (Correspond to Pin 23 of the IC) | 10 | P6 | I/O | Support hardware PWM (Correspond to Pin 22 of the IC) | 11 | P26 | I/O | Support hardware PWM (Correspond to Pin 15 of the IC) | 12 | P24 | I/O | Support hardware PWM (Correspond to Pin 16 of the IC) | 13 | GND | P | Power supply reference ground | 14 | 3V3 | P | Power supply 3V3 | 15 | TX1 | I/O | UART_TX1, which is used for transmitting user data and corresponds to Pin 27 of the IC. For the MCU solution, please refer to CBx Module. | 16 | RX1 | I/O | UART_RX1, which is used for receiving user data and corresponds to Pin 26 of the IC. For the MCU solution, please refer to CBx Module. | 17 | P28 | I/O | Common GPIO (Correspond to Pin 10 of the IC) | 18 | CEN | I/O | Reset pin, low active (internally pulled high), compatible with other modules (Correspond to Pin 21 of the IC) | 19 | P9 | I/O | Common GPIO (Correspond to Pin 25 of the IC) | 20 | P17 | I/O | Common GPIO, which can be reused as SPI_MISO (Correspond to Pin 14 of the IC) | 21 | P15 | I/O | Common GPIO, which can be reused as SPI_CS (Correspond to Pin 13 of the IC) | Test point | CSN | I/O | Mode selection pin. If it is connected to the ground before being powered on, enter the firmware test mode. If it is not connected or connected to VCC before being powered on, enter the firmware application mode. Correspond to Pin 19 on the internal IC. |
Battery_Setup 1500 3000 2 2400 4096
//measure batt every 60s
Battery_cycle 60
//mqtt_broadcastInterval 1
//mqtt_broadcastItemsPerSec 5
addEventHandler OnHold 10 SafeMode 5
setChannelLabel 1 Smoke
setChannelLabel 2 Tamper
setChannelLabel 4 BatADC
setChannelLabel 5 BatRelay
// now wait for MQTT
waitFor MQTTState 1
// extra delay, to be sure
delay_s 1
// publish smoke and tamper state at least once after boot
publish 1 $CH1
publish 2 $CH2
publish 4 $CH4
publish 5 $CH5
// ------------------------------------------------
// if smoke detected, keep cycling (but drains battery)
again:
delay_s 2
if $CH1!=1 then goto again
delay_s 10
// at this point there's no smoke so if the device is not tampered, then go to 36 hours deep sleep
if $CH2==1 then goto dpsleep
// if tampered, keep rebooting once an hour to report (tampered) state
// the 300s delay window is for maintenance work
delay_s 30
if $CH2==1 then goto dpsleep
delay_s 30
if $CH2==1 then goto dpsleep
delay_s 30
if $CH2==1 then goto dpsleep
delay_s 30
if $CH2==1 then goto dpsleep
delay_s 30
if $CH2==1 then goto dpsleep
delay_s 30
if $CH2==1 then goto dpsleep
delay_s 30
if $CH2==1 then goto dpsleep
delay_s 30
if $CH2==1 then goto dpsleep
delay_s 30
if $CH2==1 then goto dpsleep
delay_s 300
if $CH2==1 then goto dpsleep
PinDeepSleep 21600
dpsleep:
// All good, sleep for as long as possible (36 hours) to preserve battery
PinDeepSleep 130000
delay_s 3
// nothing
TL;DR: Deep-sleep pulls only 4 µA, “device goes into deep sleep and sleeps until something happens” [Elektroda, p.kaczmarek2, post #20462498] Flash OpenBeken, map P15=PIR smoke line, add
PinDeepSleep 86400; one test button press confirms MQTT. Why it matters: year-long battery Wi-Fi smoke alarms without cloud lock-in.
• MCU: BK7231N on Tuya CBU module [Elektroda, dominictauscher, post #21406315] • Flash file: OpenBK7231N_QIO_xxx.bin via UART @115 kbaud [Elektroda, seemebreakthis, post #20824777] • Deep-sleep draw: 4–6 µA, active Wi-Fi ≈80 mA [Elektroda, p.kaczmarek2, post #20462498] • Battery: 2 × AAA (≈1000 mAh) → ≈12 months @6 h heartbeat [Elektroda, DSF4ever, post #20434069] • Wake latency: ~5 s from GPIO, ~60 s from timer [Elektroda, p.kaczmarek2, post #20467927]
Battery_Setup 2000 3000 2 2400 4096
Battery_cycle 60
waitFor MQTTState 1
PinDeepSleep 86400
This sleeps 24 h, wakes, publishes voltage, then re-sleeps [Elektroda, marnypopis1, post #21038952]
platform: mqtt
state_topic: "smoke1/voltage/get"
value_template: "{{ value|int }}"
Trigger automations below 2400 mV (≈20 %) [Elektroda, dominictauscher, post #21515437]