Hello,
I have another, Tuya clone, Wifi door sensor powered 2xAAA, based on BK7231N chip. https://vi.aliexpress.com/item/1005006699671958.html
When I opened it, components are so small that I can hardly see descriptions when I use magnifying tool from my phone. No chance I can use any electronics way approach to hack this device.
I am newbie in the IoT devices hacking and I just bought 2 of these devices some time ago to do some tests, and didn't know the reality of compatibility issues, etc.
For my life scenario I wanted this device to report opening door events to external web application, not the HomeAssistant nor MQTT.
After trial and error, I successfully disconnected the device from Tuya via tuya-cloudcutter.
Then I successfully connected device to Home Assistant via ESPHome. Unfortunately it eats the battery in a few hours in that setup and I realized that with ESPHome I will be unable to use deepsleep. I didn't want to use Home Assistant anyway, just started it for some tests.
Then I realized I will need Openbaken and found a way to use it.
Running ESPHome I wanted to install OpenBaken via OTA. It was not so easy as latest openbaken images for this chip are in rbl format only (why?). Finally found old openbaken uf2 image somewhere, installed it with ESPHome OTA, and then I updated it to the latest version with OpenBaken OTA which uses rbl format. Little confused but happy that I succeeded I am currently running OpenBaken version: 1.17.670.
So far so good
Here are the problems I encountered and I'd like to kindly ask for help:
1. I don't understand the logic of pins and channels. E.g. I found out that magnet sensor is working at pin 7 when I choose DoorSnsrWSleep for this pin. But then for some reason channel is changed to 56 when I use GPOFinder. Fine I can live with that, but I don't know how to properly assign other channels. In the debug log I found out that the reset button is assigned to PIN? 20:
How can I work with this button properly?
2. I found out that with command like that I can add eventhandler and send requests to my web page
I didn't find information how to store that command permanently so it survives restarts.
I read about autoexec.bat but I cannot find a way to access it.
3. Battery level and voltage
I copied some settings from similar chip. And I get info regarding battery level and voltage, but values are weird
How can I fix that?
4. DeepSleep settings and MQTT
I would like to adjust DeepSleep for 10 seconds (or 5 maybe), just to have the option to configure it, I didn't find such an option.
I would like to change DeepSleep for 300 seconds or any configured value after reset button is pressed.
But for sure I'd like to have the option to turn off 300 seconds deepsleep when there is no MQTT connection.
I spend a lot of time during a last few days trying to find out how to make this working for me, but there are many questions I couldn't find answers for.
Could you answer to my questions?
Are there any comprehensive tutorial for newbies?
I will appreciate any help.
Thanks.
Dodano po 3 [minuty]:
>>21212130

Dodano po 51 [minuty]:
>>21212130
I found how to extract the settings from original Tuya software (via BK7231Flasher.exe), but after extraction it is not converted properly into the script in the import tab
I have another, Tuya clone, Wifi door sensor powered 2xAAA, based on BK7231N chip. https://vi.aliexpress.com/item/1005006699671958.html
When I opened it, components are so small that I can hardly see descriptions when I use magnifying tool from my phone. No chance I can use any electronics way approach to hack this device.
I am newbie in the IoT devices hacking and I just bought 2 of these devices some time ago to do some tests, and didn't know the reality of compatibility issues, etc.
For my life scenario I wanted this device to report opening door events to external web application, not the HomeAssistant nor MQTT.
After trial and error, I successfully disconnected the device from Tuya via tuya-cloudcutter.
Then I successfully connected device to Home Assistant via ESPHome. Unfortunately it eats the battery in a few hours in that setup and I realized that with ESPHome I will be unable to use deepsleep. I didn't want to use Home Assistant anyway, just started it for some tests.
Then I realized I will need Openbaken and found a way to use it.
Running ESPHome I wanted to install OpenBaken via OTA. It was not so easy as latest openbaken images for this chip are in rbl format only (why?). Finally found old openbaken uf2 image somewhere, installed it with ESPHome OTA, and then I updated it to the latest version with OpenBaken OTA which uses rbl format. Little confused but happy that I succeeded I am currently running OpenBaken version: 1.17.670.
So far so good

Here are the problems I encountered and I'd like to kindly ask for help:
1. I don't understand the logic of pins and channels. E.g. I found out that magnet sensor is working at pin 7 when I choose DoorSnsrWSleep for this pin. But then for some reason channel is changed to 56 when I use GPOFinder. Fine I can live with that, but I don't know how to properly assign other channels. In the debug log I found out that the reset button is assigned to PIN? 20:
Info:GEN:20 Button_OnLongPressHoldStart
Info:GEN:20 Button_OnInitialPressDown
Info:GEN:20 Button_OnInitialPressDown
Info:GEN:20 key_double_press
Info:GEN:20 key_short_press
How can I work with this button properly?
2. I found out that with command like that I can add eventhandler and send requests to my web page
addChangeHandler Channel7 != 0 SendGet http://10.10.10.5/sensor1Change
I didn't find information how to store that command permanently so it survives restarts.
I read about autoexec.bat but I cannot find a way to access it.
3. Battery level and voltage
I copied some settings from similar chip. And I get info regarding battery level and voltage, but values are weird
Battery level=0.00%, voltage=-0.58mV
How can I fix that?
4. DeepSleep settings and MQTT
I would like to adjust DeepSleep for 10 seconds (or 5 maybe), just to have the option to configure it, I didn't find such an option.
I would like to change DeepSleep for 300 seconds or any configured value after reset button is pressed.
But for sure I'd like to have the option to turn off 300 seconds deepsleep when there is no MQTT connection.
I spend a lot of time during a last few days trying to find out how to make this working for me, but there are many questions I couldn't find answers for.
Could you answer to my questions?
Are there any comprehensive tutorial for newbies?
I will appreciate any help.
Thanks.
Dodano po 3 [minuty]:
>>21212130

Dodano po 51 [minuty]:
>>21212130
I found how to extract the settings from original Tuya software (via BK7231Flasher.exe), but after extraction it is not converted properly into the script in the import tab

{
"bt_pin":"20",
"status_led_pin":"26",
"rstcnt":"3",
"basic_pin_pin":"7",
"module":"CB3S",
"jv":"1.0.4",
"bt_lv":"0",
"net_t":"180",
"samp_type":"1",
"basic_st":"1",
"basic_pin_lv":"1",
"samp_sw_pin":"14",
"max_V":"3000",
"min_V":"2200",
"samp_sw_lv":"1",
"status_led_lv":"1",
"samp_pin":"23",
"crc":"45"
}
