ESP8266 Fronius Symo Modbus TCP Communications

Hello,

Has anybody managed to get an ESP8266 to read holding registers in a Fronius Symo solar invertor via Modbus TCP? Sample code would be appreciated. Thanks.

Regards,
Brian

Your post was MOVED to its current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Thanks Juraj! This is exactly what I was after. I was hoping it would be you. I've come across some of your older posts. I will try the code tonight.

  1. Did you use any libraries?
  2. Was your application via ESP8266 over Wifi ?
  3. Did you use the 'int+SF' setting in the Fronius?
  4. Did you change the Controlling Priorities? Currently my settings are default i.e. :
  • 1.IO Control
  • 2.Dynamic power reduction
  • 3 Controlling via Modbus.

NOTE1: My Fronius is a 5kW Symo not the Hybrid so I guess all else is common except the battery request code.

Back ground:
I have established a Wifi connection to the Fronius Symo. I started using the Modbus library written by Alexander Emelianov which shows when the Modbus connection is established. I did appear to get some kind of data but it would disappear and did not make sense to me. Your code looks like it is spot on with what I need.

It looks like all I need to do is add the Wifi connection code, get a connection then run your code. Does this approach sound reasonable? Any comments would be most appreciated.

Best regards,
Brian

I don't use a modbus library. All modbus tcp related code is in Modbus.ino.

I run the project on esp8266 for some months. The Arduino networking libraries have the same API so I use a #define NetClient, which can be WiFiClient or EthernetClient.

Yes I use int+SF.

I didn't change the priorities, but I don't control the inverter. Only control setting I use is battery discharge speed limit.

The Modbus.ino I linked is part of a large sketch, which is divided into multiple ino files. The main ino is Regulator.ino. It has setup and loop. The GitHub repository is one project. Read the README for more info.

Hello Juraj,

I had a look at your code and wow it's pretty involved. I do have a practical level of code experience but no where near your level. I started trying to add the Modbus.ino to my project but obviously it needs the Regulator.ino to run. I've abandoned that approach. Do you think it a better approach to use your Regulator code, leave the Modbus.ino code as it is and modify the Regulator code i.e. strip back most of the code not associated with the Modbus communications? At this stage I just want to read the invertor power output either directly from the invertor or the Smart meter. Writing to the invertor will come later. Once I can read a single register then I think it'll all become clear. Also, I didn't realize the code could be separated as done in your project. It's a good idea. Do the .ino files simply need to be located in the same directory?

P.S. if you have a simplified 'Read' example code that may help get me started.

Regards, Brian

modbus tcp are the 3 functions at the end of Modbus.ino.
modbusRequest reads registers
modbusWriteSingle writes a register (used in BatSet,ino)
modbusConnection handles the TCP (re)connection. the Client object is global and stays connected all the time

requestSymoRTC, requestInverter, requestMeter, requestBattery use modbusRequest function to read data for my sketch. they store the values in global variables available for other parts of the sketch

modbusError does project specific error handling to keep track of problems but not to panic at first error

modbusLoop does project specific logic to retrieve a consistent set of values every 4 seconds

Thanks Jurai for the explanation. I'll work on this again tonight. I think I will try to use the Regulator.ino and the Modbus.ino only. Do these files need to live together in the same directory?

Regards,

Brian

an Arduino sketch is a folder with source files with the main ino file having the same name as the folder.
https://arduino.github.io/arduino-cli/latest/sketch-specification/

Thanks Juraj. Makes better sense now. I'll get to work. I'll let you know how i go. It may take a few days to make progress. FYI, I'm ok with serial comms but a bit weak in the Wifi/Ethernet department. I have a Wifi connection in another sketch so will try to adapt that to your Regulator sketch and remove any code not associated with the Modbus and Battery (I don't have a Hybrid invertor but will leave this code in for now as I will adapt for writing to the standard Symo invertor later).

Best regards,

Brian

take first only Regulator.ino and the .h files. comment out all the function calls to other .ino files. make Regulator.ino work (connect to WiFi). then add Modbus.ino and uncomment modbusSetup() and modbusLoop() in Regulator.ino. make it run. next add Telnet.ino for logging (it logs to Serial too) and uncomment telnetSetup() and telnetLopp(). etc
this is how I proceed if migrating to a new board.

here is the version of Regulator.ino before I removed esp8266 support (it uses ssid and password remembered in esp8266): Regulator/Regulator.ino at 2bcc2cad8e6e71cb8bd998e27b70a5e05a405b3b · JAndrassy/Regulator · GitHub

Juraj,

Thanks for this guide. I will pause progress with adapting your project for now and will get back to it in about two or three weeks . The reason being I have managed to get the ModbusIP_ESP8266.h library written by Alex Emelianov working with help from Alex. I had a timing issue as the network is actually a Modbus bridge within the Fronius solar inverter (Modbus TCP bridges to Modbus RTU RS485). I have another project where I think your code will help. That project is more simple and an RS485 Modbus half Duplex config. I'll start it after I receive an I/O module on order from somewhere in China.

Your program is brilliant and I will come back to this blog to continue our discussion as there are very interesting aspects to what you have done. I really appreciate your help so far. I'll do a write up of my project hopefully before the year is out and post in the Arduino Forum with credits to both you and Alex. I will eventually upgrade to a Symo Hybrid or add one as a string inverter. Things will get interesting then.

I'm interested in how you manage the battery discharge (but I'm not ready for that just yet). Using the ModbusIP_ESP8266.h library it appears I can read register values in both the inverter and smart meter. I've only tried 'uint' values at this point. I'll experiment and start to add the system into my Python project on my Raspberry Pi over the next couple of weeks and will let you know how it goes. I will also look into the Fronius parameters and work out how I can optimize generation.

FYI, I used to be a Control System Engineer many years ago (old school, pre IOT) and also hold an electrical license so will review the power system aspect and advise of anything useful. I am impressed with your project and will spread the word. I'll be in touch soon.

Best regards,
Brian

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.