Deye RS232 Modbus protocol reader

I wanted to read data from my Deye Inverter (Model SUN-5K-SG03LP1-EU) but my model do not have the RS486 plug fitted as shown in the Deye manual that mention it is "available on SOME models".

So RS232 is the only option. I downloaded 3 programs for ESP32 that claim to read RS232 data, but none worked on my inverter. The Modbus address they use are not valid/available on my inverter RS232 port.

I could not find any documentation on the Internet on Deye RS232 Modbus protocol. (If you have it please send to "EunomiaSolar" at gmail.)

So with a ESP32 Dev board I wrote some investigative programs and found addresses for 12 important data registers.

Then I wrote my own Deye RS232 Monitor on ESP32.

You can find my App and experiments on :

Enjoy

Hi @eunomiasolar !

To be honest I am not an expert for this product but found some possibly helpful information. If it's not useable please put it into the next electronic garbage bin ... :slight_smile:

You can probably find further information here

https://diysolarforum.com/threads/modbus-comms-with-deye-inverter.46197/

Just a hint: You wrote RS486 but I assume you mean RS485 ...

This document states that the RS232 port is used to connect to a Wifi datalogger

https://ivg-energy-solutions.de/Produktbilder/DMS/ART_SUN-5K-SG03LP1-EU/Manual_SUN_3.6_6K_SG03LP1_EU_Deye_Ver2.2.pdf

On this page (in German language, you may have to use an online translator) users discuss how the Deye Wifi Logger (which they say is a Solarman Logger) works; Here is the essential point:

In current versions of the cFos Wallbox, there is a meter definition specifically for DEYE LP3 inverters. (Previously, users had to download the meter definition from the cFos website and upload it to the cFos Wallbox; this is no longer necessary today.)
In fact, the Deye Wi-Fi Logger (technically the Solarman Logger) listens on port 8899, allowing the cFos Wallbox to read out the relevant values. To enable this, when configuring the devices within the cFos interface, you must specify the local address of the Wi-Fi Logger in the following format: "192.168.x.y:8899i". Note well: that small, inconspicuous "i" is crucial, as it signals to the cFos Wallbox that the proprietary Solarman protocol is to be used.

You find a specification of the Solarman protocol here:

https://pysolarmanv5.readthedocs.io/en/stable/solarmanv5_protocol.html

Good luck!
ec2021

My Deye do not have the RS485 Modbus plug populated - so RS232 is the only way. Normally the WiFi dongle is in fact on RS232 as Ec2021 mentioned above, but I do not use the Deye Internet Web interface - so I unplug the WiFi dongle in any case.

The Modbus Documentation online seem to be for RS485, but I found none for RS232 and in my experimentation the addresses differ totally on RS232. Do anybody have it, or know where to find it? (See code on GitHub - link above, for the register addresses I found).

Secondly my ESP32 sketch have an HTML web interface that display all the data I found in real time(The most important fields) - so the WiFi dongle is unnecessary. However with more documentation I can add more data items.

The daily .CSV file is relay informative especially when you plot the data on a graph.

The beauty of the RS232 plus is that there is a 12V power supply that can drive the ESP32.

are yiou having problems reading the rs-232 interface or simply interpreting the data from it?

you mention a .csv file with data, but i don't see it on you site

Hi gcjr

My ESP32 read the RS232 Modbus 100% fine after a big investigation and some trail & error searching for register addresses, but I would like documentation on Deye RS232 Modbus (RS485 is available) so I can access more registers.

Register addresses that I found on RS232 differ from the RS485 documentation online. (Why Deye ? )

The daily .CSV file is 0.5 GB long, but there is a graph of it on :
GitHub - eunomiasolar/ESP32-Deye-RS232-Modbus-Reader: Read the RS32 port on DEY SUN-5K inverter register data with ESP32 · GitHub

the difference between rs-485 and rs-232 is just voltages levels. shouldn't affect the protocol or registers

i can't read values from a graph. just post 100 lines

I understand that DB-9 is a standard connector. Why the above connector's pin signals differ from what I know Fig-1).


Figure-1:

On my Deye RS232 I use pin 2 and pin 3 as normal for data

gcjr I can assure you on my Deye the register addresses on RS232 differ totally from the manual on RS485 Modbus, however the Modbus protocol is the same.

Here is a few lines from my 0.5 GB .CSV file

DSub 9 is a standard connector, also named DB9 or DE-9, that can be used for different purposes.

See here (typical applications)

https://en.wikipedia.org/wiki/D-subminiature

or for CAN bus

https://en.canopen-lift.org/wiki/CANopen_Connector_9-Pin_D-Sub

