logo elektroda
logo elektroda
X
logo elektroda

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

p.kaczmarek2 178092 1242
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #151 19881131
    p.kaczmarek2
    Moderator Smart Home
    Initial XR809 port seems to be working - but only HTTP server works so far.
    IMPORTANT: XR809 is using the same codebase/app repo as BK7231T version, which will make it easier to maintain in the long term. Basically, we will be supporting two different platforms now.
    There is no backend whatsoever, no flash memory storage, no pins settings, etc.
    XR809 app setup guide
    1. Checkout https://github.com/openshwprojects/OpenXR809 , add missing toolchain (this is XR809 SDK)
    2. Checkout https://github.com/openshwprojects/OpenBK7231T_App to OpenXR809/project/oxr_sharedApp/shared/ (this is our shared multiplatform app)
    3. Add missing SSID/pass in prv_config.h
    4. Run build_oxr_sharedApp.sh
    5. Use pheonixMC to burn firmware by UART on XR809
    Proof of concept works, now I will be porting each functionality to XR809, step by step.

    Anyone with XR809 devices here? @DrTFav ?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #152 19882094
    sebastian48
    Level 9  
    Hi, I got this Nedis Wi-Fi Smart Plug using the WS2B. I connected the pins directly to the WS2B but I can't get Beken Writer to write. It always times out/fails. I only have one UART connected (as I don't own two currently) so I cant really see what is happening. When running the writer I can hear the relay in the Smart Plug going on and off (after pressing "Program". Also the "pairing" diode keeps blinking so I guess I'm not even in boot loader. Trying to remove power and plug it back in to no avail, relay keeps clicking. Any ideas? I see you mention the "CEN pin". What is that?

    Power is separate steady 3.3V.

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #153 19882149
    boozeman
    Level 11  
    Looks like Nedis WIFIPO120FTW. I have wrecked 2 of them while desoldering whole module on the main board. No success for me when I was trying to flash when module is connected to main board. I have figured out the pins for this module and I know that WB2S TX1 bin is connected to button. No success even driving stabile 3.4VDC on external powersource. But if module is off the main board there's no difficulties to flash. But only first flash. When module is correctly flashed and soldered back, it can be reflashed normally like your picture (with CEN wire)

    If you figure out what is preventing flashing when module is connected to main board let me know. I do not want to wreck any more of them.

    pinout for WIFIPO120FTW:

    PWM0 = Led
    PWM1 = BL0937 CF
    PWM2 = BL0937 CF1
    PWM4 = BL0937 SEL
    PWM5 = Relay
    TX1 = EDIT: Connected to nothing
    RX1 = Button

    ah, and the CEN pin. When looking at your picture the CEN pin is connected opposite side of the wb2s module where it soldered to main board (pins viewed at top when VCC is right, CEN, A0, PWM0, PWM1 and PWM2). it must sorted to ground while programming.

    Module Datasheet
  • #154 19882165
    sebastian48
    Level 9  
    Interesting. I is indeed the WIFIPO120FTW.

    Did you have the same weird relay clicking going on? Something is at least happening, it starts when trying to Program.

    So you managed to reflash if you desoldered it but then you could not solder it back?

    Could you maybe mark it on the image? I don't quite understand where you mean...
  • #155 19882184
    boozeman
    Level 11  
    Sorry, english is not my native language and sometimes my text seems to be too complicated . Look at my previous post link to datasheet. And the same thing. Relay klicking and lights flickering.
  • #156 19882211
    sebastian48
    Level 9  
    Ah I missed the link. But just to be clear: you had to desolder the module and put it back to work? Or did you never get it to work?

    So connecting the CEN pin to GND is a momentary thing or should it be permanently there while flashing?
  • #157 19882233
    boozeman
    Level 11  
    sebastian48 wrote:
    Ah I missed the link. But just to be clear: you had to desolder the module and put it back to work? Or did you never get it to work?

    So connecting the CEN pin to GND is a momentary thing or should it be permanently there while flashing?


    I got 2 of modules flashed when totally removed from the Nedis Main board. I think that the TX1 pin causes this problem. It is connected to button. Try to desolder tx1 pin from the main board with tin cucker so there is no connection for module and main board for that pin. The other Nedis module WIFIP130FWT do not have this kind of flashing problem at all.

    Beware! the pin pads of the Nedis main board are really easily destroyed by excessive heat!
  • #158 19882238
    sebastian48
    Level 9  
    Thanks for the quick replies. Yes I experienced this with the 3.3V pad as you can see in the picture.

    I will give it a try and report back. Thing is this one is IP44 and for outdoors which is what I need.
  • #159 19882265
    p.kaczmarek2
    Moderator Smart Home
    I don't think that you need to desolder whole module just because of button on TX pin. The button most likely have a pull up resistor (a resistor between pin and VDD, while a button is between pin and GND), this resistor is used to set the default high value on pin (then, if you press the button, the pin value is low).

    All you need is to desolder temporarily this pull up resistor.

    Of course, if that's the case - I haven't tested this module, but if you tell me where I can buy it for Paypal, then I will order one right away! Or if you're willing to send me one for testing...

    BTW: relay clicking during programming? Maybe the RX or TX line is used for relay control as well?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #160 19882302
    sebastian48
    Level 9  
    I can try and get another one and send you. Will try your suggestions first. PM your address.
  • #161 19882336
    boozeman
    Level 11  
    p.kaczmarek2 wrote:
    I don't think that you need to desolder whole module just because of button on TX pin. The button most likely have a pull up resistor (a resistor between pin and VDD, while a button is between pin and GND), this resistor is used to set the default high value on pin (then, if you press the button, the pin value is low).

    All you need is to desolder temporarily this pull up resistor.

    Of course, if that's the case - I haven't tested this module, but if you tell me where I can buy it for Paypal, then I will order one right away! Or if you're willing to send me one for testing...

    BTW: relay clicking during programming? Maybe the RX or TX line is used for relay control as well?


    Hi, my bad! It is RX1 which is connected to a button.

    TX1 pin has no traces for anywhere in this board. I try to figure out full path to RX1 to button. Button has pull down resistor to the GND (R34). RX1 goes R33 to R2. R2 is pulled for 3.3v and other end is for button.

    Relay goes PWM5 to R8, then Transistor Q1 which is connected to relay coil.

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #163 19882469
    boozeman
    Level 11  
    sebastian48 wrote:
    Ok so desolder RX1 then?


    Or that resistor R33. What is easier.

    If and when you get it flashed Pin configuration is likely follows (There is no support for BL0937 current measuring circuit at the moment)

    pin configuration is most likely this:

    P6 LED 1
    P10 Button 1
    P26 Relay 1
  • #164 19882557
    ExploWare
    Level 10  
    boozeman wrote:
    sebastian48 wrote:
    Ok so desolder RX1 then?


    Or that resistor R33. What is easier.

    If and when you get it flashed Pin configuration is likely follows (There is no support for BL0937 current measuring circuit at the moment)

    pin configuration is most likely this:

    P6 LED 1
    P10 Button 1
    P26 Relay 1


    R33 is a 0ohm link, likely R8/R11 is the pull-up in this situation, although the picture is not completely clear on that.


    On my powermeasuring plug I managed to power it with 5V at the power voltage regulator, without desoldering angthing. Check U1 on your board, I think thats identical to my U2 [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    There I supplied the right-bottom pin with 5volt
  • #165 19882602
    boozeman
    Level 11  
    ExploWare wrote:

    R33 is a 0ohm link, likely R8/R11 is the pull-up in this situation, although the picture is not completely clear on that.


    On my powermeasuring plug I managed to power it with 5V at the power voltage regulator, without desoldering angthing. Check U1 on your board, I think thats identical to my U2 [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    There I supplied the right-bottom pin with 5volt


    Ah ok, The RX1 line goes via R33 to R2. That R2 must be that pullup resistor, because it's other end is connected to +3.3VDC.

    R8 is for bl0937 SEL pin and R11 for relay driver transistor. I have not encountered a similar flashing problem with other smart plugs. Another Nedis model has also RX1 for button. And one Emax plug too.
  • #166 19882644
    sebastian48
    Level 9  
    Yes there you go. It’s probably as you mention. I will have a go tomorrow.
  • ADVERTISEMENT
  • #167 19883071
    p.kaczmarek2
    Moderator Smart Home
    I had a very hard ride with adding MQTT support to XR809/XR3 platform, but it finally works:
    https://github.com/openshwprojects/OpenXR809/commit/26a486d6395936b5aced974dac82eb3cd27e4384
    https://github.com/openshwprojects/OpenBK7231...mmit/b736ba87e771f6f8de3739dec836c577e701b95d
    It was hard because OpenBK7231T is using LWIP 2 library for MQTT and XR809 was using LWIP 1 internally. At first, I tried to run XR809 on LWIP 2 but it was crashing. I decided that investigating this crash issue would take too long so I just ported LWIP 2 mqtt code to LWIP 1 for XR809 and now such a hybrid seems to be working:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    EDIT: I am looking into flash API right now:
    https://github.com/XradioTech/XR809SDK/blob/a...f82fd82872cdc85/project/wlan_etf/prj_config.h
    https://github.com/XradioTech/XR809SDK/blob/a...82872cdc85/project/common/framework/sysinfo.c
    Helpful post? Buy me a coffee.
  • #168 19883733
    pepesuriano
    Level 9  
    Hi, just a quick question, in this firmware is it possible to upgrade after flashing or I need to connect to UART each time I want to flash it? Just to know if I unsolder all cables after flashing.

    Thanks
  • #169 19883901
    p.kaczmarek2
    Moderator Smart Home
    The current version of BK7231T should have working OTA feature, so you don't need any wiring connection to it after flashing it once. Just make sure to flash it with latest version of OpenBK7231T, because @btsimonh did some improvements to config storage system and I am not sure if old config will be retained correctly (it might be, but I am not sure, I haven't tested it so far, I am extending support to differnt platforms right now - XR809 work in progress).

    XR809 update: I have decided to use sysinfo.c method for flash config storage.
    Helpful post? Buy me a coffee.
  • #170 19883937
    boozeman
    Level 11  
    p.kaczmarek2 wrote:
    The current version of BK7231T should have working OTA feature, so you don't need any wiring connection to it after flashing it once. Just make sure to flash it with latest version of OpenBK7231T, because @btsimonh did some improvements to config storage system and I am not sure if old config will be retained correctly (it might be, but I am not sure, I haven't tested it so far, I am extending support to differnt platforms right now - XR809 work in progress).

    XR809 update: I have decided to use sysinfo.c method for flash config storage.


    Hi
    OTA seems to work. Tested with de.vi.ce.ip/app link method. Seems like pin config is erased at first time. Second flash will keep pin settings.

    While testing this new webapp method at first time, I wrecked 2 of my modules :) Their MAC addresses converted to c8-47-8c-00-00-00 and I do not figure out what happened or how to Fix it. Well if there is no cure for this I have two spare modules that can be soldered in place and hope the circuit boards don't break :)

    Dodano po 3 [godziny] 46 [minuty]:

    sebastian48 wrote:
    Yes there you go. It’s probably as you mention. I will have a go tomorrow.


    Just flashed new Nedis WIFIPO120FWT at one shot. Just desolder that R33 for first flash. No need to even take the board off the plug \o/

    Pin Config:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #171 19884865
    p.kaczmarek2
    Moderator Smart Home
    That's great news! Please submit new device config by pull request. I'm happy that my 'remove resistor' trick works for you.

    XR809 config save & read is very close. I think I'm able to do a first XR809 support release this month.

    boozeman wrote:
    Their MAC addresses converted to c8-47-8c-00-00-00 and I do not figure out what happened or how to Fix it. Well if there is no cure for this I have two spare modules that can be soldered in place and hope the circuit boards don't break :)

    I hope that OTA hack maintainer - @btsimonh - will look into that, otherwise I'll try to come up with something, maybe API to change mac manually

    Dodano po 3 [godziny] 10 [minuty]:

    Or oh well, I changed my mind, I added MAC API right now, but I tested it only on XR809 platform so far, I think that BK might need a small fix for it to work fully:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Probably will need to save it to efuse
    Helpful post? Buy me a coffee.
  • #172 19885006
    boozeman
    Level 11  
    p.kaczmarek2 wrote:
    That's great news! Please submit new device config by pull request. I'm happy that my 'remove resistor' trick works for you.


    Yeah, This was the only module where pulled up button causes any flash problems. That R33 (0 ohm bridge, because the board is only single sided) is also easy to desolder and solder back. I will make PR for this and another Nedis mobule. Nedis WIFIPO120FWT has power measurement circuit, so the pin config will change when BL0937 support arrives. I'll make also some info, how to open devices, what must done before first flash, etc.

    p.kaczmarek2 wrote:

    Or oh well, I changed my mind, I added MAC API right now, but I tested it only on XR809 platform so far, I think that BK might need a small fix for it to work fully:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Probably will need to save it to efuse


    You are right about the efuse. The form works now on bk7231t but the data will not save yet.

    OTA needs some clearance to preventing damages by such "Gyro Gearloose "as I bring about. Whether both technologies require a back-end server with firmware files? The default in ota.c is http://raspberrypi:1880/firmware and this uses bin file. Using this method, the device resets to AP-mode. Settings are also erased and seems like my firmware does not update.

    Webapp method uses the rbl.file. It backups the settings, upfate firmware and restore settings ok. I quess it uses also that OTA backend http://raspberrypi:1880/firmware too?

    Webapp is hosted now by the site https://openbekeniot.github.io/webapp/

    There's setting to change webapp, but what/where is that Webapp code? Can we later bring it to private network too? So one can use the webapp without internet connection.

    Some docs needed.
  • ADVERTISEMENT
  • #174 19885620
    boozeman
    Level 11  
    schrad wrote:
    First of all: Nice work guys!!

    I would like to give it a try:
    1.) git clone --recursive https://github.com/tuya/tuya-iotos-embeded-sdk-wifi-ble-bk7231t.git in OpenBK7231T
    2.) git clone --recursive https://github.com/openshwprojects/OpenBK7231T_App.git in OpenBK7231T/apps/OpenBK7231T_App
    3.) ./build_app.sh apps/OpenBK7231T_App OpenBK7231T_App 1.0.0

    Is this the right way?!


    Yes, just like that. If you use some Debian/**buntu based Linux distro for compiling, please install Build-essential and libc6-i386 first.

    sudo apt-get install build-essential libc6-i386
  • #175 19885629
    p.kaczmarek2
    Moderator Smart Home
    schrad wrote:

    Incorrect, you have to use our modified SDK:
    https://github.com/openshwprojects/OpenBK7231T

    @boozeman so you're saying that mac change works (and can be seen by router) but it's not saved and after reboot mac is lost?
    Helpful post? Buy me a coffee.
  • #176 19885667
    boozeman
    Level 11  
    p.kaczmarek2 wrote:


    @boozeman so you're saying that mac change works (and can be seen by router) but it's not saved and after reboot mac is lost?


    Edit: I will try to be clearer.
    The form works, but the MAC address does not change or be saved.
  • #177 19885785
    p.kaczmarek2
    Moderator Smart Home
    @boozeman , I will try to look into it soon. I've been out of the loop for few days because I've ported our entire app to XR809 so my focus shifted temporarily to different platform. But most of things seems to be working on XR809 now, HTTP website, MQTT, digital output pins, MAC address change, saving configuration to flash... only few things left to do, including buttons, PWM, etc. Of course there is also no OTA on XR809 but it's not planned now.
    Helpful post? Buy me a coffee.
  • #179 19885828
    boozeman
    Level 11  
    schrad wrote:
    I use cygwin64 for win10.

    to be continuted...


    Be sure to install make when setting the Cygwin environment. This will save you a little time when compile the App for the first time :)
  • #180 19887366
    hmonteiro
    Level 7  
    Linux seems to build properly too.

    gcc -v
    Using built-in specs.
    COLLECT_GCC=gcc
    COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
    OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
    OFFLOAD_TARGET_DEFAULT=1
    Target: x86_64-linux-gnu
    Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6' --with-bugurl=/usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-Km9U7s/gcc-10-10.2.1/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
    Thread model: posix
    Supported LTO compression algorithms: zlib zstd
    gcc version 10.2.1 20210110 (Debian 10.2.1-6)

    ...

    *********************OpenBK7231T_App_1.0.0.bin********************
    *************************************************************************
    **********************COMPILE SUCCESS************************************

    ...

    Now i just have to find the time to do some soldering and try it out. :)

    Great work! Thanks!

Topic summary

The discussion revolves around the development and implementation of custom firmware for devices using the BK7231T and BK7231N chips, particularly focusing on creating a mini HTTP server, MQTT support, and integration with Home Assistant. Users share their experiences flashing various smart devices, troubleshooting issues related to UART connections, and configuring GPIO pins for different functionalities. The conversation also touches on the challenges of maintaining WiFi connectivity, the importance of proper pin configuration, and the potential for using I2C for additional device control. Several users report successful firmware updates and the addition of new features, including support for various sensors and devices.
Summary generated by the language model.
ADVERTISEMENT