I have the Datasheet informations from Huawei but i have completle no idea how i can use this registers. I need the "Active Power" Register 40525, 16Bit, Command 0X03, Quantity 2
Please, please show to my Problem again, i just need this "Active Power" Variable and my absolute basic knowledge is not enough to solve this.
Everything else ist no Problem for me.
Kind Regards Hoerb
I solved the Problem with the 2 serial interfaces by using
SoftwareSerial
But I have Problems to understand Addresses and Registers.
The Huawei Info to read Modbus:
*Active Power
*Address 40525,
*I32
*16Bit
*Command 0X03,
*Quantity 2
How can i integrate this Info in my Code? I used questions marks ?????? in my code, where i think that is important:
#include <ModbusMaster.h>
#include <SoftwareSerial.h>
#define MAX485_TX_ENABLE 7 // EIA-485 transmit control pin; MAX485 Module PIN DE and RE
#define EIA485_RX 9 // EIA-485 serial receive pin ; MAX485 Module PIN RO
#define EIA485_TX 10 // EIA-485 serial transmit pin ; MAX485 Module PIN DI
ModbusMaster node;
SoftwareSerial RS485Serial(EIA485_RX, EIA485_TX); // Hier wird der serielle Port beschrieben
void preTransmission() {
digitalWrite(MAX485_TX_ENABLE, true);// Vor der Übertragung wird Pin 7 auf High gesetzt.
}
void postTransmission() {
digitalWrite(MAX485_TX_ENABLE, false);// Nach der Übertragung wieder auf Low
}
void setup() {
pinMode(MAX485_TX_ENABLE, OUTPUT);
digitalWrite(MAX485_TX_ENABLE, false);
Serial.begin(9600);
RS485Serial.begin(9600); //Baudrate des Sensors auf 9600
node.begin(1, RS485Serial);//Start der seriellen Schnittstelle, Slave ID 1 //???????????? Huwaei DTH666 says 11?????
node.preTransmission(preTransmission);
node.postTransmission(postTransmission);
Serial.print("");// Bezeichnung meines Sensors
}
void loop() {
float result;
//uint16_t result;
result = node.readInputRegisters(40525, 2);//Funktion : Read Input Registers, Modbus Adressen 2 //???????? no idea if it is right
if (result == node.ku8MBSuccess)
{
Serial.print("Active Power: ");
Serial.println(node.getResponseBuffer(0)*0.1,1);// 1. Part????????????
Serial.println(node.getResponseBuffer(1)*0.1,1); // 2. Part???????????
Serial.println(" kw");
}
else {
Serial.print("Fehler beim Auslesen des Sensors\n");
}
delay(2000);//Aktualisierung alle 2 Sekunden
}
Thank you very much for your Answer. But i do not come into the loop because
if (result == node.ku8MBSuccess) is not true -> so I think the 40525 falue must be false
result = node.readInputRegisters(40525, 1);//Read Input Registers, Modbus Addresses - sure not right
if (result == node.ku8MBSuccess)
{
Serial.print("Active Power: ");
int32_t power = node.getResponseBuffer(0);
power <<= 16;
power |= node.getResponseBuffer(1);
Serial.println(power);
Serial.println(" kw");
}
else {
Serial.print("Error Data\n");
Now i get sometimes random Numbers - with very short Registernumbers (for example 1 or 25)
But the actual Register is: 37113
Insteat of 37113 i used 113.
The output was: Error Data
Hallo,
i also want to disign a Controller to control the Power. Can you please Tell me the Code that you have taken?
And what Adresse ist the active Power.
The Code at the top dosent work by my Inverter.
Thank you for you Help.
Today i have still no funktional code. But this weekend i dry it again . It seem to be important to login with the installer login to the sun2000 app to enable the modbus output. HAve you allready logged in in this way?
The register for active power adress is: 37113