logo elektroda
logo elektroda
X
logo elektroda

Tasmota replacement for BL602, programming, pairing with Home Assistant, now with OTA working!

p.kaczmarek2 123621 497
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #361 20805803
    Balteck
    Level 2  
    I've got a this sensor from Ai-Thinker: RD-01.
    it is based on BL602 + S3KM111L. With the stock firmware I can use the radar only with UART connection to another MCU.

    But, since it uses a BL602, I think that it will be interesting to have a firmware that already sends status and data on MQTT via WIFI and, why not, add some other sensors on free GPIO available (like a DHT11/22 or BME280/680 or BH1750)

    Documentation is here: https://docs.ai-thinker.com/en/rd-01
    Actual firmware is here: https://github.com/Ai-Thinker-Open/Ai-Thinker-Radar

    Is it possible to support this sensor with OpenBK7231T_App?

    I can do debugging, testing or any other things that could help (sorry, I'm not a programmer)

    Thank you very much
  • ADVERTISEMENT
  • #362 20805895
    Balteck
    Level 2  
    I've got a this sensor from Ai-Thinker: RD-01.
    it is based on BL602 + S3KM111L. With the stock firmware I can use the radar only with UART connection to another MCU.

    But, since it uses a BL602, I think that it will be interesting to have a firmware that already sends status and data on MQTT via WIFI and, why not, add some other sensors on free GPIO available (like a DHT11/22 or BME280/680 or BH1750)

    Documentation is here: https://docs.ai-thinker.com/en/rd-01
    Actual firmware is here: https://github.com/Ai-Thinker-Open/Ai-Thinker-Radar

    Is it possible to support this sensor with OpenBK7231T_App?

    I can do debugging, testing or any other things that could help (sorry, I'm not a programmer)

    Thank you very much
  • #363 20823594
    Zhekos555
    Level 10  
    Was anyone able to flash openbeken to chip xt-bl02? Tried bldevcube latest version and blflash, as result no boot. On boot external power jumps to 0.02amps for a second and then to 0.00. Tried all , chip not booting, any experience?

    WiFi module XT-BL02 with visible wire connections.
  • #364 20823704
    p.kaczmarek2
    Moderator Smart Home
    We had several reports that chip will flash but will not boot if you power it from a low-current 3.3V power supply. For example, it happens if you get 3.3V directly from USB to UART converter. How are you powering your chip?
    Helpful post? Buy me a coffee.
  • #365 20823733
    Zhekos555
    Level 10  
    10amp laboratory supply, 3.3 very stable, have done many other chips with no issues at all. Golden ch340 is the flasher. Could it be that this bl602 has incompatible hw with openbeken? I have read here some topics that some versions of bl602 not compatible. Altrhough i have sucessfully flashed sonoff bulbs with the same bl602. Any help? Or just order esp-02s and forget it?
    Ps, I have tried to put it onboard back, same result, 0 activity.
    P.p.s. bootloader shows activity on serial, but stuck on booting openbeken fw
  • #366 20830092
    EricHughes
    Level 3  
    Hello everyone,

    I am hoping for your help:

    I have a Magic Home LED controller with LF686 chip. According to Github, it can be flashed like a BL602.

    I have connected the board to a USB->TTL adapter as described here in the forum. TX->RX, RX->TX, GND->GND 3.3V->3.3V->10k resistor -> Boot

    In BLDevCube 1.8.6 I have set the parameters as shown in the screenshot. I have flashed the current firmware version 1.17.308.bin.
    The process was also displayed as 100% successful in BLDevCube. However, no WiFi can be found and the LED strip is not lit.

    How can I proceed with the troubleshooting? I have flashed it a second time. Same problem.

    The output of BLDevCube if it could help troubleshooting.
    debug.txt Download(19.9 kB)

    Thank you very much!
  • #367 20830094
    p.kaczmarek2
    Moderator Smart Home
    Some time ago I had similiar bug report and it turned out that the used USB to UART converted was not able to provide enough current for device to boot. Have you tried to, first, disconnect BOOT signal and then power the device from the original power supply, and not from the USB to UART converter?
    Helpful post? Buy me a coffee.
  • #368 20830103
    EricHughes
    Level 3  
    Thank you for your answer. My first attempt was actually with an external power supply (12V 2.5A power supply, the one I actually used is unfortunately permanently installed). It also ran successfully, but no WiFI was visible. I then also connected the 3V3 connection of the UART adapter to the 3V3 connection of the LED controller and left out the power supply unit.


    To make it clear once again:

    I connect
    UART Converter:________LED Controller:
    GND ->_________________GND
    TX ->___________________RX
    RX ->___________________TX
    ________________________3V3 ->over 10k Resistor ->Boot
    ________________________12 V power supply unit to the LED controller.

    Is the sequence relevant?
    I have done it as follows so far. UART adapter connected to the computer and BLDevCube opened. LED controller switched off and connected as described above. Then connect the power supply unit and wait briefly. Flash. 10k resistor disconnect. Disconnect power supply unit. Wait briefly Connect controller to LED strip and connect power supply unit.

    Added after 48 [minutes]:

    I tried again with 12V external power supply an no 3V3 connection from the UART Converter.
    Now i get the Error: {ErrorCode: 0050, ErrorMsg: BFLB IMG LOAD SHAKEHAND FAIL}
  • #369 20834064
    joraroin
    Level 1  
    Hello, first of all, congratulations on your work.

    I have flashed an eWeLink light bulb with the bl602 chip.
    Smart bulb eWeLink with visible technical specifications.

    Two close-ups of a bl602 chip circuit board showing the front and back sides.

    Close-up of eWeLink light bulb circuit board with BL602 chip.

    Close-up of a circuit board with LED lights and a chip.

    Screenshot of Bouffalo Lab Dev Cube software for flashing the bl602 chip.

    Sorry for the resolution of the images

    I have managed to associate it with my WiFi, but a few seconds after obtaining the IP it stops responding to the ping. I have managed to get the website to appear but it does not load anymore.

    Screenshot displaying Wi-Fi connection details for a device.

    The light bulb is two meters from the WiFi router.

    It's funny, in AP mode, you can navigate through the settings without problems.
    User interface with configuration options like MQTT, MAC change, and Home Assistant setup.

    Do you know what can happen?

    Thank you very much!
  • #370 20834704
    Zhekos555
    Level 10  
    I had the same issue, flash it again and then leave it powered ON for 10-15 minutes, dont try to connect over wifi, just wait. Then its going to work just fine.
  • ADVERTISEMENT
  • #371 20835147
    p.kaczmarek2
    Moderator Smart Home
    Regarding WIFI issue - I haven't seen it yet, but maybe you have two devices with the same MAC on your WiFi? Have you tried different router? What does the debug log output say?

    EricHughes wrote:

    I connect
    UART Converter:________LED Controller:
    GND ->_________________GND
    TX ->___________________RX
    RX ->___________________TX
    ________________________3V3 ->over 10k Resistor ->Boot
    ________________________12 V power supply unit to the LED controller.

    Is the sequence relevant?
    I have done it as follows so far. UART adapter connected to the computer and BLDevCube opened. LED controller switched off and connected as described above. Then connect the power supply unit and wait briefly. Flash. 10k resistor disconnect. Disconnect power supply unit. Wait briefly Connect controller to LED strip and connect power supply unit.

    This sounds correct, altough I recently had a BL808 (yes, 808) flash issue on one of PCs that made it impossible to flash it. It worked on another PC. Both Windows 10. I am not sure what's wrong. So maybe try other PC... I will investigate it more.

    Apart from that, remember:
    - keep flashing wires length short
    - make sure you power device from a good 3.3V power supply
    - make sure you disconnect and RESET after flashing
    - do not clear the whole device flash/do not use different flashing config because you might erase MAC and I don't know how to recover it on BL602 yet

    In a meantime, here are our both BL602 tutorials:





    Helpful post? Buy me a coffee.
  • #372 20843181
    aradzh
    Level 2  
    Thank for firmware ! I flash small WIFI-relay based on BL602(SM-028_V1.3 BL602L20) (it needs to unsolder relay to have access to flash points).
    I meet with problem that for some reasons BL602 do not want to work with Xiaomi Mi Router 4A Giga Version (with OpenWrt 23.05): in logs of router there are a lot of lines like
    "Thu Nov 30 23:05:55 2023 daemon.info hostapd: phy0-ap0: STA 7c:b9:4c:a5:16:9f IEEE 802.11: authenticated"
    but no IP is given to BL602. So I many times used emergency five time power-off until realized what is the problem. With different router (TP-LINK MR3020) it works perfectly.
    I also check that with Android AP on my phone BL602 also working.
  • #373 20843198
    p.kaczmarek2
    Moderator Smart Home
    Is your problematic router using 2.4GHz WiFi? 5G is not supported on that kind of chips. Same goes for Beken.
    Still, if there is that kind of message in log of the router, it's most likely not a 5G issue... maybe you have some kind of MAC filtering on?
    Helpful post? Buy me a coffee.
  • #374 20843549
    EricHughes
    Level 3  
    >>20835147

    Hello, thank you for your Answer:

    I have already used the linked tutorials as an application aid. The USB-> UART Device delivers an accurate 3.3 V output.

    - make sure you disconnect and RESET after flashing
    What do you mean exactly?

    - do not clear the whole device flash/do not use different flashing config because you might erase MAC and I don't know how to recover it on BL602 yet
    Where can I specify this? I used the BLDevCube flasher as recommended in the tutorial.
  • #375 20847687
    aradzh
    Level 2  
    >>20843198
    It is dual mode router. I try BL with 2.4 Wifi and no MAC filtering.
    Behavior is very strange since many devices work ok with this router with 2.4 Wifi: notebook, phone, ESP8266 with Tasmota.
    On the other hand BL works very smoothly with other routers (I checked one more router), no traces of strange behavior - everything works nicely: web interface, web application, MQTT.
    Probably, it could be connected that this Xiaomi router is with OpenWRT firmware not original one.
  • #376 20854502
    EricHughes
    Level 3  
    >>20843549

    Hello everyone,
    I'll get back to you again.

    In the meantime I have tried another USB->UART converter, no change. The flash process runs completely but no WLAN is displayed.

    I have also tried it on another Windows PC. Here I now get the following Error:
    {list index out of range}
    After File "core\bflb_iot_tool.py", line 1801, in flasher_download_thread

    Does anyone else have an idea?
  • ADVERTISEMENT
  • #377 20854521
    p.kaczmarek2
    Moderator Smart Home
    Hey, have you tried to reset the device after flashing, do a power off/on cycle? Are you powering it from good enough power supply? We've already had reports that AP was not appearing after flashing due to a weak power supply used.
    What does the log output say?
    Helpful post? Buy me a coffee.
  • #378 20855750
    EricHughes
    Level 3  
    Hey,

    >have you tried to reset the device after flashing, do a power off/on cycle?
    Of course, i've removed first the boot-connection, then the 3,3V power-connection an then pluged in 3,3V again. I also installed it in the previous envoroment with it's default power supply and the led-stripes.

    >Are you powering it from good enough power supply? We've already had reports that AP was not appearing after flashing due to a weak power supply used.
    See above.

    What does the log output say?
    I've posted the log in #365.
  • #379 20855958
    p.kaczmarek2
    Moderator Smart Home
    EricHughes wrote:

    What does the log output say?
    I've posted the log in #365.

    This is not the OpenBeken firmware/BL602 firmware log output. It's a log of the flasher tool. I've asked about the log output of BL602 during boot, so you need to connect USB to UART converter to RX/TX, open UART port in realterm, set baud (as far as I remember it's the same as the one used for flashing), then disconnect power, clear UART window, and reconnect power. You should see a boot log of BL602 along with later OBK messages in your UART window in realtime.

    I am asking for this log because it can at least tell us whether OBK firmware starts properly or not.
    Helpful post? Buy me a coffee.
  • #380 20882478
    minikuppler26
    Level 2  
    It seems like Homeassistant doesn't understand hex color codes. I can succesfully change the color of my rgbw controller with this template:
    
    mqtt:
      light:
      - unique_id: "Pascal_LED_Test"
        name: "Pascal_LED_Test"
        rgbw_command_template: "{{ '#%02x%02x%02x%02x00' | format(red, green, blue, white)}}"
    #   rgbw_value_template: "{{ value_json.Color }}"
        rgbw_state_topic: "cmnd/Pascal_LED_Test/led_basecolor_rgb"
        rgbw_command_topic: "cmnd/Pascal_LED_Test/led_basecolor_rgb"
        command_topic: "cmnd/Pascal_LED_Test/led_enableAll"
        availability_topic: "Pascal_LED_Test/connected"
        payload_on: 1
        payload_off: 0
        brightness_command_topic: "cmnd/Pascal_LED_Test/led_dimmer"
        brightness_scale: 100
        brightness_value_template: "{{ value_json.Dimmer }}"
        brightness_state_topic: "cmnd/Pascal_LED_Test/led_dimmer_get"
    

    But Homeassistant doesn't understand the response. From my LOG:
    
    2023-12-30 00:33:25.175 ERROR (MainThread) [homeassistant.util.logging] Exception in rgbw_received when handling msg on 'cmnd/Pascal_LED_Test/led_basecolor_rgb': '#10ff000000'
    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 44, in wrapper
        msg_callback(msg)
      File "/usr/src/homeassistant/homeassistant/components/mqtt/light/schema_basic.py", line 518, in rgbw_received
        rgbw = _rgbx_received(
               ^^^^^^^^^^^^^^^
      File "/usr/src/homeassistant/homeassistant/components/mqtt/light/schema_basic.py", line 480, in _rgbx_received
        color = tuple(int(val) for val in str(payload).split(","))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/src/homeassistant/homeassistant/components/mqtt/light/schema_basic.py", line 480, in <genexpr>
        color = tuple(int(val) for val in str(payload).split(","))
                      ^^^^^^^^
    ValueError: invalid literal for int() with base 10: '#10ff000000'
    

    I figured I can use rgb_value_template or in my case rgbw_value_template to parse the color like the rgbw_command_template but I don't get it right. Can someone help?

    Hinzugefügt nach 1 [Stunden] 39 [Minuten]:

    I found a template that should work:
    
    rgb_value_template: "{{ value[0:2]|int(base=16) }},{{ value[2:4]|int(base=16) }},{{ value[4:6]|int(base=16) }}"
    

    But now I get this error in the logs:
    
    2023-12-30 02:18:08.960 ERROR (MainThread) [homeassistant.util.logging] Exception in rgb_received when handling msg on 'cmnd/Pascal_LED_Test/led_basecolor_rgb': '#00ff000000'
    Traceback (most recent call last):
      File "/usr/src/homeassistant/homeassistant/components/mqtt/debug_info.py", line 44, in wrapper
        msg_callback(msg)
      File "/usr/src/homeassistant/homeassistant/components/mqtt/light/schema_basic.py", line 504, in rgb_received
        rgb = _rgbx_received(
              ^^^^^^^^^^^^^^^
      File "/usr/src/homeassistant/homeassistant/components/mqtt/light/schema_basic.py", line 472, in _rgbx_received
        payload = self._value_templates[template](
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/src/homeassistant/homeassistant/components/mqtt/models.py", line 251, in async_render_with_possible_json_value
        rendered_payload = self._value_template.async_render_with_possible_json_value(
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 735, in async_render_with_possible_json_value
        return _render_with_context(self.template, compiled, **variables).strip()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2179, in _render_with_context
        return template.render(**kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
        self.environment.handle_exception()
      File "/usr/local/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
        raise rewrite_traceback_stack(source=source)
      File "<template>", line 1, in top-level template code
      File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1927, in forgiving_int_filter
        raise_no_default("int", value)
      File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1609, in raise_no_default
        raise ValueError(
    ValueError: Template error: int got invalid input '#0' when rendering template '{{ value[0:2]|int(base=16) }},{{ value[2:4]|int(base=16) }},{{ value[4:6]|int(base=16) }}' but no default was specified
    

    It seems like the leading # didn't get removed

    Hinzugefügt nach 1 [Stunden] 36 [Minuten]:

    I found out how its done, now everything works.
    My manual config in configuration.yaml is now:
    mqtt:
      light:
        - unique_id: "Pascal_LED_Test"
          name: "Pascal_LED_Test"
          rgb_command_template: "{{ '#%02x%02x%02x0000' | format(red, green, blue)}}"
          rgb_value_template: "{{ value[1:3]|int(base=16) }},{{ value[3:5]|int(base=16) }},{{ value[5:7]|int(base=16) }}"
          rgb_state_topic: "cmnd/Pascal_LED_Test/led_basecolor_rgb"
          rgb_command_topic: "cmnd/Pascal_LED_Test/led_basecolor_rgb"
          color_temp_command_topic: "cmnd/Pascal_LED_Test/led_temperature"
          color_temp_state_topic: "Pascal_LED_Test/led_temperature/get"
          command_topic: "cmnd/Pascal_LED_Test/led_enableAll"
          availability_topic: "Pascal_LED_Test/connected"
          payload_on: 1
          payload_off: 0
          brightness_command_topic: "cmnd/Pascal_LED_Test/led_dimmer"
          brightness_scale: 100
          brightness_value_template: "{{ value_json.Dimmer }}"
          brightness_state_topic: "cmnd/Pascal_LED_Test/led_dimmer_get"
    
  • #381 20882647
    p.kaczmarek2
    Moderator Smart Home
    @minikuppler26 why are you using manual Yaml approach instead of HASS Discovery?


    Helpful post? Buy me a coffee.
  • #382 20882997
    minikuppler26
    Level 2  
    HASS Discovery didn't work. But I can try again later

    Hinzugefügt nach 3 [Stunden] 59 [Minuten]:

    OK now HASS discovery worked. I think the difference was, that I set the GPIO Pin for warm white to Channel 4, not 3 and I enabled flag 24
  • #383 20892866
    davidcpurdy
    Level 7  
    Slightly different subject here now; I may actually post a teardown of the Sonoff S40 too keep things from becoming buried or hard to find.

    Has anyone found a way to get the Sonoff S40 (BL602) which has been flashed w/ OpenBeken to correctly access and display power usage via the CSE7766? I know there was some preliminary work down, and even a few commits over the last few weeks, regarding the CSE7766. It would be a useful feature to enable.

    I have an unused S40 flashed w/ latest OpenBL602 firmware [OTA is easy] (and some time over the next week)... and would be willing to test/experiment.
  • #384 20893673
    p.kaczmarek2
    Moderator Smart Home
    Sure, that's great idea, any detailed teardown and guide is welcome here! Please do.

    Hmmm, I think that CSE7766 driver may be ready, but the UART link is not tested. I don't hava this device on site, so it's hard for me to work on that. Still, you may be able to get that working easily, only a very basic C experience may be helpful. You will not have to write new code for that, just double check UART config.
    Helpful post? Buy me a coffee.
  • #385 20919273
    p.kaczmarek2
    Moderator Smart Home
    This topic is very long.
    I have split the discussion about B02-BL-A60 CW CCT bulb to separate thread: https://www.elektroda.com/rtvforum/topic4029987.html
    Helpful post? Buy me a coffee.
  • #386 20928839
    gianniveloce
    Level 2  
    winux22 wrote:
    Hello i flashed OpenBL602_1.12.8.bin on a Sonoff MiniR3 as described above.
    Flash was successful but the device does not boot after opening the boot-3,3V connection and power cycling.
    When i try to log in DevCube i get an error. Do i need a different Partition Table or Params?
    The Chip is a BL602L20.
    Some Pics and flash logs are in the attachment.
    Cheers Winux


    Kudos Mate!

    Grace to your post I managed to flash my MiniR3 smoothly and then connected to Home Assistant.

    Best wishes

    GV
  • ADVERTISEMENT
  • #387 20945714
    derryck
    Level 2  
    Sucessfully flashed this RGBW MagicHome and it span up the portal on 192.168.4.1. Had to use a network scanner to find its actual IP address so I could direct it to my LAN, where it has connected as 192.168.1.167. Here the fun starts, as although I can modify all the other settings, name, mqtt and so on, I cannot get it to change to a fixed IP address no matter what I try. And bizarrely, when I run the scanner again there is another IP that comes and goes with power to the device on 192.168.1.168, with no ports open.

    There's nothing in my router that could affect this.

    I'm stumped!
  • #388 20945743
    betinelu
    Level 10  
    I hope I understood your problem correctly. You enter with the computer (change the IP from the computer 192.168.4.15 you must be on the same network), connect with a browser on 192.168.4.1 (not Firwefox) and in the settings that appear change to the WiFi menu and write there the WiFi name and the password of your network Basic. Then restart and change the IP on the computer to the original one or automatically. From that moment it will connect to your network, you don't have to change anything in the router.
  • #389 20946297
    derryck
    Level 2  
    Network settings screen showing IP configuration for WiFi client mode.

    The image shows what I'd like to happen. I click on Submit, a popup comes up to say that I must reboot, which I do. This time the module comes back online, but this time at 192.168.1.186 and not as I asked it to do. The setting is not "sticking".

    My note about the router was meant to divert questions about misconfiguration.
  • #390 20946384
    betinelu
    Level 10  
    Try (if you haven't done so) with another IP, maybe the router has blocked the address you want for another device. And don't restart the light bulb immediately, wait a bit to re-synchronize the router. I reserved the IP from the router based on the MAC, I didn't set the light bulb, and it worked immediately.

Topic summary

The discussion centers on a custom Tasmota-like firmware replacement for the BL602 platform by Bouffalo Lab, enabling integration with Home Assistant via MQTT. Key topics include flashing the firmware using USB to UART converters, SDK compilation, and device pairing. Users report successful flashing on MagicHome LED controllers (RGB, RGBW, single color) and Sonoff devices, with detailed guidance on GPIO pin identification and configuration for PWM and relay functions. MQTT integration supports commands for color, dimmer, hue, saturation, and device control, with ongoing improvements to MQTT topic naming, discovery, and feedback reporting. Challenges addressed include MQTT buffer limitations causing device instability, startup behavior with LED blinking, and the absence of OTA updates for BL602 (unlike Beken platforms). The firmware supports saving and restoring channel states, configurable MQTT reporting flags, and plans for Alexa Hue emulation. Users share troubleshooting steps for flashing errors, network connectivity, and device crashes, with developer responses including bug fixes, feature additions, and testing requests. The project emphasizes open-source collaboration, aiming to free IoT devices from manufacturer servers, enhance privacy, and unify multi-vendor ecosystems under a single firmware solution.
Summary generated by the language model.
ADVERTISEMENT