logo elektroda
logo elektroda
X
logo elektroda

[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

p.kaczmarek2 180177 1264
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #211 19889316
    p.kaczmarek2
    Moderator Smart Home
    ExploWare wrote:

    I have created a pull request on Github for that.
    Line 264 should be 'not' instead of '!' and line 271 and 272 should be on one line


    Thanks, I have merged the pull request.

    Still, @ferbulous , can you still tell me which python version are you using? I'm curious because the code seemingly worked before fine for at least @btsimonh , I presume.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #212 19889317
    ferbulous
    Level 18  
    @kmhn I was able to get 2mb firmware bin from bk7231tools, there was some issue where it just stop midway (10-20%) when reading the firmware.
    I'm not sure what I did afterwards, but I finally got the firmware, one thing I noticed was the UART was still blinking even after it was finished.

    Dodano po 7 [minuty]:

    @p.kaczmarek2 it was 3.10, i added that previous post
    I'm trying to use the hid_download tool to try and read firmware but not successful yet since it keeps getting stopped midway

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #213 19889338
    boozeman
    Level 11  
    @p.kaczmarek2

    Can we use OpenBK7231_App Repository's Wiki section to collect Hookup Guides for devices? Articles with pics and schematics if possible, how to open the case, what must be do before flashing, etc.
  • #214 19889398
    p.kaczmarek2
    Moderator Smart Home
    boozeman wrote:

    Can we use OpenBK7231_App Repository's Wiki section to collect Hookup Guides for devices? Articles with pics and schematics if possible, how to open the case, what must be do before flashing, etc.

    Well, I am doing the same thing in Elektroda's teardown section for about at least one year already:
    https://www.elektroda.pl/rtvforum/topic3825966.html
    https://www.elektroda.pl/rtvforum/topic3793509.html
    https://www.elektroda.pl/rtvforum/topic3822484.html
    https://www.elektroda.pl/rtvforum/topic3806108.html
    https://www.elektroda.pl/rtvforum/topic3816656.html
    https://www.elektroda.pl/rtvforum/topic3798114.html
    and much more.

    See, two example schematics as drawn by me:
    Electrical schematic of WF-DS01 TUYA dimmer.
    Electrical schematic of TUYA WF-DS01 dimmer.
    If you like my work remember to support it at: https://paypal.me/openshwprojects

    You are all welcome to post your teardowns here on Elektroda so we have everything in one place:
    English section: https://www.elektroda.com/rtvforum/forum507.html
    (many teardowns are yet to be translated from polish to english)
    Polish section: https://www.elektroda.pl/rtvforum/forum507.html
    but if you prefer github, you can also submit device information there. Of course you don't have to do as detailed teardowns as I do on Elektroda, any information is welcome. If you need anything from me as from OpenBK7231_App Repository's Wiki maintainer, just tell me, I will be happy to help.

    Just note that every mine device (including devices donated by people here - strigona, etc) will have a dedicated topic on Elektroda teardowns section.
    Helpful post? Buy me a coffee.
  • #215 19889815
    ferbulous
    Level 18  
    @p.kaczmarek2 hi, which firmware bin file should i pick for the device?

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    Using hid_download.py still fails to completely read the firmware though

    If I use bkwriter for bk7231n, anything else I should change on the settings or just stick with the default?
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #216 19889833
    ExploWare
    Level 10  
    @ferbulous
    I think you might want to hold off a bit longer.

    This N version looks to be even more a work in progress for some time to come and you haven't read up. I'd suggest to do some more research, read each message in this topic (there are all the answers to the questions you've asked up to now) and be aware you can brick your device(s)
  • #217 19890168
    p.kaczmarek2
    Moderator Smart Home
    ExploWare wrote:

    This N version looks to be even more a work in progress for some time to come and you haven't read up.


    In fact, I have just received reports from one of our polish users saying that the current version of OpenBK7321N (N version) is working:
    wiktor_m wrote:
    python uartprogram openbk7231app_QIO_1.0.0.bin -u -d com13 -w --startaddr 0x0

    wiktor_m wrote:

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    I am not sure why he is using QIO version of binary and not UA (maybe it has something to do with startaddr 0x0), but the startaddr 0x0 and -u params (unprotect) are taken from original Beken company python tool so can assume they are correct.

    Is anyone else here (except Wiktor) willing to take the risk and test BK7231N build from my previous post?
    Helpful post? Buy me a coffee.
  • #218 19890291
    boozeman
    Level 11  
    @p.kaczmarek2 The last commit about the naming. My WB2S modules are recognized as BK7231N. They're Clearly BK7231T modules... I happily flashed them with the T version :)

    I made PR for it.
  • ADVERTISEMENT
  • #219 19890376
    p.kaczmarek2
    Moderator Smart Home
    Thank you for typo correction.

    I've just checked with the one and only N module I recently received:
    Electronic module with various components on a circuit board held by pliers.
    It seems that N version is working. I will post a separate teardown/flashing guide topic soon.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    EDIT: < redacted >
    EDIT2 : it seems that configuration save (pins and wifi creditentials) works on N version as well, altough I have one report from user saying that in his case the config crashes module (?)
    EDIT3: No, it seems that config is sometimes lost on N version, I will look into it later. Maybe we have to deprotect flash before saving configuration.
    Helpful post? Buy me a coffee.
  • #221 19890939
    ferbulous
    Level 18  
    p.kaczmarek2 wrote:
    Thank you for typo correction.

    I've just checked with the one and only N module I recently received:
    Electronic module with various components on a circuit board held by pliers.
    It seems that N version is working. I will post a separate teardown/flashing guide topic soon.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    EDIT: < redacted >
    EDIT2 : it seems that configuration save (pins and wifi creditentials) works on N version as well, altough I have one report from user saying that in his case the config crashes module (?)
    EDIT3: No, it seems that config is sometimes lost on N version, I will look into it later. Maybe we have to deprotect flash before saving configuration.


    Using hid_download tool i was able to flash the firmware with ease, didn't even need to use cen for reset. Not sure why bkwriter doesn't work for me

    As for the cbu, I used UA bin but then the device doesn't turn on (no led red). I'll try to solder the pins if it helps since I was still using probe pins. Hopefully the chip isn't bricked or something otherwise I'll have to transplant esp
  • #222 19890960
    ExploWare
    Level 10  
    @ferbulous after firmware upload is done, you'll need to setup the device
    The LED is often on a GPIO pin, which is controlled by the firmware, but that needs to be told first. Same for the relay and the button.
    Chances are big you'll see a new Wifi accesspoint when the device is switched on.

    Again:please read this whole thread to understand whats happening, you clearly are hoping to get more than you can expect at this state. As @p.kaczmarek2 said just a few posts before this, the N version is currently not storing settings as it should
  • #223 19890970
    p.kaczmarek2
    Moderator Smart Home
    ferbulous wrote:

    As for the cbu, I used UA bin but then the device doesn't turn on (no led red).

    At first I did the same - I used UA bin file but then device doesn't turn on (with no UART log at all).

    Then I used QIO and voila - it's alive:
    List of available Wi-Fi networks on a computer screen.
    but it seems that flash configuration is not retained after power off/power on cycle. It happens for both me and Wiktor. I suspect it has something to do with unprotecting the memory. I need to go out for a walk right now, but when I come, I will look into the N version sdk, maybe they have something more in their flash access code like "deprotect(1)" etc.

    Can anyone else check is the QIO binary working for them on N version chip, flashed as below:
    
    python uartprogram W:\GIT\OpenBK7231N\apps\OpenBK7231N_App\output\1.0.0\OpenBK7231N_app_QIO_1.0.0.bin --unprotect -d com10 -w --startaddr 0x0
    

    I just really need more test devices. Or testers.

    Also, can anyone include full debug logs here, both preflashing and after flashing?

    EDIT:
    ExploWare wrote:
    @ferbulous after firmware upload is done, you'll need to setup the device

    To be honest, I understood that @ferbulous has programmed the N chip incorrectly with UA version which doesn't work, it just stucks the module in the bootloop. I have tested it right now, while writing this post. In order to get OpenBK access point showing up, you have to use QIO version (and remember ofs 0x0 and --unprotect).
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #224 19892293
    ferbulous
    Level 18  
    @p.kaczmarek2 got it working after flashing N chip with QIO bin file, I can access the webpage and the settings now
    Will be waiting for your fix on the flash configuration not saved after powered on/off
    Also how can I help with the debug log if I use the hid_download tool?

    @kmhn now that I have the 2mb firmware dump from the BK7231N chip, if i ever need to restore the original firmware again. do I just select that bin file or anything else needs to be done first?
  • #225 19892314
    p.kaczmarek2
    Moderator Smart Home
    @ferbulous , can you at least check if settings are lost for you after a longer power-off of the module?
    Helpful post? Buy me a coffee.
  • #226 19892763
    pvxvictor
    Level 6  
    LSPA9, CB2S module: BK7231N
    python uartprogram OpenBK7231N_app_QIO_1.0.0.bin -u -s 0 -d com20 -w
    UartDownloader....
    programm....
    Write Successful: |##################################################|[ 9.03k/s]
    

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Configuration and next power startup:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    The third power startup is the loss of all settings and work in AP mode.
  • #227 19892926
    ferbulous
    Level 18  
    p.kaczmarek2 wrote:
    @ferbulous , can you at least check if settings are lost for you after a longer power-off of the module?


    Waited for 1 minute+ before it's powered on and the settings are still saved
    Setup the gpio pins, and webpage stopped responding, turn it off on the second time, does't look like it's connecting to the router just yet
    Restarted for 3rd time, and it's connected back to wifi with the settings still there

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • ADVERTISEMENT
  • #228 19892992
    ExploWare
    Level 10  
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant


    I do have a Qia Smart Switch device with the T chip.
    I noticed in te Templates this was listed as an N module.
    Maybe this one is in two variants?

    
    template_t g_templates [] = {
    	{ Setup_Device_Empty, "Empty"},
    	// BK7231N devices
    	{ Setup_Device_BK7231N_CB2S_QiachipSmartSwitch, "[BK7231N][CB2S] QiaChip Smart Switch"},
    
  • #229 19893493
    p.kaczmarek2
    Moderator Smart Home
    ExploWare wrote:

    I do have a Qia Smart Switch device with the T chip.

    This is a very useful information. I was wondering whether should I separate configs for N and T versions and now I'm sure that those versions are sometimes used interchangeably. My Qia has a N chip.

    ferbulous wrote:

    Restarted for 3rd time, and it's connected back to wifi with the settings still there

    And today, no settings loss?

    PS: The N version has slightly different table offsets, I am investigating it now:
    https://github.com/tuya/tuya-iotos-embeded-sd..._os/beken378/func/user_driver/BkDriverFlash.c
    https://github.com/tuya/tuya-iotos-embeded-sd..._os/beken378/func/user_driver/BkDriverFlash.c
    Source code defining logical partitions on devices with BK7231T and BK7231N chips.

    Dodano po 5 [godziny] 2 [minuty]:

    UPDATE: after a brief investigation I am concluding that RL_SUPPORT_FAST_CONNECT option is overwriting the data from BK_PARTITION_NET_PARAM, thus making us lose our configs.

    See platforms/bk7231n/bk7231n_os/beken378/func/joint_up/role_launch.c :
    Source code in C language related to a function for reading BSSID information.
    I will try disabling it and see if the configuration issues are gone. If that's it, then we're getting a third supported platform (first was obviously BK7231T, second XR809 - yes, it works, even with config save, and third now will be BK7231N)

    As I said in the first post, the multiplatform, flexible approach is required for todays smart devices, so we don't have to create separate Tasmota clone for each platform. With both BK7231's supported (N and T), and of course XR809 supported (which is a totally different chip family), I will continue the development of main app and maybe add support for more platforms soon! Any suggestions of other popular chips that have public SDKs?
    Helpful post? Buy me a coffee.
  • #230 19896479
    ExploWare
    Level 10  
    @p.kaczmarek2 the only other platform I've run into with Tuya is a bit older but I do have the module separated from the lightbulb: it was the WR3L with a Realtek RTL8710 chip onboard

    I've also created a pull request for the OpenBK7231 as well as the _App repositories, to include the Git clone version, I think thats easier for users as it is auto_incrementing and developers as it's always pointing to what version is in use.

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    Dodano po 24 [minuty]:

    that version would lead to https://github.com/openshwprojects/OpenBK7231T_App/commit/e896a81e and that informs a lot on what version is cloned for the build
  • #231 19896505
    p.kaczmarek2
    Moderator Smart Home
    I have posted a detailed teardown and programming guide (and short story of my experiences) about Qiachip BK7231N version on polish side of the forum:
    https://www.elektroda.pl/rtvforum/topic3874289.html#19896503
    I might translate it later.

    I also started working on readme:
    https://github.com/openshwprojects/OpenBK7231T_App/
    and pushed binaries to the App repo (for all 3 supported platforms):
    https://github.com/openshwprojects/OpenBK7231T_App/tree/main/releases

    Ah, I also reworked the buttons code - buttons will now work for XR809 platform.

    ExploWare wrote:

    I've also created a pull request for the OpenBK7231 as well as the _App repositories, to include the Git clone version, I think thats easier for users as it is auto_incrementing and developers as it's always pointing to what version is in use.

    It seems like a very nice idea, but my concern is that the SDKs doesn't have to be used only to build our app, they can be basically used to build any app for BK7231N or BK7231T or XR809. Could you modify your code in such a way that it takes the GIT version if there is not one specified, and if user specified a version then he's allowed to override it?
    Helpful post? Buy me a coffee.
  • #232 19896892
    sebastian48
    Level 9  
    Thanks for your continued work! Looks like this is getting more streamlined. Before I start trying to not wreck another device I just need to ask about the UART again as I see BKWriter is now replaced with a python tool: I should still connect everything as I tried with BKWriter (which always failed)?

    Specifically what does "connect the PC to serial 2 on the bk7231" mean? I have the WB2S with BK7231T. Just a bit perplexed about the "serial 2"?
  • #233 19896944
    boozeman
    Level 11  
    sebastian48 wrote:
    Thanks for your continued work! Looks like this is getting more streamlined. Before I start trying to not wreck another device I just need to ask about the UART again as I see BKWriter is now replaced with a python tool: I should still connect everything as I tried with BKWriter (which always failed)?

    Specifically what does "connect the PC to serial 2 on the bk7231" mean? I have the WB2S with BK7231T. Just a bit perplexed about the "serial 2"?


    Hi,

    The previous failed apptempts with Nedis WIFIPO 120FTW was caused the use of The pin of the RX1 is pulled up to 3.3 volts and is used to connection of the push button. When trying to flash, this causes that led flickering and relay klicking.

    Remove R33 before the first flash (if you use that Nedis 120FTW). You can use RX1 and TX1 for flashing. RX1 goes to your usb2serial adapter TX and TX1 to RX. Beken Writer should do the job, because the module is BK7231T. Start the programming and then short CEN and GND for a second.

    If you see new Access Point at your phone or computer after flashing, you can disassemble the wires and put R33 back on board. and assemble the covers back. Be careful on the resistor and use tweezers when removing or assembling it.
  • #234 19896969
    sebastian48
    Level 9  
    boozeman wrote:
    sebastian48 wrote:
    Thanks for your continued work! Looks like this is getting more streamlined. Before I start trying to not wreck another device I just need to ask about the UART again as I see BKWriter is now replaced with a python tool: I should still connect everything as I tried with BKWriter (which always failed)?

    Specifically what does "connect the PC to serial 2 on the bk7231" mean? I have the WB2S with BK7231T. Just a bit perplexed about the "serial 2"?


    Hi,

    The previous failed apptempts with Nedis WIFIPO 120FTW was caused the use of The pin of the RX1 is pulled up to 3.3 volts and is used to connection of the push button. When trying to flash, this causes that led flickering and relay klicking.

    Remove R33 before the first flash (if you use that Nedis 120FTW). You can use RX1 and TX1 for flashing. RX1 goes to your usb2serial adapter TX and TX1 to RX. Beken Writer should do the job, because the module is BK7231T. Start the programming and then short CEN and GND for a second.

    If you see new Access Point at your phone or computer after flashing, you can disassemble the wires and put R33 back on board. and assemble the covers back. Be careful on the resistor and use tweezers when removing or assembling it.


    I guess I will have to try it once more. Getting a soldering station with a thinner tip first. But that begs to question: is the R33 resistor actually needed for function?

    The pad broke on the R33 when I trained on the already broken board so I probably need to be more careful. Anyway, I ordered a station with exchangeable tips and digital temperature setting. Any recommendations on temperatures when removing the R33?
  • #235 19897032
    boozeman
    Level 11  
    sebastian48 wrote:
    I guess I will have to try it once more. Getting a soldering station with a thinner tip first. But that begs to question: is the R33 resistor actually needed for function?

    The pad broke on the R33 when I trained on the already broken board so I probably need to be more careful. Anyway, I ordered a station with exchangeable tips and digital temperature setting. Any recommendations on temperatures when removing the R33?


    The R33 is basically a trip wire, so you can replace it with shot piece of wire or take the 0 ohm resistor for your previous device. The R33 is possibly the easiest part to be desolder before first flash. This modules circuit board is one sized, so there's several 0 Ohm resistors like trip wires. Without R33 the button wont work.
  • #236 19897071
    ExploWare
    Level 10  
    @boozeman I think the English word you're looking for is Jump-wire. It Jumps the PCB Trace over another.

    @sebastian48 The Serial 2 is implying the 2TX and 2RX connections which are on the back of the module pcb. They are used to get log data. The 1TX and 1RX are the 'programming bus', and therefor most important, and the 'logging bus' is optional, but very useful if something unpredicted happens.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #237 19897084
    sebastian48
    Level 9  
    ExploWare wrote:
    @boozeman I think the English word you're looking for is Jump-wire. It Jumps the PCB Trace over another.

    @sebastian48 The Serial 2 is implying the 2TX and 2RX connections which are on the back of the module pcb. They are used to get log data. The 1TX and 1RX are the 'programming bus', and therefor most important, and the 'logging bus' is optional, but very useful if something unpredicted happens.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant


    Ah yes thanks for the clarification. I only got one UART device so that will have to do unless I pick up one additional.
  • #238 19897117
    ExploWare
    Level 10  
    sebastian48 wrote:
    I only got one UART device so that will have to do unless I pick up one additional.

    Sure? Lots of us have an extra Arduino or Raspberry Pi laying around.

    They are quite capable to use as the flash station and logging feedback
    https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-uarts

    or as an extra Serial to USB dongle
    https://www.arduino.cc/en/Reference/SoftwareSerial
  • #239 19897135
    sebastian48
    Level 9  
    ExploWare wrote:
    sebastian48 wrote:
    I only got one UART device so that will have to do unless I pick up one additional.

    Sure? Lots of us have an extra Arduino or Raspberry Pi laying around.

    They are quite capable to use as the flash station and logging feedback
    https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-uarts

    or as an extra Serial to USB dongle
    https://www.arduino.cc/en/Reference/SoftwareSerial


    HA! of course I didn't think of that! I do have an Arduino that I could use actually! Thanks :)
  • #240 19897203
    boozeman
    Level 11  
    sebastian48 wrote:
    HA! of course I didn't think of that! I do have an Arduino that I could use actually! Thanks


    You do not need the second UART because when you do successful flash and connect the device to your wlan, you can always use ip.address/app link. There is logs tab

Topic summary

The discussion centers on the development and testing of an open-source firmware project for the BK7231T microcontroller, focusing on creating a cross-platform mini HTTP server, web-based pin configuration, MQTT integration, and Home Assistant compatibility. The project includes a Visual Studio project for Windows and firmware flashing tools like Beken Writer and a Python-based uartprogram. Users report challenges with flashing devices, including issues with firmware size limits (956KB), UART converter compatibility, and power supply stability during flashing. Solutions include using specific UART adapters (e.g., FT232R, CP2102), resetting devices via the CEN pin instead of power cycling, and trimming firmware binaries. The firmware supports devices with BK7231T and BK7231N chips, with ongoing work to add PWM dimmer support, BLE, TuyaMCU protocol integration, and OTA updates. Various smart devices such as WB2S/WB3S modules, smart plugs, LED bulbs, and switches from brands like MOES, Nedis, Hama, and Calex are tested. Users share detailed hardware teardowns, pinouts, and flashing procedures. MQTT topic naming issues related to MAC address usage were identified and fixed. The project emphasizes community collaboration, with suggestions for a Discord server to enhance real-time communication. Additional tools and SDK improvements, including CMake support and BLE integration, are under development to facilitate firmware building and device support expansion.
Summary generated by the language model.
ADVERTISEMENT