Closed aherzer69 closed 1 year ago
OK, so you need to read all the way up to 15*45 registers to get the battery soc. Your approach is correct, but I think you made a mistake here:
setcounter++;
if (setcounter==2) {
setcounter = 0;
Here, this code resets the setcounter to 0 after 1. Because I only needed to read 2 sets of 45 registers. So for you, you need to allow the code to count all the way up to 16 sets to reset.
setcounter++;
if (setcounter==16) {
setcounter = 0;
I think that should work. Please give it a try, I can obviously not test that.
That's it!!! :-)))))) THANK YOU VERY MUCH!!!!!
Hello, first at all...THANK YOU VERY MUCH TO CREATE SUCH A GREAT PROJECT!!!! Now I am trying to implement additional data from "Growatt Inverter Modbus RTU Protocol": https://www.photovoltaikforum.com/core/attachment/265072-pdfcoffee-com-growatt-inverter-modbus-rtu-protocolii-v120-english-pdf-free-pdf/ (I think this is the right protocol for my SPH4600 because values until "95" (tempboost) are ok)
To get the SOC I add to your "growattInterface.cpp":
if (setcounter == 15) { // Battery modbusdata.socinverter = growattInterface.getResponseBuffer(1014 - 960); }
and below the section:
setcounter++; if (setcounter == 2) { setcounter = 0; // Generate the modbus MQTT message sprintf(json, "{", json); sprintf(json, "%s \"status\":%d,", json, modbusdata.status); sprintf(json, "%s \"socinverter\":%.1f,", json, modbusdata.socinverter);
In "growattInterface.h" I added to section the "socinverter":
struct modbus_input_registers { int status; float solarpower, pv1voltage, pv1current, pv1power, pv2voltage, pv2current, pv2power, outputpower, gridfrequency, gridvoltage; float energytoday, energytotal, totalworktime, allphaseenergy, gridpowertolocalload, energyp3, pv1energytoday, pv1energytotal, pv2energytoday, pv2energytotal, opfullpower; float dischargepower, chargepower, socinverter, batsoc; float tempinverter, tempipm, tempboost; int ipf, realoppercent, deratingmode, faultcode, faultbitcode, warningbitcode; };
As MQTT feedback I received a "0" :-( ("socinverter": 0)
Did I something wrong to define "setcounter"???