Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Growatt Inverter support via RS 485 / CAN #1

Closed
sanitariu opened this issue Sep 8, 2023 · 60 comments
Closed

Growatt Inverter support via RS 485 / CAN #1

sanitariu opened this issue Sep 8, 2023 · 60 comments

Comments

@sanitariu
Copy link

Hello,
Do you plan any support for Growatt Inverter support via RS 485 ?

@ai-republic
Copy link
Owner

I'm currently implementing a MQTT support with a little webserver to see the states of all battery cells in each battery pack.

To implement the Growatt protocol would be no problem but maybe in a couple of days. If you have the protocol at hand or could organize it, it would be helpful and speed up the process :)

Best regards,
Torsten

@sanitariu
Copy link
Author

I will help with all i can. I would like to make my Daly BMS speak with my Growatt inverter. Currently i am able to read info from the Daly via small python script i found here
https://github.com/dreadnought/python-daly-bms.git

This is the information from my Daly:

daly-bms-cli --device /dev/ttyUSB2 --all

{
"soc": {
"total_voltage": 53.9,
"current": 39.0,
"soc_percent": 76.4
},
"cell_voltage_range": {
"highest_voltage": 3.379,
"highest_cell": 16,
"lowest_voltage": 3.372,
"lowest_cell": 5
},
"temperature_range": {
"highest_temperature": 28,
"highest_sensor": 1,
"lowest_temperature": 28,
"lowest_sensor": 1
},
"mosfet_status": {
"mode": "charging",
"charging_mosfet": true,
"discharging_mosfet": true,
"capacity_ah": 213.92
},
"status": {
"cells": 16,
"temperature_sensors": 1,
"charger_running": false,
"load_running": false,
"states": {
"DI1": false
},
"cycles": 63
},
"cell_voltages": {
"1": 3.373,
"2": 3.373,
"3": 3.372,
"4": 3.375,
"5": 3.372,
"6": 3.375,
"7": 3.374,
"8": 3.377,
"9": 3.374,
"10": 3.373,
"11": 3.372,
"12": 3.375,
"13": 3.372,
"14": 3.375,
"15": 3.374,
"16": 3.379
},
"temperatures": {
"1": 28
},
"balancing_status": {
"error": "not implemented"
},
"errors": []
}

Also I am able to read data from my Growatt inverter and graph it using grafana via this:
https://github.com/sdsolomo/growatt-x000ES

Daly is using this connection - ch341-uart converter now attached to ttyUSB2 (USB to UART cable connected to Daly device)
Growatt is using this connection - cp210x converter now attached to ttyUSB1 (USB direct cable from the Inverter to Pi device)

If i can help you somehow i would do it even with some remote access if you like.

@sanitariu
Copy link
Author

Here is Daly BMS protocol
Part 4_ Daly RS485+UART Protocol.pdf

@sanitariu
Copy link
Author

Here is Growatt protocol
Growatt PV Inverter Modbus RS485 RTU Protocol v120.pdf

@ai-republic
Copy link
Owner

Hi Todor,
sorry for the late reply. I've been away for a few days. I've had a look at the Growatt protocol but have not yet really understood everything as a lot of the knitty gritty stuff for the BMS data is in chinese. I will have to work through it with google translator and try to figure it out. Do you know which mandatory values the Growatt inverter needs from the BMS?

@ai-republic
Copy link
Owner

FYI: I've added a growatt module to the project. Just for the structure... there is no functionality yet!

@ai-republic
Copy link
Owner

Hi Todor,
I've implemented the Growatt CAN protocol if you like to test it.
Note: I do not have a Growatt Inverter so it is purely programmed by the Growatt CAN protocol specifiation for low voltage (12-96V) inverters.
If you like to test it I would be thankful :)

@sanitariu
Copy link
Author

Hi,
Thanks for the support ! I am going to test it very soon. I must order CAN device to connect the inverter. I can connect now only via RS-485.

@sanitariu sanitariu changed the title Growatt Inverter support via RS 485 Growatt Inverter support via RS 485 / CAN Oct 28, 2023
@sanitariu
Copy link
Author

I have ordered the same CAN device model as yours. I found also one PYLON_EMU project with dbc file where you can see what you must report via the CAN to the inverter. I am attaching the file if you are interested.
I am going to test tomorrow your version with my CAN device.

pylon_CAN_210124.txt

@sanitariu
Copy link
Author

sanitariu commented Jan 31, 2024

Ok trying to simply connect Growatt to can0.
I receive the following errors
[1662498.588369] mcp251xfd spi0.0 can0: CRC read error at address 0x0010 (length=4, data=e0 80 af 70, CRC=0x01f5) retrying.
I am connecting High to High and Low to Low pins.
Here is my /boot/config.txt

