diy solar

diy solar

JK-BMS-CAN with new Cut-Off Charging Logic (open-source)

I have my own DNS Server running so the DNS Record is correctly resolving to the IP Address (Static Lease on the DHCP Server) of the ESP32.

The problem is that the upload never goes past 10%. Sometimes it fails at 4%. Sometimes it gives up just after starting the upload process.

I also tries to restart the ESP32 in Safe Mode prior to OTA. Nothing :rolleyes: . The only thing that wants to work is a reliable USB cable :rolleyes:.

Can you post your ota config and if using BLE Version also the on_boot part please
 
I have my own DNS Server running so the DNS Record is correctly resolving to the IP Address (Static Lease on the DHCP Server) of the ESP32.

The problem is that the upload never goes past 10%. Sometimes it fails at 4%. Sometimes it gives up just after starting the upload process.

I also tries to restart the ESP32 in Safe Mode prior to OTA. Nothing :rolleyes: . The only thing that wants to work is a reliable USB cable :rolleyes:.

Try to ping the atom and look for potential time outs, or perhaps install esphome on a different computer, and try with a host file ( but yes DNS resolve should be equally good ). Many moving parts here. 😵‍💫
 
Wonder if part of my problem is related to my BMS being a CAN/heat model, and maybe had the RS485 deactivated? Or was assigned different GPIO's as such?

Has anyone been able to get cable working with HW v11.XA / SW v11.43?
 
Wonder if part of my problem is related to my BMS being a CAN/heat model, and maybe had the RS485 deactivated? Or was assigned different GPIO's as such?

