TUYA door and window sensor. It comes with a BK7231N (pic1) soldered onto a board like this (pic2). Now, as you can see, I can't easily access the backside with RX and TX as you did. And as I plan to use 22 such sensors all around the house, desoldering and resoldering each one would take me YEARS as I am a really newbie - willing but with not much soldering experience.
Now I hope you either have any other idea how to access the BK´s RX/TX PiNs .... ooooor maybe the shown contacts on the right side of the board (pic2) could be helpful? They are (marked in red) on the downside marked (as you can see on the pic)
RST, SWS, V, G, T, R
Any idea if maybe the BK´s RX / TX are directed to any of these?
Hello, I will try to help you... hmm... why do you think this device is problematic?
It's not WB2L/WB2L_M1/CB2L.. it's CBU. It's very easy to flash.
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.
As you can see, TX1 and RX1 are easily accessible.
By the way, please check where the mentioned pads for goldpins connect, and post information here. It might be useful for some people, but I'd already try guessing that R stands for RX and T for TX. Then G is Ground, V is Voltage...
"""
`serial` is an object serialization/deserialization library intended to facilitate authoring of API models which are
readable and introspective, and to expedite code and data validation and testing. `serial` supports JSON, YAML, and
XML.
"""
from __future__ import nested_scopes, generators, division, absolute_import, with_statement,
print_function, unicode_literals
from . import utilities, abc, model, marshal, errors, properties, meta, hooks, test, request
~
~
~
First of all, the CRC code is not updated for N so the warning is normal. It's okay.
And regarding WriteSector failed.... hm, how do you reset? I had this issue while I was resetting too quickly... the reset should be really, just 0.25s short on CEN.
btw how did you solve that strange Python problem from the several posts above?
... in which there was described a similar situation:
- reading (backup) possible
- baudrate issues same
- writing not possible
ALL as described above and in that post.
Aaaand this post even became identical as I read he used a MacBook Pro (as me). So the ONLY thing I changed was connecting the USB-UART-Dongle to my RASPBPI. Result:
So this similarity is surely no conincidtance and clearly a macOS issue. At least users should be warned or GitHub code should be updated. If I can help to finde out the reason: let me know what I can do!
Well done, I don't have much experience with macOS so I was not aware about it.
If you want, you can do the honors and submit a pull request with readme update here:
https://github.com/OpenBekenIOT/hid_download_py so your Github account will show up as a contributor - it's always good to be remembered as a person who helped with testing the tool.
Saved and rebooted, but how can I check before adding to HA if it works? How can I check if I used the correct PINs? Can I see sensor state results in the web frontend?
And there is actually one issue: it loses WiFi connection. No ping or web request wakes it up.... :(
Needs there anything else to be configured?
Added after 36 [minutes]:
I am asking this because the sensor publishes a state correctly via MQTT that is displayed in HA but does not change: so I suppose that I have maybe chosen the wrong PINs? This suits the fact that the device falls asleep, loses WiFi connection and does not come back even if physically triggered: so there is no wake up command from a recognized sensor state change, right?
When looking at the board picture (in my very first post) the magnetic contact sensor is marked as "H1" - is that helpful?
Device has to fall asleep in order to prolong battery life. Otherwise it would discharge battery in a day. While asleep, the website has to be offline, otherwise it wouldn't sleep. The only thing that can wake up correctly configured device is a button or sensor event.
The problem seems that you have selected wrong pin for button and the sensor. Now you have to put out batteries, wait several minutes or more for capacitors to discharge, because they can still hold current, and then finally put batteries again and quickly disable DoorSensor pin and driver. Then reboot.
Once you are sure that device is not running door sensor anymore, carefully investigate which GPIOs are really used for button and for sensor.
You can try setting a dInput role for each pin and checking which one reacts to door magnet.
The correctly configured device should wake up on both door sensor and button events.
I have same BK7231N/CBU Tuya door sensor, I’ve been trying to find the firmware, can you please link it, also can you advice how I can connect it to mqtt/home assistant (in detail please). Thank you.
X 10 [MQTT] Broadcast self state on MQTT connect X 35 [HASS] Deactivate avty_t flag for sensor when publishing to HASS (permit to keep value). You must restart HASS discovery for change to take effect. X 37 [WiFi] Quick connect to WiFi on reboot (TODO: check if it works for you and report on github)
Very good, I would only add that automatic HASS Discovery should be already working for that kind of devices, so you don't really need to write YAML manually.
But you have exactly the same device as we spoke about, right? If not, please post the picture.
It already works automatically adding to HA, but it shows the reverse status. When the sensor is open it shows that it is closed, and when the sensor is closed it shows that it is open
The discussion revolves around connecting and configuring a Tuya door and window sensor equipped with a BK7231N chip without using TuyaMCU. Users seek guidance on accessing the RX/TX pins for flashing firmware and configuring the device for MQTT/Home Assistant integration. Various solutions are proposed, including using specific pin configurations for the door sensor and button, adjusting baud rates for flashing, and troubleshooting issues related to firmware and battery drain. The conversation also covers the importance of deep sleep mode for battery conservation and the need for correct pin assignments to ensure proper sensor functionality. Users share their experiences with different configurations, including inverting sensor states and adjusting sleep settings to optimize performance. Summary generated by the language model.