i2c canhat

dtparam=spi=on
dtoverlay=spi1-3cs
dtoverlay=mcp251xfd,spi0-0,interrupt=25
dtoverlay=mcp251xfd,spi1-0,interrupt=24

Also doing this setup ...

link up

/usr/bin/ip link set can0 up type can bitrate 1000000 dbitrate 8000000 restart-ms 1000 berr-reporting on fd on
/usr/bin/ip link set can1 up type can bitrate 1000000 dbitrate 8000000 restart-ms 1000 berr-reporting on fd on

buffers

/usr/sbin/ifconfig can0 txqueuelen 65536
/usr/sbin/ifconfig can1 txqueuelen 65536

If i loop can0 to can1 and send something like this

candump can0
cansend can1 000#11.22.33.44

I see the output.
Can i have your settings for the same wave hat and can ?
If i do not send any data will i receive something from the inverter ?

@ai-republic
Copy link
Owner

ai-republic commented Feb 1, 2024

Hi Todor,
which CAN adaptor are you using? Is it the Waveshare 2-CH CAN FD Hat?
Since your boot.config setting suggest and you have can0 and can1 I guess it might be.

So I believe your Growatt will not have a baudrate of 1000000 but probably 500000. But I will check the documentation.
Also you should not have FD on and also no berr reporting.

My settings for the SMA SI are like this:

sudo ip link set can0 up type can bitrate 500000 restart-ms 100
sudo ip link set can0 txqueuelen 65536

Also make sure you've connected the correct wires (PIN4 = CAN H and PIN 5 = CAN L) of the RJ45 plug to your CAN adaptor.

image

EDIT: I checked for the baudrate and think I've found that it is 500kb

@sanitariu
Copy link
Author

Yes I have the exact same can model you suggested. I setup to 500kb now. Will I see any output from the inverter even if i did not setup program 36 at the inverter side ? I have the same schema in my Growatt book. Seems like the cables are blue and white-blue. As far as I know i should connect CANH to CANH and CANL to CANL ?

@ai-republic
Copy link
Owner

Yes, CAN H to CAN H and CAN L to CAN L.

I'm not sure if you need to set up your inverter to use 2 Lithium and then 36 mode 51 (Growatt) or 52 (Pylontech I think) for the inverter to activate the CAN communication on its BMS port.

You should see some output in the log about the inverter communication. If the Growatt inverter module (with mode 51 on the inverter) doesn't work you can also try to configure the SOLARK inverter since that is also a pure Pylontech CAN protocol implementation with mode 52 on the inverter.

@sanitariu
Copy link
Author

Anyone did a voltage measurements for Growatt CAN H/L ? According to scheme blue/white and blue are pin numbers 4/5. Orange is the ground. I did measure mine and both H/L shows 2.25 voltage. Also resistance between H/L is 160 oms. Is this correct ? I thought CAN H should have more high voltage.
If someone have values for his inverter please share...

@ai-republic
Copy link
Owner

As per CAN physical layer specification:
CAN H (≥ 2.5 VDC) | 2.5 VDC (idle) | 2.5 to 3.5 VDC (active)
CAN L (≤ 2.5 VDC) | 2.5 VDC (idle) | 2.5 to 1.5 VDC (active)

The CAN-L and CAN-H waveforms mirror each other about 2.5 V and have a 1 V peak to peak amplitude. The CAN-L waveform switches from 2.5 V down to 1.5 V and the CAN-H waveform switches from 2.5 V up to 3.5 V.

So 2.25V seems a bit low for CAN H even if its idle. Have you connected PIN 6 (GND) also?

@sanitariu
Copy link
Author

No i have not connected Ground because i read that it is dangerous and you do not need it.
Also i do not know how to test exactly if CAN is working at inverter side ... like i would like to send some command and see the result. If you have something in mind like commands i can try connect the ground and test them via cansend/candump ?

@ai-republic
Copy link
Owner

ai-republic commented Feb 18, 2024

You could try to send a frame like:

  1. for Growatt CAN protocol
0x13, 0x03, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xE6, 0x14, 0x0F, 0x00, 0xDC, 0x00, 0x5E, 0x64

or

  1. for Pylontech CAN protocol
0x55, 0x03, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x5E, 0x00, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00

That should send the follow values:
Pack Voltage: 53.5V (only Growatt protocol)
Pack Current: 1.5A (only Growatt protocol)
Pack Temp: 22C (only Growatt protocol)
Pack SOC: 94% (both protocols)
Pack SOH: 100% (both protocols)