Has anyone been able to get cable working with HW v11.XA / SW v11.43?
No 11.43 will not response to request data command as I have mentioned (my version 11.36, 11.42 does not work on wired connection anymore, the "4E:57:00:13:00:00:00:00:06:02:00:00:00:00:00:00:68:00:00:01:28" command does not work! I have not upgraded to V15 as guided by JK-BMS guy as I have not seen any guidance on that and not sure the V15 is supported the upgrading from V11. The only way that seems possible is to use Bluetooth for multiple BMS (my previous pose has the link but I have not tried yet)
 
Try to ping the atom and look for potential time outs, or perhaps install esphome on a different computer, and try with a host file ( but yes DNS resolve should be equally good ). Many moving parts here. 😵‍💫
Tried on several computers. Ping works. Host file tried previously to no avail...
 
A bit side topic but ... How do you manage to get OTA working ?

I tried several approaches and none works so far :(

a. Using esphome run XXX.yaml -> This results in timeout failure during upload or similar other messages.
GitHub Issues and Home Assistant Forums seem to point to a Network Issue.
I am running this off a Rock 5B using hostapd and an Alpha AWUS1900 USB-Wifi Adapter (RTL8814AU).

b. Running esphome dashboard in a Podman Container (similar to Docker) doesn't really work.
I cannot do anything since autodiscovery doesn't work. If I add devices manually, there really isn't a "Firmware Upload" button or something similar.

c. Running esphome integration for Home Assistant I can see entities etc, but I cannot upload a new firmware.

Make sure your code uses the ota declaration in the main yaml like so.
Code:
logger:
  level: ERROR

ota:

then run these commands one after the other in the terminal.
Code:
esphome compile .\jk-hybrid-can.yaml

esphome upload .\esp32_hybrid_jk-bms-can.yaml --device 192.168.1.113

substitute Local IP and filename as usual.
d. Web Server does NOT support OTA on esp-idf framework (only on Arduino) according to documentation.
We are using esp-idf framework here ...
This is different with the main OTA capability mentioned earlier.
with esp-idf, the web-server will not allow uploading OTA binaries. That's all.
 
Can you post your ota config and if using BLE Version also the on_boot part please

I have the problem on several (all) projects.

===================================================================

For my modified @Sleeper85 code.

The ota part:
YAML:
ota:
  safe_mode: true
  version: 1
  password: !secret ota_password
  on_begin:
    then:
      - lambda: id(enable_bluetooth_connection).turn_off();
      - logger.log: "BLE shutdown for flashing"

The on_boot part is stock @Sleeper85:
YAML:
esphome:
  name: ${name}
  platformio_options:
    board_build.flash_mode: dio
    build_flags:
      - -DCONFIG_ARDUINO_LOOP_STACK_SIZE=32768
  comment: ${device_description}
  project:
    name: !secret project_name
    version: !secret project_version
  on_boot:
    then:
      - switch.turn_on: can_switch_charging
      - switch.turn_on: can_switch_discharging
      - switch.turn_on: can_switch_float
      - switch.turn_on: can_switch_auto_charge_current
      - switch.turn_on: can_switch_auto_discharge_current
      - switch.turn_on: can_switch_auto_charge_voltage

Full YAML file: https://github.com/luckylinux/jk-bm...main/esphome-jk-bms-can/esp32-ble-1.17.5.yaml
Secrets (example) file: https://github.com/luckylinux/jk-bms-build-helpers/blob/main/secrets.sh.example

===================================================================

For my forked esphome-for-deye which I adapted (work in progress) in a more modular approach and supporting many more RS485 registers (also off-grid ones) compared to the original.

The ota part:
YAML:
ota:
  safe_mode: true
  version: 1
  password: !secret ota_password

BLE is not used (but maybe still turned on ?). Unsure ...


Full YAML file: https://github.com/luckylinux/esphome-for-deye/blob/main/esphome-config-common.yaml
Secrets (example) file: https://github.com/luckylinux/esphome-for-deye/blob/main/secrets.sh.example


===================================================================

Now that i upgraded ESPHome using pip, another thing could be to try "version: 2" in the "ota" section.
From what is written on ESPHome OTA component, the version 2 should be more stable (previously the "version" declaration was not supported, so I assume it was using "version 1").

Anyway, it would NOT let me upgrade the ESP32 devices using the default OTA "version: 2", so I had to use "version: 1" for the (unsuccessfull) upgrade.

Now I could in theory switch to "version: 2" though ...
 
Make sure your code uses the ota declaration in the main yaml like so.
Code:
logger:
  level: ERROR

ota:

then run these commands one after the other in the terminal.
Code:
esphome compile .\jk-hybrid-can.yaml

esphome upload .\esp32_hybrid_jk-bms-can.yaml --device 192.168.1.113

substitute Local IP and filename as usual.

This is different with the main OTA capability mentioned earlier.
with esp-idf, the web-server will not allow uploading OTA binaries. That's all.
I have

Code:
logger:
  hardware_uart: USB_SERIAL_JTAG
#  level: DEBUG # For Debugging only
  level: INFO # For Production
 
  ota:
  safe_mode: true
  version: 1
  password: !secret ota_password
  on_begin:
    then:
      - lambda: id(enable_bluetooth_connection).turn_off();
      - logger.log: "BLE shutdown for flashing"

And I simply do
Code:
esphome run ./esp32-ble-1.17.5.yaml

Why would it me propose ota flashing if that command isn't supposed to handle it ?
 
OTA Version 2 also just failed ...
I just opened a GitHub Issue on the ESPHome Issue Tracker:

I do NOT have high hopes that it will be resolved quickly though.

I'll try to see if I can get any of the custom web server libraries (several are available on GitHub that work with esp-idf framework without needing the Arduino one) that support OTA (and possibly also HTTPS).

I might also wonder if this is a low-RAM issue, since the Atom S3 Lite does NOT have integrated/external PSRAM (typically 2-8 MB) but only 320 kB usable (although should be 520 kB total according to Wikipedia).

Is anybody here using the Atom S3 Lite WITH OTA working correctly ? Or are those who managed to get OTA working using ESP32/ESP32-S3 MODULES which have far more (PS)RAM and Potentially Flash ?

If I recall correctly also @chaosnature had issues with OTA on the Atom S3 Lite ...

Not sure if it's a requirement also to set up a custom Partition Layout for ESPHome to handle OTA correctly ...
 
I might also wonder if this is a low-RAM issue, since the Atom S3 Lite does NOT have integrated/external PSRAM (typically 2-8 MB) but only 320 kB usable (although should be 520 kB total according to Wikipedia).
I have the cheapest ESP32 Dev boards and even they handle OTA perfectly fine.
This is not the issue.

This is the output on my windows PowerShell.

Code:
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 (5.4.0) > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)

it even shows estimates for RAM and FLASH consumption for the compiled binary.

Code:
Compiling .pioenvs\shvm-jk\src\main.o
Linking .pioenvs\shvm-jk\firmware.elf
Retrieving maximum program size .pioenvs\shvm-jk\firmware.elf
Checking size .pioenvs\shvm-jk\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  17.6% (used 57548 bytes from 327680 bytes)
Flash: [========  ]  75.8% (used 1390949 bytes from 1835008 bytes)
Building .pioenvs\shvm-jk\firmware.bin
esptool.py v4.4
Creating esp32 image...
Merged 26 ELF sections
Successfully created esp32 image.
esp32_create_combined_bin([".pioenvs\shvm-jk\firmware.bin"], [".pioenvs\shvm-jk\firmware.elf"])
esptool.py v4.7.0
Wrote 0x165200 bytes to file D:\Desktop\JKcan\.esphome\build\shvm-jk\.pioenvs\shvm-jk/firmware-factory.bin, ready to flash to offset 0x0
 
I have the cheapest ESP32 Dev boards and even they handle OTA perfectly fine.
This is not the issue.

This is the output on my windows PowerShell.

Code:
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 (5.4.0) > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)