RS-232 specifies the use of DB9 and DB25.

If you do not have to apply to a standard you can specify your own use. Not always a good decision but some companies try to push sales of their own addon equipment by implementing non-standard interfaces...

In a lot of cases that's motivating makers to find their own solutions...

you're not making this easy.

i wanted the raw values as in a text (i.e. .csv). I can't read numeric values from an image into a script to evaluate.

so the internal register values are acutally different, not the protocol. Can you post a link that explains the differences?

Hi gcjr

The addresses I found on my RS232 connections are below address 200 and they give valid data. (Online documentation addresses is above +- 500 for RS485)

See the list of addresses in the README.md file in :

I uploaded part of my 0.5 MB .CSV file to :

Hope that is sufficient.

It is a 9-pin connector but the signal attachment with pins vary with protocol. I did not know it as I have been always using it for async serial operation where Pins-2, 3 are used for data lines.

Thanks for respondng.

Do you know this page?

https://kellerza.github.io/sunsynk/reference/definitions

As far as I can see the registers in your code can be found in the table listed there plus a lot more...

where is the link to a description of the protocol? or do i need to do a google search?

and then exactly which program, .cpp file, did you use to extract the data?

and do you have a copy of the raw data?

The protocol is standard Modbus, but the addressing differ as I explained above (and in the README.md files).
I used the standard Arduino library "ModbusMaster.cpp" but added a Poll function to improve speed of main loop(). Check it out in my source code.
Your other questions is answered in the four README.md files on GitHub (link above)

This is the register list as found on

https://kellerza.github.io/sunsynk/reference/definitions

but tailored to the relevant columns and rows