Be sure to choose the correct BMS setting in the Growatt inverter.

@sanitariu
Copy link
Author

I tried but nothing happened. Growatt does not return anything. I do not know if this is normal ? Maybe i need to setup the Growatt first ?!
Also i have tried direct in your code /dev/can1 and this is the output:

2024-02-22 10:45:23.680 | ERROR | 2-thread-1 | verter.core.Inverter:70 | Failed to send CAN frame
java.lang.IndexOutOfBoundsException: fromIndex: 1 > toIndex: 0
at java.util.BitSet.checkRange(BitSet.java:369) ~[?:?]
at java.util.BitSet.set(BitSet.java:484) ~[?:?]
at com.airepublic.bmstoinverter.inverter.growatt.can.GrowattInverterCANProcessor.getChargeStates(GrowattInverterCANProcessor.java:224) ~[inverter-growatt-can-0.0.1-SNAPSHOT.jar:?]
at com.airepublic.bmstoinverter.inverter.growatt.can.GrowattInverterCANProcessor.createAlarms(GrowattInverterCANProcessor.java:135) ~[inverter-growatt-can-0.0.1-SNAPSHOT.jar:?]
at com.airepublic.bmstoinverter.inverter.growatt.can.GrowattInverterCANProcessor.createSendFrames(GrowattInverterCANProcessor.java:34) ~[inverter-growatt-can-0.0.1-SNAPSHOT.jar:?]
at com.airepublic.bmstoinverter.core.Inverter.process(Inverter.java:62) ~[core-api-0.0.1-SNAPSHOT.jar:?]
at com.airepublic.bmstoinverter.inverter.growatt.can.GrowattInverterCANProcessor$Proxy$_$$_WeldClientProxy.process(Unknown Source) ~[inverter-growatt-can-0.0.1-SNAPSHOT.jar:?]
at com.airepublic.bmstoinverter.BmsToInverter.lambda$start$4(BmsToInverter.java:168) ~[bms-to-inverter-main-0.0.1-SNAPSHOT.jar:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
at java.lang.Thread.run(Thread.java:840) [?:?]

I did not setup anything to growatt yet ! I am still not sure if these voltages 2.25 on blue/white and blue are correct.

@ai-republic
Copy link
Owner

Hi Todor,
could you try to see what the inverter sends via candump?
That way I can compare and see which protocol the inverter uses.

@ai-republic
Copy link
Owner

Hi,
I updated the Configurator to allow setting a BMS Id. Also I changed the poll intervall to be a general BMS configuration (not for each).

You will need to download the new Configurator and re-configure your setup and do a clean install.

@ai-republic
Copy link
Owner

Hi Todor,
FYI: the Growatt (Pylon) HV is now working if you like to test it on your setup

@sanitariu
Copy link
Author

Hello,
I am going to test very soon. Waiting to coordinate this with my wife :). If Growatt does not detect BMS it will shutdown the power in my house. ... and someone will be angry :). Also my PI is connected to the same battery and i will be in some sort of loop. So i bought an UPS for the pi. I hope next Sunday to test this setup and you will sure get some sponsor tips from me too !

@jimmy737
Copy link

I'm currently implementing a MQTT support with a little webserver to see the states of all battery cells in each battery pack.

To implement the Growatt protocol would be no problem but maybe in a couple of days. If you have the protocol at hand or could organize it, it would be helpful and speed up the process :)

Best regards, Torsten

Hello, Have you succeeded to get cell information? I have the SPF 5000 ES with 6 Growatt ARK 2.5 batteries trying to get the same battery details as you. Thank you.

@ai-republic
Copy link
Owner

Hi Jimmy,
yes, the Growatt binding is working :)

@jimmy737
Copy link

Hi Jimmy, yes, the Growatt binding is working :)

Thank you. Is there any step by step documentation I can follow to be able to get cell details information from the inverter USB port to an Arduino or raspberry PI? Thank you.

@jimmy737
Copy link

Sorry me again! I cannot install daly. I get this error. Any idea how to resolve this? Thank you.
daly

@jimmy737
Copy link

Ok. I think I am ready to try connecting to the battery. Does it look ready? Thank you.
IMG_1653

@ai-republic
Copy link
Owner

ai-republic commented Apr 17, 2024

No, you don't need daly or python.
Once you have connected the RJ45 to your BMS's CAN port you need to connect the other end to your CAN hat on your RPi. What CAN hat do you have? And have you already installed/configured it?
And you need to know which cables of the 8 in the RJ45 are assigned for CAN H and CAN L.
That should be in the manual of the ARK BMS. Then just follow the Wiki.
You will need to install a Java JDK:

sudo apt install default-jdk

And then download and start the Configurator app as described in the Wiki.

@jimmy737
Copy link

Thank you. I install the Configurator on my laptop and configured it. But in the drop list
it dows not show an option for PI4 64 bits. Which option to choose?
Also I found the correct pins for the cable to go from the CAN port to the PI4. Thank you.

Configurator
RJ45

@jimmy737
Copy link

Sorry one more thing. Yesterday we talked about one end of the custom made network cable to the battery and the other end to PI4. But what do I do with the Waveshare RS485 CAN HAT? I dont have one but if need to I`ll one. Thank you.

@ai-republic
Copy link
Owner

ai-republic commented Apr 20, 2024

The PI4 has an AARCH64 OS platform. The RJ 45 goes right into your CAN port of the ARK. Then you will need to either cut the end off and use wire 4 and 5 (as seen above). Make sure you have the plug the right way around when determining the wires.
Another option is to buy something like this screw terminal adaptor rj45 female to 8 pin connector:

image

You will need to connect the CAN H and CAN L wires to the Waveshare 2CH CAN hat respectively:

image

@jimmy737
Copy link

Thank you for the clear explanation. I will try first option because I live on an island in the caribbean and buying electronic parts is not easy. I'll try that today and report back my progress. Thank you for all the help. Greatly appreciated.

@jimmy737
Copy link

Hello Torsten, I made it this far but nothing shows on the webpage with port 8080. I attached all the details I have and logs maybe you see what is missing. Thank you.
BMS-to-Inverter.log
BMS-to-Inverter_Webserver.log
IMG_1685
IMG_1686
IMG_1687
IMG_1688
IMG_1689
IMG_1691
IMG_1692

@sanitariu
Copy link
Author

I also can not detect the inverter via my PI CanHat. Maybe the cabling is not correct. I am using standart RJ-45 cable with connectors and cut the cable. Using blue and white-blue cables for CANL and CANH.
I tried setup the inverter to battery Li and type 51 or 52 and it goes to error 20/4 immediately. The bad thing is that I must connect my PI4 to other power source because when inverter errors it does not output energy. If someone have more success in connecting Growatt ES5000 inverter please share howto.

@jimmy737
Copy link

I also can not detect the inverter via my PI CanHat. Maybe the cabling is not correct. I am using standart RJ-45 cable with connectors and cut the cable. Using blue and white-blue cables for CANL and CANH. I tried setup the inverter to battery Li and type 51 or 52 and it goes to error 20/4 immediately. The bad thing is that I must connect my PI4 to other power source because when inverter errors it does not output energy. If someone have more success in connecting Growatt ES5000 inverter please share howto.

I am connecting directly to the Growatt Ark battery the same way as you. But no success.

@ai-republic
Copy link
Owner

Hi Jimmy,
the error message that is relevant here is:
Failed to resolve the interface: can() - errorNumber=19, errorMessage='No such device'

What CAN ports show up if you use the command:

ifconfig -a

Usually they are call can0 and can1.

Another thing I noticed on your configuration you configure a Daly BMS. I would expect the Growatt ARK BMS to use the Growatt CAN protocol. If that doesn't work try the Pylon HV or the Pylon CAN protocol and see if you get some data.

Let me know if that helps.

@sanitariu have you checked the documentation which RJ45 wires are CAN H and CAN L for the inverter? I think they were pin 4 and pin 5. Maybe try to switch the cables.

Best regards,
Torsten

@jimmy737
Copy link

Thank you Torsten for the help and suggestions. I am extensively traveling for the next 3 weeks. Away from my inverter so I will try that command to see if I get any data as soon as I return home.

@funkydeo
Copy link

funkydeo commented May 7, 2024

Hi there, im just wondering if you managed to get the Growatt SPF (48v) inverter working with the BMS-inverter. I have some Lithium Po4 batteries and it would be nice to input data for BMS on inverter. i have two batteries but they are not charging/discharging equally on bms setting (Li) and so others use (user2) and input own values problem i am facing is that when i set one particular parameter it resets and i have to input it again the next day for the batteries to charge. so far only the bms function works and i will have to swap cables from top battery to bottom as not charging/discharging equally. hope this is the right place i am searchimg for my answer. cheers

@jimmy737
Copy link

jimmy737 commented May 7, 2024

Hi there, im just wondering if you managed to get the Growatt SPF (48v) inverter working with the BMS-inverter. I have some Lithium Po4 batteries and it would be nice to input data for BMS on inverter. i have two batteries but they are not charging/discharging equally on bms setting (Li) and so others use (user2) and input own values problem i am facing is that when i set one particular parameter it resets and i have to input it again the next day for the batteries to charge. so far only the bms function works and i will have to swap cables from top battery to bottom as not charging/discharging equally. hope this is the right place i am searchimg for my answer. cheers

Hello, I have set the settings 36 to 52. The built in BMS of my SPF 5000 ES does a ok job. I say ok because if I take a reading with a USB stick CONFIG.txt, and open the spreadsheet of each battery, i can see that of my 6 batteries some have different number of discharge cycle. So I plan on rotating the battery every 6 months otherwise some willl be much more used than other. My batteries are different than yours. I have 6 ARK 2.5 Kwh A01. Sorry not much help here.

@funkydeo
Copy link

funkydeo commented May 7, 2024

Hi Jimmy, thanks very much for your response. Yes i think i may have to rotate the batteris in this case with my syatem. At the moment my setting 36 is on 01 which was mentioned by the seller who sold me the battery(OT-LV-5120WH)/inverter(SPF 5000 ES). I havent tried it on 52 yet, is it just a protocol for the battery brand? Im also waiting for the RS-232 connection from battery to check detailed info.
thanks

@ai-republic
Copy link
Owner

@funkydeo yes, the Growatt SPF should be working with either the Growatt inverter CAN binding or the Pylon inverter CAN binding

@KelasHA00
Copy link

Hi,
i have attempted and just now succeeded in coupling a Daly HV BMS to a Growatt SPH TL3 BH UP thank to this thread.
i was stuck for some time, but changing from Growatt Can to Pylontech HV Can solved the communication to Inverter.
Could you update the wiki to make this clear?

I will definitly send support to this project. Great work!

i have some minor issues with 'Next frame: Buffer (HEX): Null - No bytes recieved' from Daly HV BMS every 8 or so seconds.
But communication works.

@ai-republic
Copy link
Owner

Hi @KelasHA00,
great to hear you got it working and thanks for the donation!!!
Yes, the message 'Next frame: Buffer (HEX): Null - No bytes recieved' is normal. Occasionally the read frame buffer has not been received yet or is not fully filled with frame bytes.

Your suggestion is great to add a Wiki page documenting which binding works with which BMS and which Inverter!
Thanks I will definitely create that and always great to get feedback to make it more complete.

@KelasHA00
Copy link

Well, the description in the Inverter settings leads to think the Growatt Can is the correct one. But i guess it only applies to LV Growatt inverters. I spend quite some hours double checking my wiring and resetting the Pi.

The daly only works on rs485, but should be able to communicate on Can also.
I have some Pi 4bs and both the waveshare 2ch can and rs485 can hat i can test on.
Is this something we can look into?

@KelasHA00
Copy link

KelasHA00 commented Jun 22, 2024

One issue i just noticed now is, the inverter is mostly idling the battery when using Lithium setting.
In the log its reporting 'dis-/charge-state: stationary.

Battery at 40% and no change when excess power should trigger a charge.
And no discharge when load is introduced.
i will monitor the behavior over the day when more sun is available.

Daly is a HV / 48s LiIon series the Inverter a SPH TL3 BH UP running firmware YA1.0.

@ai-republic
Copy link
Owner

Well, the description in the Inverter settings leads to think the Growatt Can is the correct one. But i guess it only applies to LV Growatt inverters. I spend quite some hours double checking my wiring and resetting the Pi.

The daly only works on rs485, but should be able to communicate on Can also. I have some Pi 4bs and both the waveshare 2ch can and rs485 can hat i can test on. Is this something we can look into?

Yes, the CAN protocol works definetly better with the Daly. I have also 8 Daly's running via the Waveshare 2CH CAN hat on my RPI 4B. Must make sure that the Daly is really a CAN-enabled version (they do advertise CAN but need it specifically enabled on ordering), otherwise you're stuck with RS485.

@ai-republic
Copy link
Owner

ne issue i just noticed now is, the inverter is mostly idling the battery when using Lithium setting. In the log its reporting 'dis-/charge-state: stationary.

Battery at 40% and no change when excess power should trigger a charge. And no discharge when load is introduced. i will monitor the behavior over the day when more sun is available.

Daly is a HV / 48s LiIon series the Inverter a SPH TL3 BH UP running firmware YA1.0.

Have you checked the maximum discharge voltage for you Daly? This might cut off at 40% charge.

@ai-republic
Copy link
Owner

Closing this issue since I have not heard anything for a long time. Please create a new issue if you encounter any problems.

@funkydeo
Copy link

funkydeo commented Aug 9, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants