logo elektroda
logo elektroda
X
logo elektroda

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

p.kaczmarek2 177435 1242
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #301 19908574
    p.kaczmarek2
    Moderator Smart Home
    @boozeman , Ah I know what happened, thanks for catching that!
    I was fixing it after @talltechdude pull request but forgot about that one variable.
    See:
    https://github.com/openshwprojects/OpenBK7231...mmit/f96713c794b83d9adaafe6e8ef79c4aa79239aee
    It seems I just need to add one more variable to be passed here.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    At first, it didn't work at all after @talltechdude changes (automated github release pull request) because all variables were empty (APP_NAME was empty, etc), so, as you see on the screenshot, I simply forwarded their values to make.


    EDIT: is it working for you now? See my fix:
    https://github.com/openshwprojects/OpenBK7231...mmit/5e91bcccfd364f31ac14d7aa85ca4173c1d6bbc7
    https://github.com/openshwprojects/OpenBK7231...mmit/91166a82dd2c50e01034268233657cc64ae10dfa
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    btw: I guess the same problem is with N version SDK?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #302 19909120
    sebastian48
    Level 9  
    I finally managed to flash using python CLI instead of the Beken Writer which I never got to work. Unfortunately the pad to R33 came off too so I am unable to resolder it. Is the button really necessary though?

    Also, and excuse my ignorance: in order for Home Assistant to control this unit I need to add commands or a schema? I'm just interested in on / off at this point. How can I figure out what commands it reponds to? @boozeman you seemed to have flashed the same unit. Could you point me in the right direction?
  • #303 19909153
    pepesuriano
    Level 9  
    p.kaczmarek2 wrote:
    Important note: If I have skipped someone's question/issue related to my firmware and the problem is not resolved, feel free to repeat this. I will do everything i can to help you.

    ferbulous wrote:
    @boozeman @p.kaczmarek2
    on my first few attempts, I did get the AP with successful flashing, but not anymore
    then I tried just soldering the pins, but still the same

    Are you saying that you're still not getting AP showing up on N version chip? But it showed before? Is that correct?

    Can you check logs and paste full log here?
    The log on UART 2 should tell you whether:
    a) device fails to boot/fails to start
    b) device starts in your WiFi client mode and tries to connect to your wifi network but fails (maybe you've set bad SSID or passport?)
    c) device starts in AP mode for but some reasons AP creation fails
    I need to know which scenario happens (a, b or c) and see full log before taking next step towards resolving your issue.

    If you set a wrong SSID/password on your Beken device and haven't configured any buttons, then you will have to reflash it with recovery mode flash to access it again.

    pepesuriano wrote:
    While I put CEN to GND I see on debug output that device restarts just fine, what could be missing? I also changed the PL2303 adapter and got the same.

    This suggests that you might have a resistor on TX or RX line as some people said, but it's hard to debug remotely. Do you know any online shops like eBay where I could buy the device you have? I'd do a teardown and test myself what's wrong.
    ALSO... maybe take a multimeter in a sound/buzzer continuity test mode, put one probe on programming TX port of Beken chip and then check with second probe one by one parts on board is it connected anywhere, maybe to some resistor? And then do the same for RX....


    @ExploWare , what's the state of your build fails issue? Is the building working for you now? I tried to build with a clean copy of both repos and it works for me.


    Unfortunately, it's a totaly unbranded device and there are no model marks on the PCB, it's sold from a local retailer here.
    I started poking around and nothing gave me continuity between TX1 or RX1 with something, what I realized is that TX1 is connected to nothing since it has no line on PCB (TX1 is green wire)

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

    Perhaps I'm still doing it wrong? I did this just like @ExploWare said:

    "...So: boot everything, start Read Flash, pull CEN to Ground and release that, then (if everything is wired correctly) the device will be sending the flash data to the computer...."

    To start discarding things, power supply must be fine since I can see logs on debug port right? Shorting CEN to GND to restart should be also fine since I see in debug output how it reboots.

    If anyone is willing to help vía PM, it's welcome since it becomed more difficult that it appeared :/
  • ADVERTISEMENT
  • #304 19909216
    btsimonh
    Level 11  
    try with python based flasher - to read (you need to get a dump of original anyway).
    I would trust the python flasher over bk_writer - at least you can see what it's doing...
    Thought still sometimes I can do 5-6 reboots before the flasher will connect...
    (and sometimes I just have TX & RX the wrong way around....).
    Last resort, suspect your 232 adaptor. I had a dodgy PL2023, now I don't use that one any more.
    I see you do have boot logs - swap adaptors over.
    Try reducing baud rate on python flasher.... (but this is not normally failure to connect - rather failure to read/write after connected.
    Again, check connections..... took me 3 days to get SPI flash to work, mainly 'cos I was stupid, and did I feel stupid when I found a twist in my ribbon was the main reason for no success :).
    br,
    Simon
  • #305 19909240
    ExploWare
    Level 10  
    As @btsimonh said, serial connection can be crappy.
    Just today I had a connection on an ESP where the ground was not fully shared,where I thought it was. I saw some sata flowing with Putty, so I didn't suspect that. But it didn't work.
    When I coupled the Serial ground to the power ground, it started to work just fine.
  • #307 19909869
    pepesuriano
    Level 9  
    Well, I have some new input, I realized that PL2303 which is connected to TX1 and RX1 don't have it's activity LEDs blinking while boot, I swapped my 2 PL2303 between TX1/RX1 and TX2/RX2 and both works fine, I can see logs on debug with either of them and none of them blink LEDs at boot.

    So maybe the theory of having some resistor on RX1 still stands? I discard TX1 since (as seen on previous posts) it has no trace attached to it. I tested continuity between RX1 and several resistors but none of them seem to be connected, I don't add more pictures because I seem that they are very clear but if any detail is needed to found the problem just tell me

    Cheers
  • ADVERTISEMENT
  • #308 19910003
    p.kaczmarek2
    Moderator Smart Home
    pepesuriano wrote:

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

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


    What I would suggest to you:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    Example of working setup:
    [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


    Aside from flashing issues - IMPORTANT QUESTION - do you guys (and I mean everybody) have any suggestions related to Tasmota compatibility, MQTT format structure, etc? Eg. cmnd/topic/<cmnd> ? Or in general, what are the features that are in your opinion the most important right now?
    Helpful post? Buy me a coffee.
  • #309 19910089
    boozeman
    Level 11  
    p.kaczmarek2 wrote:
    Aside from flashing issues - IMPORTANT QUESTION - do you guys (and I mean everybody) have any suggestions related to Tasmota compatibility, MQTT format structure, etc? Eg. cmnd/topic/<cmnd> ? Or in general, what are the features that are in your opinion the most important right now?


    My wishlist are follows:

    - New device's information as Json string like Tasmota. -> Auto Generate from pin config for sharing with ease > No need to change code, just share the json string. Where to collect?
    - MQTT like Tasmota or at least that you can configure device topic and name. / Tele Stat and Cmnd and maybe some common topic for all beken/xr809/whatever chips for discovery like Tasmota
    - BL0937 support for smart plugs with power measurement capabilities (There's that demo translated to english on OpenBK7231T/apps but it is way beyond to my programming skills.)


    Cheers and keep on really good work!

    Timo
  • #310 19910140
    ExploWare
    Level 10  
    I would really like a edge detect function.
    For example PIR sensor: high = motion detected, send mqtt message and/or activate relay. Low = no more motion, send mqtt message and/or release relay.
    This is functional for various type of sensors. Home Assistant can then for example trigger the hall light when movement is detected at the porch, or record the security camera footage as long as pin is high, so it does not have to rely on visual triggers on the camera feed
  • #311 19911618
    p.kaczmarek2
    Moderator Smart Home
    Thanks, any other suggestions?

    Today I have added a very handy small improvement.
    As you may know, some devices have a single button but two relays, like that one:
    https://www.elektroda.com/rtvforum/topic3875654.html
    So far it was only possible to disable both or enable both relays together with Btn_Toggle_All.
    Now, I added a secondary channel for button:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    So now, you can control two relays with single button.
    Very useful (and better than Tuya) for devices like CCWFIO232PK.
    Helpful post? Buy me a coffee.
  • #312 19912654
    absinth84
    Level 5  
    I recently bought a thermostat BHT-002 and i found inside the WB3S BK7231 instead of ESP.

    The module control a mcu via uart to pilot screen and relay.

    I extracted the original FW with Rpi (not enough current with ftdi or arduino and the module reset itself arter some seconds) and just tried to load OpenBK7231T_App compiled with docker on mac.

    I's possible an integration/porting from github fashberg/WThermostatBeca or klausahrenberg/WThermostatBeca?
  • #313 19912687
    p.kaczmarek2
    Moderator Smart Home
    @absinth84 I don't know the exact device you're referring to (thermostat BHT-002), I'd need to get one somehow for testing, maybe I can buy one with money from donations, we will see, but TuyaMCU support is on the way. Can you provide more information where one can buy BHT-002 WB3S version (not ESP)? It would be a shame if I bought one and received an ESP8266-based version...

    but in general, I have already started to work on TuyaMCU, I am using TH06 clock/temperature/humidity LCD display for development.
    Some WIP screenshots/photos:
    [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
    [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
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Helpful post? Buy me a coffee.
  • #314 19913213
    absinth84
    Level 5  
    @p.kaczmarek2
    The product is this one:
    [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

    bought on Amazon italy.

    If you are implementing the serial communication for the mcu I can test some commands to retrieve temp and manage scheduling and ralay.

    Are you developing in different branch/project?
  • #315 19915489
    p.kaczmarek2
    Moderator Smart Home
    I might try ordering this device from Banggood but I don't know what are the chances that I will get a WB3S-based one.

    The TuyaMCU development is in the main branch of App repository (not SDK). It's very far from being complete. Right now I am able to send RTCC data (date + time) from TuyaMCU to TH06 clock calendar LCD.
    Today I also added NTP support - getting time from network, so I will be able to send this time to TH06 soon.
    Of course TuyaMCU is much more than that, and everything is still to be done.

    If you want to test, there is a uartSendHex command in the current App, and soon I will add more advanced command which computes Tuya MCU checksum automatically, so it's easier to send.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    Futhermore, current codebase is able to receive and partially decode TuyaMCU packets:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Helpful post? Buy me a coffee.
  • #316 19917727
    pillarama
    Level 2  
    Greetings everyone. Just sharing my experience - I purchased a set of RGB LED smart bulbs branded "Arlec GRID Connect SMART LED GLOBES" from the local hardware store here in Australia.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Popped one open and found that they are running WB2L modules. :(
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Seems that nothing ships with ESP modules any more... :( Then I found this forum - and hope!

    I removed the module from one and wired it up.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    Since I run Linux and reaching Windows is not convenient for me, I first tried passing the USB serial modules through to a Windows VM so that I could run BekenWriter and successfully read the flash from the module (after a few tries)!

    I compiled the demo program in the SDK and tried to flash that onto the chip but it kept failing a moment after beginning the erase.

    Long story short - although I was able to read the chip quite well using the VM with USB passthrough this turned out to be the problem with writing - as soon as I switched to a real Windows machine I was able to write the program first try. I also noticed that it would read faster and work on every attempt as well. So just in case anyone else tries the same for whatever reason note that YMMV. :)

    I'm going to try the python flashing script mentioned here on Linux next that I know it's all wired up properly and the chip indeed can be flashed.

    Regarding discussions about what we would like to see developed - I guess an RGB LED is what would be good for me (sorry if that's already been discussed/done - I've not had time to read this whole thread yet). This LED runs a SM2135EJ LED controller.

    [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

    Thanks for everyone's hard work so far!
  • #317 19919007
    eakeyson
    Level 6  
    Hello,

    I am trying to flash a WB2L module with OpenBK7231T firmware. Relatively new here but have successfully flashed several ESPs with Tasmota.

    I can successfully flash with python CLI and 1st time, I did get AP and successfully configured WiFi and MQTT using OpenBK7231T_App_UA_1.0.0.bin. At first reboot after successful flash, all went away and now I can't get AP again despite flashing again several times. I have tried all of the pre-compiled binaries in the repo with no success. I have also double checked all the connections and confirmed absence of pull-up or pull-down resistors on pins.

    Here is the log output after boot:

    V:BK7231S_1.0.5
    CPSR:000000D3
    R0:77EDF0F6
    R1:2331136B
    R2:EED6FE63
    R3:5DB35B52
    R4:DF4B6338
    R13:732CE97F
    R14(LR):BCFF93B7
    ST:D1662661
    J 0x10000
    prvHeapInit-start addr:0x41ca60, size:144800
    [bk]tx_txdesc_flush
    Entering init log...
    Init log done!
    bk_pwm_stop:98

    Any suggestions on what to do next? Is this a BK7231S chip and not supported? Was the first time a fluke?

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #318 19919008
    pepesuriano
    Level 9  
    p.kaczmarek2 wrote:


    What I would suggest to you:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    Example of working setup:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant


    Ok, so I did literally that (double checked and tried with different PL2303 modules and python/bkwriter). No luck...

    What I found different is that now powering via the AMS1117 the SSID shows up (powering via 3v3 of WB2S does not).
    Also (hope this is useful) if you remember this picture:

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    I found with a multimeter that AMS1117 VIN (third pin from left to right) has continuity with upper connection of C6, and lower connection of C6 has continuity with left connection of R3. Is that useful?

    Cheers
  • #319 19919123
    sharathbk1912
    Level 8  
    Hi ,


    Firstly thankyou for the awesome work!!

    Current installation instruction (2022.01.28):
    1. Get openbk7231t_20220128_UA.bin from here:
    THe given link doesnt work can anyone please help with the bin repository

    Where to find the bin .

    Thanks and Regards
    Sharath B K
  • #321 19920637
    sharathbk1912
    Level 8  
    Thanks for the link !!

    My experience:
    Well i wasnt able to flash using bkwriter . It would just start erasing and stop there indefinitely even with multiple CEN toggle/power cycle . I thought would give the python method a try and it worked great! Used pwm with color picker and worked well from the app status page.

    Things work great!

    Few things i wanted to ask :
    Is there a configurable poweronstate setting ? how to use it ?

    For The PWM , all channels are currently individual . However we need to make them exclusive, like when CW no WW/RGB . when RGB no White(warm/cool) and when WW no CW/RGB. As to maintain the led supply current limits for the designed power supply.

    Thanks
    Sharath B K
  • #322 19920755
    pillarama
    Level 2  
    Ok, I've made some more progress on the ARLEC RGB SMART LED globes. I have flashed OpenBK7231T_App using the hid_download uartflash tool and that works nicely. My WB2L boots up and I was able to connect it to my WiFi. Great!
    I started looking at the LED PWM controller. As mentioned earlier it's a SM2135E Multi-Channel dimmer LED driver and uses I2C to control it. I have a translated Chinese PDF datasheet which has a basic explanation of the protocol, and I believe Tasmota has some level of support implemented (that's where I found the datasheet).

    I think the next step then would be some sort of I2C library for OpenBK7231.
    Is there one already in the SDK?

    I had a look but couldn't find one...

    BK7231 Pin layout:
    PWM4 I2C CLK
    PWM5 I2C DATA (Incorrectly labelled as PWM2 on the bottom of PCB)

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    PDU:
    Byte | Purpose
    0 | Address Instruction
    1 | Max Current Control
    2 | RGB or W/Y Select
    3 | R Value
    4 | G Value
    5 | B Value
    6 | W Value
    7 | Y Value

    I gather bytes 3-7 are straight forward since there's 256 levels per output
    Further details about Bytes 0-2 will require some more deciphering as the translation from Chinese is not perfect... It might be easier to go and see what the state of the Tasmota support is and maybe use that as a reference...
  • #323 19922005
    absinth84
    Level 5  
    Apparently I broken the WB3S module of thermostat, after a good flash last week i tried to connect it via his power source and cable but no wifi connection. So i tried to restore the firmware but i have no communication and activities on uart.

    I tried successfully also to load the bootloader and the entire firmware via SPI and rpi3 but nothing to do. The module don't boot.
    I flashed the QIO version of the firmware with default address and chip. It is correct?

    Any suggestion to try to restore it?
  • #324 19922086
    pepesuriano
    Level 9  
    pepesuriano wrote:
    p.kaczmarek2 wrote:


    What I would suggest to you:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    Example of working setup:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant


    Ok, so I did literally that (double checked and tried with different PL2303 modules and python/bkwriter). No luck...

    What I found different is that now powering via the AMS1117 the SSID shows up (powering via 3v3 of WB2S does not).
    Also (hope this is useful) if you remember this picture:

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    I found with a multimeter that AMS1117 VIN (third pin from left to right) has continuity with upper connection of C6, and lower connection of C6 has continuity with left connection of R3. Is that useful?

    Cheers


    Any suggestions on that?
  • #325 19922162
    ExploWare
    Level 10  
    pepesuriano wrote:
    Any suggestions on that?

    I fail to see a question. I thought it was reporting a success story.

    Can you rephrase your question?
  • #326 19923723
    pillarama
    Level 2  
    Hi All,
    Just highlighting a question I had burred in my last post because it's likely people won't notice it in there.

    Does anyone know if there is I2C support already anywhere in OpenBK7231?
    And if not, how hard it would be to implement?
    I'm hoping to implement SM2135 support for the RGB light bulbs I have.

    Thanks
  • ADVERTISEMENT
  • #327 19923811
    p.kaczmarek2
    Moderator Smart Home
    pepesuriano wrote:

    What I found different is that now powering via the AMS1117 the SSID shows up (powering via 3v3 of WB2S does not).

    pepesuriano wrote:

    Any suggestions on that?

    So it's working or is it not?

    sharathbk1912 wrote:

    Few things i wanted to ask :
    Is there a configurable poweronstate setting ? how to use it ?

    Not right now, but it will be added


    absinth84 wrote:
    WB3S module
    (...)
    I flashed the QIO version of the firmware

    WB3S requires UA version, QIO is for modules based on BK7231N, not T.

    pillarama wrote:

    Does anyone know if there is I2C support already anywhere in OpenBK7231?
    And if not, how hard it would be to implement?

    EDIT: At first I tought there is no I2C in Beken SDK, but there actually is. See later posts for implementation details.
    Helpful post? Buy me a coffee.
  • #328 19925094
    ExploWare
    Level 10  
    I seem to loose WiFi connectivity over time on several modules.
    Anyone else recognizes this?
  • #329 19925143
    absinth84
    Level 5  
    p.kaczmarek2 wrote:
    absinth84 wrote:
    WB3S module
    (...)
    I flashed the QIO version of the firmware

    WB3S requires UA version, QIO is for modules based on BK7231N, not T.


    Finally i solved the issue.
    Probably my bootloader was corrupted and i found a solution to rewrite it to BK7231T

    The correct way is rewrite the firmware QIO (bootloader + User data) or only th BL via SPI but i notice that the first bytes of the flash was blocked. During a dump with spi tool the fist bytes were all to 0.
    I triend to delete all flash with spi command but nothing...

    Reading the datasheet of the memory used (EN25QH16B) i saw the possibility via register to blocking the first sector or 64k of bootloader.
    I extended the hid tool and with Spi command i readed the status registry ( command 0x05). My suspect was confirmed. So i changed the registry (command 0x01) unprotecting the BL and finally i refleshed the entire firmware with bootloader (QIO version). The firmware boots up immediately and now also the update via UART is available.

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