Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New PowerMeter Class for PowerLimiter #102

Closed
wants to merge 32 commits into from
Closed

New PowerMeter Class for PowerLimiter #102

wants to merge 32 commits into from

Conversation

Adminius
Copy link

PowerMeter Class extrahiert aus PowerLimiter
gibt Flexibilität bei der PowerMeter Auswahl (Aktuell MQTT oder SDM-Zähler, später HTTP/JSON?),

ToDos:
UI noch nicht vorhanden
Pin Auswahl in die UI integrieren
SDM Library evtl. doch direkt von GitHub laden und nicht integrieren?

Bernhard Kaszt and others added 24 commits January 3, 2023 22:39
Some values could not be deserialized and where null
…ments

* The voltage load correction factor now takes the voltage drop under load into account to not stop the producer too early already
* Fix powerlimiter interval not being set
* Set the power limit to the lowest value when the producer is stopped
* Other smaller improvements
If Victron support is enabled, the Dynamic Power Limiter will now directly pass
through all power coming from the Victron MPTT to the grid.
This is better for the battery, as it prevents the battery from being charged
unnecessarily. It also decreases unnecessary energy loses.
* Add translations for en and de for Powerlimiter & Battery admin settings
* Add SOC thresholds to Powerlimiter
@berni2288
Copy link

Hey @Adminius ,

thank you for the PR!
I suggest keeping our communication in English, so that we don't exclude people that don't speak German.

Should we wait until you have completed all Todos or do you already want to merge it?
I'll have a look at it when I have time.

@Adminius
Copy link
Author