it even shows estimates for RAM and FLASH consumption for the compiled binary.

Code:
Compiling .pioenvs\shvm-jk\src\main.o
Linking .pioenvs\shvm-jk\firmware.elf
Retrieving maximum program size .pioenvs\shvm-jk\firmware.elf
Checking size .pioenvs\shvm-jk\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  17.6% (used 57548 bytes from 327680 bytes)
Flash: [========  ]  75.8% (used 1390949 bytes from 1835008 bytes)
Building .pioenvs\shvm-jk\firmware.bin
esptool.py v4.4
Creating esp32 image...
Merged 26 ELF sections
Successfully created esp32 image.
esp32_create_combined_bin([".pioenvs\shvm-jk\firmware.bin"], [".pioenvs\shvm-jk\firmware.elf"])
esptool.py v4.7.0
Wrote 0x165200 bytes to file D:\Desktop\JKcan\.esphome\build\shvm-jk\.pioenvs\shvm-jk/firmware-factory.bin, ready to flash to offset 0x0
I ran out of Atom S3 Lite and will need to order some extra to try to replicate.

In the meantime I'll try another ESP32-S3 dev board (module this time) on a Raspberry Pi using dnsmasq + hostapd with the same Alfa AWUS1900 USB-Wifi Adapter (RTL8814AU) in AP mode.

It might be that the whole ESP32-S3 (note the "S3" part) is not working, but the "standard" ESP32 is working fine.
 
This is what happens with an ESP32-S3 module.
Not sure if I have been scammed on Aliexpress ?

I am getting panics all over the place ...
 

Attachments

  • esp32-s3_module_usb_flashing.txt
    49.5 KB · Views: 8
Is the ATOM Lite ESP32 still compatible? Thinking of reflashing the most current version and trying it out again with my EG4 6000xp.
 
Is the ATOM Lite ESP32 still compatible? Thinking of reflashing the most current version and trying it out again with my EG4 6000xp.
Do you mean the ESP32 or ESP32 S3 ?


vs


Maybe the only option is to have all of these devices PERMANENTLY connected to a USB hub and a Raspberry or something.

That way if you need to flash you can do it through a "proxy" :rolleyes: .
 
I run several esp32s2lolin and have no problem with OTA until now:
OTA:
- port: 8266

Instead of using dhcp, I set manual Ip or bind ip to mac at router so the esp32 will always have fix address.
I used 'use_address: ip_address_of_mydevice
>> all working fine.
I run tens of esp32lolin in ten remote areas with NAT set up for port 8266 in remote site. Sometime i have more device, i used different OTA ports. Remote device use mqtt for updating information to my HA server.
In most of the case I believe the resolving of device ip address have problem, so better make it fix!
 
I run several esp32s2lolin and have no problem with OTA until now:
OTA:
- port: 8266

Instead of using dhcp, I set manual Ip or bind ip to mac at router so the esp32 will always have fix address.
I used 'use_address: ip_address_of_mydevice
>> all working fine.
I run tens of esp32lolin in ten remote areas with NAT set up for port 8266 in remote site. Sometime i have more device, i used different OTA ports. Remote device use mqtt for updating information to my HA server.
In most of the case I believe the resolving of device ip address have problem, so better make it fix!
I have no problems resolving or pinging the device. The problem must be elsewhere ...
 
Do you mean the ESP32 or ESP32 S3 ?


vs


Maybe the only option is to have all of these devices PERMANENTLY connected to a USB hub and a Raspberry or something.

That way if you need to flash you can do it through a "proxy" :rolleyes: .
I have Atom Lite (not S). Also I only flash with USB. So is there a problem with the non-S version?
 
Back
Top