MarkusHarmsen / esp-meter

ESP-Meter
MIT License
2 stars 0 forks source link

ESP230 #1

Open Woogel opened 9 months ago

Woogel commented 9 months ago

Hello first, great implementation! I have a suggestion. I am looking for a pure SDM230/SDM630 emulator, and I'm sure many others are as well. Currently, I transmit the data from my SDM630 over MQTT and process it with RedNode. However, the Growatt 2000 tl-x and Growatt 1000 tl-x (I have one of each) unfortunately cannot share data with the SDM630. I've been trying various emulators for some time without success.

Now, my main question: Is it possible to modify or rewrite your project to create a pure SDM230 emulator that reads its data from MQTT and informs the Growatt about how much power it should still generate? In my case, the MQTT string looks like this: "mqtt/0/Energy/sdm630/nodered/restpower/2_3". RedNode calculates everything and generates two strings. Here, the required remaining power until reaching zero is divided into 1/3 to 2/3, so that each inverter gets its share.

My SDM630 send : mqtt/0/Energy/sdm630/a_act_power
Energy/sdm630/b_act_power Energy/sdm630/c_act_power Energy/sdm630/power (complit)

I hope this is clear. I would greatly appreciate your response.

MarkusHarmsen commented 9 months ago

Hey @Woogel,

sure - that would be possible. You could take the two files:

And use them in a your project. Just call EastronSimulator::setup once and EastronSimulator::loop in your main loop and it should do the job ;).

Does that answer your question already?

Woogel commented 9 months ago

Hello Markus. First of all, thank you for your quick response. Unfortunately, I'm a bit overwhelmed here. If I tinker with something, it's usually in the Arduino environment. I have VB and PlatformIO on my computer, but it's not really my world. Nevertheless, I took a look at the entire code. How does the information from MQTT (L1, L2, L3 = total) get into the Emu? I wanted to pass the MQTT string mqtt/0/Energy/sdm630/nodered/restpower/2_3 to the Emu, and it should instruct the Growatt to go into 0 feed-in. As I mentioned, I have 2 Growatts and I divide the total consumption in the house for the larger one (2000) into 2/3 of the SDM630 power, and for the smaller one (1000) the remaining 1/3. Now, I just need to read the MQTT and feed it into the Emu, and the Emu should deceive the Growatt accordingly.

MarkusHarmsen commented 9 months ago

Ah, ok - that should be possible, but you would have to do it on your own. General outline

Woogel commented 9 months ago

Okay, I'm almost where I want to be, but where do I get the data for eastronSimulator.setCurrentPower(power, powerMeter.getReadingsInStable(), powerMeter.getReadingsOutStable(), powerMeter.getCurrentVoltage());? "Power" should be the total consumption, and I've figured out the voltage, which is L1 + L2 + L3 / 3. However, "InStable" and "OutStable" don't mean anything to me since I'm reading from an SDM630.

`void callback(char topic, byte payload, unsigned int length) { // Handle incoming message // The payload is a byte array, convert it to a string if necessary String message; for (int i = 0; i < length; i++) { message += (char)payload[i]; }

// Process the message or extract the required information float parsedValue = message.toFloat();

eastronSimulator.setCurrentPower(parsedValue, ? , ? , 230); //eastronSimulator.setCurrentPower(power, powerMeter.getReadingsInStable(), powerMeter.getReadingsOutStable(), powerMeter.getCurrentVoltage());

}`

MarkusHarmsen commented 9 months ago

Ah, ok - see the method signature here: main/src/plugins/eastron_simulator.h#L24:

      setRegisterValue(REGISTER_IMPORT_ACTIVE_ENERGY, readingIn);
      setRegisterValue(REGISTER_EXPORT_ACTIVE_ENERGY, readingOut);

So you have to set them to your total sum readings in (total energy sum taken from the grid) and total readings out (total energy sum feeding into the grid). Not sure if you have them available in your MQTT topics.

For the Growatt Inverter, I am not sure if those values are actually required to do the regulation. They will show up however on the "Shine-Portal"/App, so setting them to a fixed value (like 1000, 0) could also work.

Woogel commented 9 months ago

Hello, I'm reading data from the SDM630 using an EspEasy Mega. I can retrieve data from all registers and send them via MQTT. I'm just waiting for the sun to wake up the WR (presumably the solar inverter), and then I'll proceed with the experiment. The Esp32 send me this Data :

RestPower: 0.00 Imp_kWh: 3223.00 Exp_kWh: 4335.00 Volt: 233.00

To Time the RestPower 0 , no Sun ;)

float Imp_kWh = 0.0;  // Annahme: Diese Variablen speichern die Werte aus MQTT
float Exp_kWh = 0.0;
float RestPower = 0.0;
float V_L1 = 0.0;
float V_L2 = 0.0;
float V_L3 = 0.0;
float Volt = 0.0;

void callback(char* topic, byte* payload, unsigned int length) {
  String message;
  for (int i = 0; i < length; i++) {
    message += (char)payload[i];
  }

  float parsedValue = message.toFloat();

  if (strcmp(topic, "Energy/SDM630_ImpExp/Exp_kWh") == 0) {
    // Hier wird Exp_kWh aktualisiert
    Exp_kWh = parsedValue;
  } else if (strcmp(topic, "Energy/SDM630_ImpExp/Imp_kWh") == 0) {
    // Hier wird Imp_kWh aktualisiert
    Imp_kWh = parsedValue;
  } else if (strcmp(topic, "Energy/sdm630/nodered/restpower/2_3") == 0) {
    // Hier wird setCurrentPower mit den aktualisierten Werten aufgerufen

    RestPower = parsedValue;

  } else if (strcmp(topic, "Energy/SDM630_V/V_L1") == 0) {
    // Hier wird setCurrentPower mit den aktualisierten Werten aufgerufen
    V_L1 = parsedValue;

} else if (strcmp(topic, "Energy/SDM630_V/V_L2") == 0) {
    // Hier wird setCurrentPower mit den aktualisierten Werten aufgerufen
    V_L2 = parsedValue;

} else if (strcmp(topic, "Energy/SDM630_V/V_L3") == 0) {
    // Hier wird setCurrentPower mit den aktualisierten Werten aufgerufen
    V_L3 = parsedValue;

    Volt = (V_L1 + V_L2 + V_L3) / 3; 
}

    Serial.print("RestPower: ");
    Serial.println(RestPower);
    Serial.print("Imp_kWh: ");
    Serial.println(Imp_kWh);
    Serial.print("Exp_kWh: ");
    Serial.println(Exp_kWh);
    Serial.print("Volt: ");
    Serial.println(Volt);

    eastronSimulator.setCurrentPower(RestPower, Imp_kWh, Exp_kWh, Volt);

}