Table of Registers
Name 1PH Group
Device type [0]
Protocol [2]
Serial [3,4,5,6,7]
Battery temperature [182] * 0.1 diagnostics
Battery voltage [183] * 0.01 diagnostics power_flow_card
Battery SOC [184] diagnostics power_flow_card
Battery power [190] s diagnostics power_flow_card
Battery current [191] * 0.01 diagnostics power_flow_card
Battery charge limit current [314] s
Battery discharge limit current [315] s
Inverter power [175] s power_flow_card
Inverter voltage [154] * 0.1 power_flow_card
Inverter current [164] * 0.01 power_flow_card
Inverter frequency [193] * 0.01
Grid frequency [79] * 0.01 power_flow_card
Grid power [169] s power_flow_card
Grid L1 power [167] s
Grid L2 power [168] s power_flow_card
Grid voltage [150] * 0.1 diagnostics power_flow_card
Grid current [160,161] power_flow_card
Grid CT power [172] s power_flow_card
Load power [178] s power_flow_card
Load L1 power [176] s power_flow_card
Load L2 power [177] s power_flow_card
Load frequency [192] * 0.01 power_flow_card
AUX power [166] s power_flow_card
AUX voltage [181] * 0.1
AUX frequency [196] * 0.1
PV1 power [186] s power_flow_card
PV1 voltage [109] * 0.1 power_flow_card
PV1 current [110] * 0.1 power_flow_card
PV2 power [187] s power_flow_card
PV2 voltage [111] * 0.1 power_flow_card
PV2 current [112] * 0.1 power_flow_card
PV3 power [188] s power_flow_card
PV3 voltage [113] * 0.1 power_flow_card
PV3 current [114] * 0.1 power_flow_card
Essential power [175,169,166] power_flow_card
Essential 1 power [175,167,166]
Essential 2 power [175,169,166]
Non-essential power [172,167] power_flow_card
Day active energy [60] * 0.1
Day battery charge [70] * 0.1 power_flow_card
Day battery discharge [71] * 0.1 power_flow_card
Day grid import [76] * 0.1 power_flow_card
Day grid export [77] * 0.1 power_flow_card
Day load energy [84] * 0.1 power_flow_card
Day PV energy [108] * 0.1 power_flow_card
Day reactive energy [61] * 0.1
Month grid energy [67] * 0.1
Month load energy [66] * 0.1
Month PV energy [65] * 0.1
Total active energy [63,64] * 0.1
Total battery charge [72,73] * 0.1 energy_management
Total battery discharge [74,75] * 0.1 energy_management
Total grid export [81,82] * 0.1 energy_management
Total grid import [78,80] * 0.1 energy_management
Total load energy [85,86] * 0.1 energy_management
Total PV energy [96,97] * 0.1
Year grid export [92,93] * 0.1
Year load energy [90,91] * 0.1
Year PV energy [94,95] * 0.1
Total power [175,169,166,172,167]
Fault [103] diagnostics power_flow_card
Overall state [59] diagnostics
SD state [99]
DC transformer temperature [180] s diagnostics
Radiator temperature [181] s
Environment temperature [185] s * 0.1 diagnostics
Radiator temperature [181] s * 0.1 diagnostics
Grid connected [194] diagnostics
Time (H/M) [22,23,24] advanced
Inverter enabled (R/W) [43]
Control mode [200]
Solar export enabled (R/W) [201] settings
Generator output (R/W) [202]
Battery charging voltage [203]
Shut SOC [204]
Batt Empty [205]
Battery Absorption voltage (R/W) [208] * 0.01 battery
Battery Equalization voltage (R/W) [209] * 0.01 battery
Battery Float voltage (R/W) [210] * 0.01 battery
Battery status vs capacity (R/W) [211] advanced battery
Battery max capacity (R/W) [214] advanced battery
Battery low capacity (R/W) [218] advanced battery
Battery shutdown voltage (R/W) [219] * 0.01 battery
Battery restart voltage (R/W) [220] * 0.01 battery
Battery low voltage (R/W) [221] * 0.01 battery
Priority Load (R/W) [243] & 0x01 settings power_flow_card
Load Limit (R/W) [243] & 0x02
Max Solar power (R/W) [244]
Max Sell power (R/W) [245]
multi-invert (R/W) [247] & 0x03 settings power_flow_card
Use Timer (R/W) [248] & 0x01
Peak Shaving (R/W) [248] & 0x02
Grid peak shaving (R/W) [248] & 0x04
Gen peak shaving (R/W) [248] & 0x08
Grid charge set [248] & 0xF0
Gen peak shaving power (R/W) [249]
Grid peak shaving power (R/W) [250]
Prog 1 Time (R/W) [250] settings
Prog 1 Power (R/W) [256] settings
Prog 2 Time (R/W) [251] settings
Prog 2 Power (R/W) [257] settings
Prog 3 Time (R/W) [252] settings
Prog 3 Power (R/W) [258] settings
Prog 4 Time (R/W) [253] settings
Prog 4 Power (R/W) [259] settings
Prog 5 Time (R/W) [254] settings
Prog 5 Power (R/W) [260] settings
Prog 6 Time (R/W) [255] settings
Prog 6 Power (R/W) [261] settings
Prog 1 Capacity (R/W) [262] settings
Prog 2 Capacity (R/W) [263] settings
Prog 3 Capacity (R/W) [264] settings
Prog 4 Capacity (R/W) [265] settings
Prog 5 Capacity (R/W) [266] settings
Prog 6 Capacity (R/W) [267] settings
Prog 1 charge (R/W) [268] & 0x03 settings
Prog 2 charge (R/W) [269] & 0x03 settings
Prog 3 charge (R/W) [270] & 0x03 settings
Prog 4 charge (R/W) [271] & 0x03 settings
Prog 5 charge (R/W) [272] & 0x03 settings
Prog 6 charge (R/W) [273] & 0x03 settings
Prog 1 mode (R/W) [268] & 0x0C
Prog 2 mode (R/W) [269] & 0x0C
Prog 3 mode (R/W) [270] & 0x0C
Prog 4 mode (R/W) [271] & 0x0C
Prog 5 mode (R/W) [272] & 0x0C
Prog 6 mode (R/W) [273] & 0x0C
Prog 1 Voltage (R/W) [280] * 0.01
Prog 2 Voltage (R/W) [281] * 0.01
Prog 3 Voltage (R/W) [282] * 0.01
Prog 4 Voltage (R/W) [283] * 0.01
Prog 5 Voltage (R/W) [284] * 0.01
Prog 6 Voltage (R/W) [285] * 0.01
Battery Charge Battery current (R/W) [230] advanced battery
Battery Max Charge current (R/W) [230] advanced battery
Battery Max Discharge current (R/W) [231] battery
BMS Protocol (R/W) [233]

Could not find a format to show the table nicely inside code tags ...

This is very helpful
They list 11 of the 13 registers I found with the same addresses in : Sensors | Deye/Sunsynk
I can work with this table and will share when I got it in .cpp format.
Thanks a lot

I found the following Deye registers from the link above - these are all below address 200. Still the registers above address 500 is not available on RS232 Modus - probably it is available on RS485

Load power 178
Inverter power 175
Inverter voltage 154
Inverter current 164
Inverter frequency 193
Battery charge limit current 314
Battery discharge limit current 315
Grid connected 194
Battery charging voltage 312
Battery shutdown capacity (R/W) 217
Battery restart capacity (R/W) 218
Battery low capacity (R/W) 219

Thanks again.