Regarding Modbus RTU with solar Inverters

Juraj:
@pylon, it could be that the inverter has two modbus rtu interfaces. one where it is master (for BMS and/or Smart Meter) and one where it is slave. on my Fronius Symo I can't use Modbus RTU to request data because the inverter is master for BMS and Smart Meters. only Modbus TCP is available to request data.

@Juraj, Hi, This inverter also has TCP in it. The company has said that its possible to use RTU and TCP. Which one would be the best?

Prasannaa:
@Juraj, Hi, This inverter also has TCP in it. The company has said that its possible to use RTU and TCP. Which one would be the best?

I planed to use RTU (20 m cable) to not flood my home TCP network with realtime requests. I started with WiFi, so TCP. Then I discovered I can't use RTU, but cable is better, so now I use Ethernet (over power line). I make 4 request every 4 seconds. I started with shorter interval, but the values didn't change so fast. So it doesn't flood my home network.

Juraj:
I planed to use RTU (20 m cable) to not flood my home TCP network with realtime requests. I started with WiFi, so TCP. Then I discovered I can't use RTU, but cable is better, so now I use Ethernet (over power line). I make 4 request every 4 seconds. I started with shorter interval, but the values didn't change so fast. So it doesn't flood my home network.

Sounds great.
Can you please help me by sharing the code for reference.

Prasannaa:
Sounds great.
Can you please help me by sharing the code for reference.

Juraj:
GitHub - JAndrassy/Regulator: DIY Arduino consumption regulator build to use excess solar power for auxiliary 'summer' heating. The solar power data are retrieved over SunSpec Modbus TCP. IoT monitoring with Blynk and local Web server.

Thank you so much. Should I use the modbus.ino file?

Prasannaa:
Thank you so much. Should I use the modbus.ino file?

most of Modbus.ino is for SunSpec Modbus registers and for integration with my project. only the modbusRequest and modbusWriteSingle functions are generic.

depending on how you plan to use the data retrieved from the inverter, some parts of my project could be useful for you, but only if you understand them, to which the best way is try it to code yourself and the compare with my code.

adwsystems:
BINGO! Then configure your constructor to use Serial1 and the corresponding pins.

Hi,
I tried with mega. But in the Serial I didnt receive any data. It was Just blank. I have mentioned the code below.

Code:

#include <ModbusRtu.h>

// data array for modbus network sharing
uint16_t au16data[16];
uint8_t u8state;

/**

  • Modbus object declaration
  • u8id : node id = 0 for master, = 1..247 for slave
  • u8serno : serial port (use 0 for Serial)
  • u8txenpin : 0 for RS-232 and USB-FTDI
  • or any pin number > 1 for RS-485
    */
    Modbus master(0,1,2); // this is master and RS-232 or USB-FTDI

/**

  • This is an structe which contains a query to an slave device
    */
    modbus_t telegram;

unsigned long u32wait;

void setup() {
master.begin( 19200 ); // baud-rate at 19200
master.setTimeOut( 2000 ); // if there is no answer in 2000 ms, roll over
u32wait = millis() + 1000;
u8state = 0;
}

void loop() {
switch( u8state ) {
case 0:
if (millis() > u32wait) u8state++; // wait state
break;
case 1:
telegram.u8id = 1; // slave address
telegram.u8fct = 3; // function code (this one is registers read)
telegram.u16RegAdd = 3841; // start address in slave
telegram.u16CoilsNo = 1; // number of elements (coils or registers) to read
telegram.au16reg = au16data; // pointer to a memory array in the Arduino

master.query( telegram ); // send query (only once)
u8state++;
break;
case 2:
master.poll(); // check incoming messages
if (master.getState() == COM_IDLE) {
u8state = 0;
u32wait = millis() + 100;
}
break;
}
}

Prasannaa:
Hi,
I tried with mega. But in the Serial I didnt receive any data. It was Just blank. I have mentioned the code below.

You didn't receive any data while the MEGA was connected to the PC and the MODBUS both using the same serial connection (Serial)? I would try moving to the Modbus to use Serial1 while the PC is connected.

adwsystems:
You didn't receive any data while the MEGA was connected to the PC and the MODBUS both using the same serial connection (Serial)? I would try moving to the Modbus to use Serial1 while the PC is connected.

Yeah. I used Serial1.

I tried with mega. But in the Serial I didnt receive any data. It was Just blank. I have mentioned the code below.

Sure, you don't send anything to Serial. Modbus is handled on Serial1 but any result is just kept in the sketch, nothing is reported to Serial.

Hello Prasannaa,

How did you go with your Modbus RTU connect to your Fronius Simo? I'm think of doing the same over the next few weeks. It would be good to know how successful you were.

Regards,

Brian

Brian_Usher:
Hello Prasannaa,

How did you go with your Modbus RTU connect to your Fronius Simo? I'm think of doing the same over the next few weeks. It would be good to know how successful you were.

Regards,

Brian

do you have a Symo without Smart Meter and battery? because with Smart Meter the Data Manager is Modbus RTU master so you can't read data with other device as master