logo elektroda
logo elektroda
X
logo elektroda

How to flash LN882H with open source Tasmota/Esphome style firmware - backup procedure included

p.kaczmarek2 42051 297
ADVERTISEMENT
  • #91 21018952
    divadiow
    Level 34  
    note that if you update a LN device to latest commit https://github.com/openshwprojects/OpenBK7231T_App/pull/1143 (Build on Mar 25 2024 12:49:16 version LN882H_1143_merge_b068861648fb) and you have powersave 1 set, the device will not connect to wifi but will need to be put into safe mode so you can switch to powersave 0.

    That was my experience just now anyway. I don't have an LN connected to uart to see boot log at the mo

    Added after 15 [minutes]:

    behaviour confirmed on two different devices. LN-02 switch and unmarked candle bulb module
  • ADVERTISEMENT
  • #92 21021475
    divadiow
    Level 34  
    anyone else tried this PR with powersave 1?
  • #93 21021572
    rufus4
    Level 10  
    Hi everyone,
    may I ask some beginners questions?

    Yesterday I did flash a LN822H on the WL2S (blue pcb), part of the ELIVCO LSPA9. It worked so far without any problems.
    (btw at the moment you can get three of these units for €10 on ali)

    After playing arround with some settings I cant reach the userinterface anymore. Device does not show up on AP or the homenetwork.
    Reflashing is possible, but it does not clear the settings. Is there a way to clear settings over the flash-tool or any other way than wifi?
  • #94 21021637
    divadiow
    Level 34  
    rufus4 wrote:
    After playing arround with some settings I cant reach the userinterface anymore. Device does not show up on AP or the homenetwork.
    Reflashing is possible, but it does not clear the settings. Is there a way to clear settings over the flash-tool or any other way than wifi?


    Not sure I've had this with any LNs, but if the RF stuff gets messed up on Beken I've had to reflash factory firmware then re-OBK again. Might be something to try on LN?
  • #95 21021640
    miegapele
    Level 15  
    You can just power on and off 5 times with short pause in between and it will come up in safe mode and create ap, the same as after initial setup. Then you can clean the settings
  • ADVERTISEMENT
  • #97 21021655
    rufus4
    Level 10  
    thanks a lot for your hints!
    I´ll try.

    I think this happend when I did set Channel to remember state with "-1". Is there any problem with this setting? for me it looks like it messed all up.
  • #98 21021656
    divadiow
    Level 34  
    miegapele wrote:
    You can just power on and off 5 times with short pause in between and it will come up in safe mode and create ap, the same as after initial setup. Then you can clean the settings


    yes. it should just go into safe mode tho, which will ignore the -1 set, surely?
  • #99 21021687
    rufus4
    Level 10  
    when I checked for mac I could not acess datas "Fail. Could not go in ramcode mode."
    then I did erase flash and it was possibly again to ask for mac "mac:ff:ff:ff:ff:ff:ff"
    then reflashed, entered in ap mode and configured network settings, reboot, but still no acess from homenetwork, again not possible to ask for mac!

    I`ll try to reflash original fw

    --update---

    reflashing original fw did help at least to connect the device again on homenetwork
    thanks again!

    Added after 2 [hours] 19 [minutes]:

    One more question about understanding the hole materia.

    Why is my dump file from the HL882KHI 4MB? Docs say that this chip has got 2MB Flash. LN882H series comparison diagram showing memory and pin designation.
  • ADVERTISEMENT
  • #100 21021878
    divadiow
    Level 34  
    rufus4 wrote:
    reflashing original fw did help at least to connect the device again on homenetwork
    thanks again!


    excellent

    rufus4 wrote:
    Why is my dump file from the HL882KHI 4MB? Docs say that this chip has got 2MB Flash


    https://www.elektroda.com/rtvforum/topic4008545-150.html#20935788

    tbh I thought the .py file had been updated wherever it can be downloaded from

    Added after 2 [minutes]:

    divadiow wrote:
    Not sure I've had this with any LNs, but if the RF stuff gets messed up on Beken I've had to reflash factory firmware then re-OBK again. Might be something to try on LN?


    actually I have https://www.elektroda.com/rtvforum/topic4008545-90.html#20914464
  • #101 21022078
    max4elektroda
    Level 20  
    divadiow wrote:
    anyone else tried this PR with powersave 1?

    Finally I did. And with "strange" results:

    Changing "startup command" to set "PowerSave 1" and restart, device will connect to WiFi, log will dispaly " ... POWERSAVE", but current used is unchanged at ~ 90mA.

    BUT: If I set "PowerSave 1" from the "Command Tool", the current drops to ~ 55mA !!!

    So for me, setting Powersave doesn't work as startup command - but it does as a command.
  • #103 21022086
    max4elektroda
    Level 20  
    But this is just tested on my bare module, not the one in a plug, which would need to "count energy interrupts".
    And: GUI is very slow now.
  • #105 21022109
    max4elektroda
    Level 20  
    Since WiFi did work, I also tried on my plug:
    Seems to work quite o.k., the energy values shonw are reasonable and, best to say, after about 10 minutes the temperature is ~ 30°C, with a simple load of 25W !
    The bare module used to be around 35°C, not even inside a case, not to speak about realy, power converters ...

    Added after 7 [minutes]:

    Switched to "PowerSave 0", and one minute later temperature is well beyond 40° (over 45° just now).

    Added after 4 [minutes]:

    Switched back to PowerSave 1 at 47.8°
    After 3 minutes, temperature is 37.2°

    Added after 6 [minutes]:

    But it is really very slow (toggling switch took me 10 seconds) and readings for BL0937 are not updated as it seems :-(

    Added after some more [minutes]:
    This might have been a problem on my client.
    Now it looks o.k. I see readings for BL0937 changing again and switching is o.k.
    Temperature around 35° - that really looks good for me now (no long term test though)
  • #106 21022157
    divadiow
    Level 34  
    p.kaczmarek2 wrote:
    typedef enum
    {
        ACTIVE          = 0,
        LIGHT_SLEEP     = 1,
        DEEP_SLEEP      = 2,
        FROZEN_SLEEP    = 3,
    } sleep_mode_t;


    Which of these corresponds to new powersave commands? What states are we entering?

    Added after 11 [minutes]:

    light sleep I guess

    https://github.com/openshwprojects/OpenBK7231...mits/e58abff715e43ebdf0a9c67daea143f273f2123c
  • #107 21022179
    max4elektroda
    Level 20  
    In cmd_main.c is:

    #elif defined(PLATFORM_LN882H)
    	if (bOn) {
    		sysparam_sta_powersave_update(WIFI_MAX_POWERSAVE);
    		wifi_sta_set_powersave(WIFI_MAX_POWERSAVE);
    	}
    	else {
    		sysparam_sta_powersave_update(WIFI_NO_POWERSAVE);
    		wifi_sta_set_powersave(WIFI_NO_POWERSAVE);
    	}
    #else


    Ahh, I just realized, we are talking about different things!
    Sorry, I tried with the release version, not the one from the PR.

    I hope I didn't misguide you with my posts.
  • #108 21022196
    divadiow
    Level 34  
    oh lol.

    im testing Build on Mar 25 2024 12:49:16 version LN882H_1143_merge_b068861648fb

    I have powersave 0 in startup command at the moment but have tried switching to powersave 1 in web app and ALSO see the temperature drop as well as the power consumption.

    This is the power consumption starting with powersave 0 with the 0.6-0.7w readings then powersave 1 with 0.3-0.5w readings from about 8s into the video





    but now I don't know where the PR fits into all this.

    Added after 9 [minutes]:

    i can't say im seeing a slow down with powersave 1 on the PR build though

    Added after 3 [minutes]:

    I'm just testing with this LN candle lamp. it was getting too hot with the bulb lit and it would reboot after a few minutes. temps were 80+ degrees C. see how long it lasts...

    Screenshot of the OpenLN882H_C25E1088 interface with controls for LED brightness and color temperature.

    Added after 54 [minutes]:

    bulb still on and online, which is a novelty. BP5758D_Current 1 1 set though so LEDs are LOW.

    Screenshot of a web application interface showing internal temperature and WiFi status.

    will try BP5758D_Current 5 5

    Added after 18 [minutes]:

    Too hot at 5 5, rebooted. Will try 3 3
  • #109 21022423
    p.kaczmarek2
    Moderator Smart Home
    That's a lot t process! Ok, here are two quick tips from my side:
    - BL0937 is known to work bad with powersave because BL0937 requires a change interrupt to work in order to count CF/CF1 pulses
    - if somehow PowerSave must be run later, you can use delay_s in script of waitFor to wait for WiFi state
    I'm eager to see more results!
    Helpful post? Buy me a coffee.
  • #110 21024816
    rufus4
    Level 10  
    I made an interesting discovery. Tried to measure the power consumption of the LSPA9 with LN822HKI and the BL0937, because I recocnised that its getting quiet hot.
    It looks like Tuya does not use any power save mode at all on this device with the WL2S board. And this is very interesting. (Or they just don`t care?)

    Measured with a DMM and a clamp meter the device's power with relays off and on.
    OpenLN882H_1.17.521 takes 8.5 and 12.5 mA
    original Tuya FW takes the same 8,5 and 12.5 mA (this is incredible 2/3Watts)

    OpenLN882H_1.17.521 with experimental "powersave 1" takes an average of 6.5 and 10.5 mA (but GUI is not stable, freezes after a while)

    For comparison, a shelly plug (16A) takes around 4/7mA which is only half of the Tuya firmware.

    (I know, my mesurement is not very accurate because of powerpeeks. But without powersave mode the consumption seems to be nearly constant.)

    p.kaczmarek2 wrote:
    - BL0937 is known to work bad with powersave because BL0937 requires a change interrupt to work in order to count CF/CF1 pulses

    maybe thats the point?
  • ADVERTISEMENT
  • #111 21026099
    rufus4
    Level 10  
    Is there a chance to get a DHT22 working on the LN882H?

    While setting the pins, I found all of this DHT's to choose on the list. So I thought I'll try and did solder one more pinout to pin 4 on the WL2S board and connected a DHT22.
    It looked like it got recognized and warned me to set two channels. But there are no values. Did I choose the wrong pin for that, do I need to start a driver or is there no such implementation in the FW?

    I know, maybe it's a bit too early for these thingies, but I love to fithering around with it and it would be nice to have temperature and humidity directly on a power plug to switch a dehumidifier. :)
    Device configuration screen with connected DHT22 sensor showing no temperature and humidity values.
  • #112 21026717
    p.kaczmarek2
    Moderator Smart Home
    rufus4 wrote:
    I
    Measured with a DMM and a clamp meter the device's power with relays off and on.
    OpenLN882H_1.17.521 takes 8.5 and 12.5 mA
    original Tuya FW takes the same 8,5 and 12.5 mA (this is incredible 2/3Watts)

    Thank you for those measurements! At least we know we're not making the power usage higher.

    rufus4 wrote:

    OpenLN882H_1.17.521 with experimental "powersave 1" takes an average of 6.5 and 10.5 mA (but GUI is not stable, freezes after a while)

    We will need to resolve that, but how... if anyone wants to help, check out our repository and give it a try.
    https://github.com/openshwprojects/OpenBK7231T_App

    rufus4 wrote:

    p.kaczmarek2 wrote:
    - BL0937 is known to work bad with powersave because BL0937 requires a change interrupt to work in order to count CF/CF1 pulses

    maybe thats the point?

    This is most likely the reason that no PowerSave is used on BL0937 devices.


    rufus4 wrote:
    Is there a chance to get a DHT22 working on the LN882H?

    rufus4 wrote:
    While setting the pins, I found all of this DHT's to choose on the list. So I thought I'll try and did solder one more pinout to pin 4 on the WL2S board and connected a DHT22.

    DHT sensors are handled per-pin:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/src/driver/drv_dht.c
    The DHT pin roles are listed here:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/ioRoles.md
    The DHT update, however, seems to be disabled for LN882H currently:
    Screenshot of Visual Studio editor with the user_main.c file open.
    Let me try checking this out. I will update LN882H makefile to include DHT driver and then add enable there.

    Added after 6 [minutes]:

    DHT step 1:
    https://github.com/openshwprojects/OpenLN882H/commit/0467665d75a879d3024f538a5d31c313f844fc16
    Now I will try to enable it in app...

    Added after 1 [hours]:

    I think i enabled it, it should work on LN882H with 1.17.527 build, but I am not able to test...
    https://github.com/openshwprojects/OpenBK7231...mmit/f27907593411632f7186e0e9e6ff4e572880cf0f
    I also later moved the define to the correct place:
    https://github.com/openshwprojects/OpenBK7231...mmit/d38957aee0cbcbb745a1975447024ce6d7f54b45
    It should be more obvious now how do we enable DHT on new platform.
    Helpful post? Buy me a coffee.
  • #113 21027619
    rufus4
    Level 10  
    First, I do have to say again that I'm a poor beginner and please for passion.
    And now one more question. Does the drivers start by themselves? DHT and NTP drivers I never have seen listed as working on the main GUI page.

    I think I made a mistake. I connected pin B4, but selected it as Pin 4.
    Which Pin number is B4 then on the list from 1-25?
  • #114 21027731
    max4elektroda
    Level 20  
    rufus4 wrote:
    Does the drivers start by themselves? DHT and NTP drivers I never have seen listed as working on the main GUI page.

    You will have to start the drivers on the "execute custom command" line:
    Its "startDriver <driver>" e.g.
    startDriver NTP
    to start NTP.

    Only BL0937 is an exception and starts automatically.
    Correction: DHT also has an autostart.

    Added after 9 [minutes]:

    Regarding the pins: in the gui you can select B4 directly.
    It will be mapped to pin 20 in the config file (A# pins are 0 to 15, so the pin B0 is 16 and so on).
  • #115 21027744
    p.kaczmarek2
    Moderator Smart Home
    @max4elektroda I think that DHT also has an autostart, it's actually handled outside drv array. Still, NTP has to be started as you shown.
    Helpful post? Buy me a coffee.
  • #116 21027834
    rufus4
    Level 10  
    Thanks a lot, finally I selected the right pin B4 now. Somehow it would have been too easy, open my eyes a bit wider only. :)

    But still DHT does not work in my case. And if I try to start the DHT driver manually, there is none on the list. Same with the newest build .530.
    --updated--
    Screenshot of a device control panel showing data related to a DHT22 sensor and other system parameters.


    max4elektroda wrote:
    to start NTP.

    Only BL0937 is an exception and starts automatically.


    does only start manually on my LN882H, but it works fine. How can I set a different NTP server IP? Couldn't find any information about that.
  • #117 21027880
    max4elektroda
    Level 20  
    rufus4 wrote:
    How can I set a different NTP server IP? Couldn't find any information about that.

    After starting the NTP driver, you can set the server with "ntp_setServer <IP>"
  • #118 21028284
    piotrret
    Level 12  
    Hello.
    I have a question about the NTP server.
    In the Startup command menu I have: startDriver ntp
    The problem is that the time after today`s time change is incorrect, so I also added: startDriver ntp; ntp_timeZoneOfs +2
    After this change, when I restarted the device, the NTP server no longer starts.
    I tried to create an autoexec.bat file to include these two commands, but the file was not created. Is the LittleFS mechanism implemented in the current version of OpenLN882H_1.17.524_OTA software?
  • #119 21028427
    p.kaczmarek2
    Moderator Smart Home
    @piotrret to enter more than one command in the short startup command should be used backlog : :
    
    backlog first command; second command etc; third
    

    Just like in Tasmota.
    Helpful post? Buy me a coffee.
  • #120 21028556
    piotrret
    Level 12  
    It works, thanks for the tip. I just wanted to ask about creating files, because, as I wrote earlier, I tried to create the autoexec.bat file, but after pressing the List Filesystem button, nothing appears, even though after using the Create File function, Screenshot of a filesystem interface showing the process of creating files and listing items in LittleFS. I have the message saving file...save complete...

Topic summary

The discussion focuses on flashing the LN882H module with open-source firmware such as Tasmota or ESPHome, detailing the necessary hardware setup, including the use of a USB to UART converter and a reliable 3.3V power supply. Users share experiences with various programming tools, troubleshooting flashing errors, and the importance of using the correct baud rate (115200) for successful firmware uploads. The conversation also touches on issues related to power consumption, the implementation of power-saving modes, and the challenges faced when trying to reset configurations or passwords in the firmware. Additionally, there are mentions of specific devices using the LN882H chip and the need for community support in resolving technical issues.
Summary generated by the language model.
ADVERTISEMENT