let it stay open, so I can do some optimizations (I made it to show what I'm doing, so you can reuse or atleast review it)

What do you think about SDM Library? include oder exlude=get it from github source

@berni2288
Copy link

The SDM library seems to be listed in the PlatformIO registry: https://registry.platformio.org/libraries/reaper7/SDM
So you should be able to just add it as dependency in platformio.ini (lib_deps) by its name. If you add a specific version we should be safe from any future surprises by breaking changes in this lib.

@Adminius
Copy link
Author

Adminius commented Feb 14, 2023

so, now I need help with the UI.
I modified some vue files, compiled and uploaded to ESP32. but I don't see any changes?! should I upload it in different way?

Idea behind UI: new menu line: Power Meter Settings
1st card:
Enable Power Meter
Source/Type: MQTT/SDM 1ph/SDM 3ph

2nd card: (visible if Power Meter enabled only)
MQTT Settings: Input 3 topics, copy from power limiter (visible only if source=0)
SDM 1ph/3Ph Settings: Pins, Bitrate, ModBus Address (visible only if source=(1 or 2), not implemented yet

P.S. SDM Library needs some optimisations (reaper7/SDM_Energy_Meter#73), so it is not possible at the moment to get it directly from github

@berni2288
Copy link

rtfm 😜

Follow.the build instructions for the webapp in README.md.

@Adminius
Copy link
Author

I need help.
I've changed power meter UI, it switches visiblity between MQTT and SDM settings, but, as long I click on save, ESP reboots because of WatchDog. And can't find why...

22:31:56.863 > RX Period End
22:31:56.864 > Success
22:31:59.643 > Connecting to MQTT...
22:32:02.496 > E (122950) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
22:32:05.434 > E (122950) task_wdt:  - async_tcp (CPU 1)
22:32:05.434 > E (122950) task_wdt: Tasks currently running:
22:32:05.434 > E (122950) task_wdt: CPU 0: IDLE
22:32:05.434 > E (122950) task_wdt: CPU 1: IDLE
22:32:05.434 > E (122950) task_wdt: Aborting.
22:32:05.434 >
22:32:05.434 > abort() was called at PC 0x40116ee8 on core 0
22:32:05.434 >
22:32:05.434 >
22:32:05.434 > Backtrace: 0x400838d9:0x3ffbec3c |<-CORRUPTED
22:32:05.434 >
22:32:05.434 >   #0  0x400838d9:0x3ffbec3c in panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:402
22:32:05.434 >
22:32:05.434 >
22:32:05.434 >
22:32:05.434 >
22:32:05.434 > ELF file SHA256: 0ddb8ff687cd8e47
22:32:05.434 >
22:32:05.434 > E (14352) esp_core_dump_flash: Core dump flash config is corrupted! CRC=0x7bd5c66f instead of 0x0
22:32:05.436 > Rebooting...
22:32:05.436 > ets Jun  8 2016 00:22:57
22:32:05.436 >
22:32:05.436 > rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
22:32:05.436 > configsip: 0, SPIWP:0xee
22:32:05.436 > clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
22:32:05.436 > mode:DIO, clock div:2
22:32:05.436 > load:0x3fff0030,len:1184
22:32:05.436 > load:0x40078000,len:13104
22:32:05.436 > load:0x40080400,len:3036
22:32:05.436 > entry 0x400805e4
22:32:05.436 > E (588) esp_core_dump_flash: No core dum���ѥѥ���found!
22:32:05.436 > E (588) esp_core_dump_flash: No core dump partition found!
22:32:05.436 >
22:32:05.436 > Starting OpenDTU
22:32:05.436 > Initialize FS... done
22:32:05.436 > Reading configuration... done
22:32:05.436 > Initialize Network... done
22:32:05.436 > Setting Hostname... Configuring WiFi STA using new credentials... done
22:32:05.436 > Initialize NTP... done
22:32:05.436 > Initialize MqTT... done
22:32:05.436 > Initialize WebApi... done
22:32:05.436 > Check for default DTU serial... done
22:32:05.436 > Initialize Hoymiles interface... Connection successfull
22:32:05.436 >   Setting radio PA level...
22:32:05.436 >   Setting DTU serial...
22:32:05.436 >   Setting poll interval...
22:32:05.436 >   Adding inverter: 114184516317 - BKW done
22:32:05.436 > done
22:32:05.436 > Initialize ve.direct interface...
22:32:05.436 > done
22:32:05.436 > Switch to WiFi mode
22:32:05.436 > Setting Hostname... done
22:32:05.436 > Configuring WiFi STA using existing credentials... E (4160) wifi:Association refused temporarily, comeback time 1024 mSec
22:32:05.436 > E (4166) wifi:sta is connecting, return error
22:32:05.436 > [  1896][E][WiFiSTA.cpp:317] begin(): connect failed! 0x3007
22:32:05.436 > done
22:32:05.436 > Configuring WiFi STA DHCP IP... done
22:32:07.009 > WiFi disconnected
22:32:07.011 > Try reconnecting
22:32:07.011 > Network lost connection
22:32:08.113 > MODULE: VE.Frame
22:32:08.114 > ERROR: [CHECKSUM] Invalid frame
22:32:08.114 > Fetch inverter: 114184516317

Settings:
{"enabled":true,"source":2,"interval":10,"mqtt_topic_powermeter_1":"smartpi/P13","mqtt_topic_powermeter_2":"smartpi/P23","mqtt_topic_powermeter_3":"smartpi/P33","sdmbaudrate":9600,"sdmaddress":1}

@helgeerbe
Copy link
Collaborator

Hi @Adminius,

can you change the target for this PR to development. Hope that I have time tomorrow to review your code. I was actually searching for a nasty bug that crashes OpenDTU. But it seems I solved this.

@Adminius
Copy link
Author

Hi @helgeerbe I had no time yesterday.
but what I've already found:
I call PowerMeter.init() when saving settings.

  1. thing is not working well ist SDM.init(), because of reinitialisation of UART. Ok, it can be handled another way.
  2. the second thing, most dangerous is MQTT... if I'm switching from MQTT to SDM, I have to unsubscribe from topics, but it does'n work well/at all. I have to finde a solution for it...

@Adminius Adminius changed the base branch from powerlimiter to development February 26, 2023 21:37
@Adminius
Copy link
Author

I've tried to switch from hardware serial to software serial for SDM-library (I need one more HW Serial for BMS)
SDM uses 4800 or 9600 bps only, so slow enough for sw serial.
https://github.com/plerup/espsoftwareserial

It works perfect with arduino IDE... but can't compile with platofrm.io:

Linking .pio\build\generic\firmware.elf
.pio/build/generic/lib69c/libEspSoftwareSerial.a(SoftwareSerial.cpp.o): in function `std::function<void ()>::operator()() const':
c:\users\eugenius\.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\include\c++\8.4.0\bits/std_function.h:686:(.iram1.66[_ZNK8delegate6detail12DelegateImplIPvvEclEv]+0x24): dangerous relocation: l32r: literal placed after use: .literal._ZNK8delegate6detail12DelegateImplIPvvEclEv
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\generic\firmware.elf] Error 1

it looks like platform.io don't like esp32 framework 🤣

@helgeerbe
Copy link
Collaborator

helgeerbe commented Feb 28, 2023

Is there a reason, why you use this lib?

https://github.com/plerup/espsoftwareserial

image

@Adminius
Copy link
Author

I need four UARTs:

  • Debug/USB-Serial
  • Victron MPPT 19.200 bps
  • SDM power meter (9.600 bps only) <- SW Serial
  • BMS <- up to 115.200 bps

There not much more SW serial libs... and SMD lib can out of the box use SW-Serial lib.

@Adminius
Copy link
Author

See new PR #140

@Adminius Adminius closed this Mar 21, 2023
Copy link

github-actions bot commented Apr 7, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion or issue for related concerns.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants