-
Notifications
You must be signed in to change notification settings - Fork 67
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
Feature: VE.Direct: Support for a second MPPT tracker #706
Feature: VE.Direct: Support for a second MPPT tracker #706
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does look promising, thanks for your efforts! 💪 There are more things that I don't like, but they are rooted in the existing design and not something that must be tackled to make this feature fly.
How did you make sure that the live view can handle only one set of details being present? How did you make sure that the websocket pushes the one updated or all data sets if any of the data sets was updated? |
On the backend side I updated the data structure In |
Yeah, and it looks okay. I think that How do you feel about generating one card for each controller with its own data age and data_critical attributes, rather than trying to account for all controllers in a "container" card? This way one could better identify issues if there are any with a single MPPT controller. There is one drawback of using getData() with all indices: Most people have only one MPPT and they will see an error message that index 1 is out of bounds. I think we should instead be able to iterate over all controllers (in the websocket implementation, the MQTT handler, and the HASS handler). That means the controller must be managed by a shared_ptr rather than a unique_ptr and we shall give access to the controllers through a const container with const shared_ptr. I think that would solve many issues and would be a cleaner design. This is very good work and it will find its way into the project for sure! Me, personally, I am interested in this as well, as I am planning on adding another Victron MPPT to my setup this year. Please don't be discouraged by me giving even more feedback. What do you think must be addressed even before this can be merged? I can test the Home Assistent integration, once I figure out how to fake one or both controllers. Does the web live view work well and as before if only one MPPT is configured? |
No worries! As C++ is not my main language and I can only work on pet projects in my free time after work, it might just take a moment longer until I'd call s.th. finished. So thank you for your patience :-) |
About faking victrons: I'm currently using two USB-TTL uart adapter on a rpi directly connected to a ESP32 as well as this emulator . Works great as mock setup. |
Not sure if it's a helping comment, but I already use 2 100/20 on a single ESP with one RX wire per MPPT. https://github.com/KinDR007/VictronMPPT-ESPHOME Not sure how difficult it is to get a free pin for this in the project 🤷♂️ @Gumbagubanga and @schlimmchen I really appreciate your work 👍👍👍 |
I did some changes on that. ATM I'd say it's a patch and not a solution by individually checking on the validity of the data.
I'm not sure about the change towards two cards as this doubles the DPL indicator.
Publishing the vector of
The switch to a shared_ptr I get. But I lack the imagination/C++ know-how for the const-container. Can you give me some more details? I believe the shared_ptr on the container is there for memory-management reasons!? Overall I looked over the code several times this week and I got the feeling that the VictronMppt class is here to encapsulate the handling of the controllers and not exposing them to the outside (i.e. MQTT, HASS, WS-Live-View). Would the container not archive the contrary?
On the one hand I want to tackle this issue but on the on the other hand I see the holistic solution not part of this PR. So warnings will be the solution here. |
Thanks @rs3hc for the link to this project. 👍 Actually OpenDTUonBattery does have all the code to access multiple Victron MPPTs. |
Hello @Gumbagubanga, Does this feature have an impact on the inverter control or is the data from the second MPPT just displayed? |
You are probably asking about solar passthrough. Yes, solar passthrough will then consider the output of both Victron MPPT charge controllers.
Good point. The DPL desperately needs its own card. Let's not postpone it any longer. The card will be very small at the start, but let's get it done. We can then add more values to it later. Then we are free to produce as many VE.Direct cards as we please. I can tackle this. Let's do it after this is merged, so be don't cause trouble rebasing your work. It's acceptable that the second card duplicates the DPL state for some time. |
Currently DPL won't work, if in a two MPPT scenario one of them is returning invalid data. Should I change implementation of |
Only if you take care that the methods iterating the controllers always check their respective "isDataValid()" methods and only use their values if the data is valid. Example: Total solar power is requested. Iterate all controllers. Only add values of controller with valid data, otherwise the calculated solar power will use outdated data, which might be too high. We might also need to check if isDataValid() really returns false after a while when breaking the connection to a charge controller. AFAIK if the data is stale, it is valid forever. That should not be the case. This changeset is becoming quite large. You are putting a lot of work into it, which is great, but the changes are becoming very substantial and hard to review. Also, I would like to start testing this and planned to merge this soon. What else do you plan to do before we can attempt a merge and release? |
I think the hardest parts have been tackled to get a stable 2 MPPT setup running. Unless you recommend improving on particular aspects, I'd say "let the testing begin". Following issues can be handled by new PRs:
|
I want to share few thoughts about “How to merge the data from the 2 MPPTs” Clear on total power. Just adding the two values. But what happens to the other values used for regulation? The MPPT voltage can be used for the inverter switch-off threshold and for the solar passthrough mode. Which of the two values do you take? The smaller voltage? The greater voltage? Average? That's why I propose a simple transparent solution. The voltage from the MPPT which is connected to serial port 1 is always used for the “battery voltage”. The installer can then use the MPPT that is best for them just by VE.Direct wiring to serial port 1. Apart from the MPPT power and the MPPT voltage, are there any other parameters that are used for regulation/controlling? |
@Gumbagubanga or @schlimmchen |
It's the minimum voltage.
It's |
Hello @schlimmchen , |
0cbdb44
to
4bc565f
Compare
this change adds support for a second Victron MPPT charge controller using a second serial connection. * Add device configuration for a second victron mppt * Update VedirectView for second victron mppt * Update MqttHandleVedirect for second victron mppt * Update MqttHandleVedirectHass for second victron mppt * Handle nonexisting victron controllers with optionals * Add bool-function to Battery and inherited classes, if uart port 2 is being used * Introduced a serial port manager. In order to prevent the battery and the Victron MPPT to use the same hw serial ports, this class keeps track of the used ports and their owners.
* fix compiler warning in SerialPortManager.cpp: function must not return void * clean up and simplify implementation of usesHwPort2() * make const * overrides are final * default implementation returns false * implement in header, as the implementation is very simple * rename PortManager to SerialPortManager. as "PortManager" is too generic, the static instance of the serial port manager is renamed to "SerialPortManager". the class is therefore renamed to SerialPortManagerClass, which is in line with other (static) classes withing OpenDTU(-OnBattery). * implement separate data ages for MPPT charge controllers * make sure MPPT data and live data time out * do not use invalid data of MPPT controlers for calculations * add :key binding to v-for iterating over MPPT instances
4bc565f
to
c584184
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Sorry für die evtl blöde Frage. Welchen Pin nutzt ihr für den zweiten MPPT/VE.Direct Eingang? Liebe Grüße aus Sachsen 👍 |
Ja, naja... Die Frage ist so mittelmäßig qualifiziert 😁 Es eignet sich jeder Pin. Einschränkungen gibt es nur insofern, als dass manche ESP32 Pins "Input only" sind. Da du aber einen Pin als Input brauchst, ist es tatsächlich egal. Es muss natürlich ein freier GPIO sein, das ist klar. Und nochmal die Erinnerung: Du solltest galvanisch trennen, z.B. mit einem ADUM1201. Zu diesem Thema findest du reichlich Infos im Netzs oder in den Diskussionen hier. |
Ja ist schon gut mit der Kritik 😁 Ich versuche nur dem Alex Seufert bei seinem Board zu unterstützen. (https://www.akkudoktor.net/forum/migrated-forums-balkonsolar/opendtu-on-battery-platine-mit-maximal-ausbau-dc-dc-und-jk-bms-stecker/paged/3/) Mit ESP habe ich nur einfache Bastelkenntnisse, spätestens beim Thema UART bin ich fachlich raus. Kurz und Knapp. Ich: Nachbar: Danke für eure Arbeit 👍 |
Nur mit ESP32-S3 (wie auf OpenDTU-Fusion Board) und nur mit weiterer (von mir geplanter) Unterstützung in Software, denn du brauchst ja 3 UARTs. Der S3 hat drei zur Verfügung (weil die "Konsole" über USB direkt angehängt ist), aber das muss alles erst noch nutzbar gemacht werden. Ohne einen ESP32 mit 3 UARTs geht es erst, wenn auch die Unterstützung für ein SoftwareSerial drin ist.
Für eine Pylontech an RS485 gibt es soweit ich weiß keine Softwareunterstützung. Und wenn du CAN nimmst, kollidiert das soweit ich mich erinnere mit dem CMT2300A SPI? Bin mir nicht sicher... |
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. |
Picking up the work of @schlimmchen in #505 and #516 I tried to implement the support for a second MPPT tracker.
Changes:
Notes: