Skip to content

Add read timeout + character delay#1

Draft
jekkos wants to merge 1 commit intoahpohl:masterfrom
jekkos:master
Draft

Add read timeout + character delay#1
jekkos wants to merge 1 commit intoahpohl:masterfrom
jekkos:master

Conversation

@jekkos
Copy link
Copy Markdown

@jekkos jekkos commented Nov 25, 2023

This PR extracts serial read iterations + character delay as parameters. I had to have my aurora repaired recently due to the common E031 failure. A relay was replaced and I took a further look at the data logging, it's still giving me a lot of read timeouts and CRC errors.

  • I changed the wiring to shielded CAT6 with twisted pair for the differential RS485 pair. Also the shielding is grounded on the adapter's return pin. This seems to be a recommendation from the manual.
  • After doing this, I hardly saw any improvements in the amount of serial errors (timeouts, CRC). I looked at the original aurora tool written by Curtis and he had some params to change the inter character delay, which I also introduced now here.

I'll try to play a bit with thos values to see if they improve the connection reliability a bit.

@jekkos jekkos marked this pull request as draft November 25, 2023 08:49
@ahpohl
Copy link
Copy Markdown
Owner

ahpohl commented Dec 2, 2023

I never had any issues with timeouts on my Aurora and it was running with the hard-coded values for years. I also used shielded CAT7 cable with one pair for the twisted RS485 A+B and another wire for ground. The CAT7 cable shield I left unconnected. Unfortunately the power board of my Aurora died this year and I had to replace the inverter entirely (bought an inverter from Fronius instead). So I cannot test your PR anymore.

If you think these parameters are necessary to change and to provide them via config file, I am happy to accept the PR (and the one for solarmeter). Do you really have to change the inter character delay and max iterations from the hard-coded values? What values to you get now for stable comms? Do they differ much?

@jekkos
Copy link
Copy Markdown
Author

jekkos commented Dec 2, 2023

Thanks for your answer! I was about to try this out now as I found that the communication is a lot less stable since the repair. If the inverter is delivering low power then the solarmeter often does not arrive at delivering any datapoint at all. IWhen I enable the serial logging, then I see it's sending and receiving data over serial.

I'll need to debug a bit further but I also saw that timeout error messages are surpressed](https://github.com/ahpohl/solarmeter/blob/master/src/main.cpp#L98C7-L98C7) after 5 occurences.

Also the changes that I did here were not working. I'll need to run the binary using gdb when the inverter is on to see what's going on;

@kolins-cz
Copy link
Copy Markdown

Hi. My ABB Aurora PVI-12.5-TL-OUTD made in 2019 was not working with anything available until this library. I had some success with python library, but after running it a few hours, inverter got "tired" and stopped answering. Restart did not helped, changing address did.
Then I discovered this library. Example ran for days. I have started to modify it for MQTT when I discovered that there is solarmeter... I had to mess with paths in Makefiles of both projects to compile it on Debian 11 on Pi.
Now it is running very stable for many days. Made systemd service out of solarmeter, so hopefully it would work without any intervention for years to come.

I have noticed that inverter is VERY picky about RS485 converter. Some stupidly made converters do not work (Waveshare CAN & RS485 HAT), cheap USB>RS485 converters without GND and many others have poorly designed direction switching. Well explained here:
https://hackaday.io/project/167532-modbus-things-with-stm8-eforth/log/168474-finding-the-culprit

Converters that do work are USB ones where USB chip has extra pin for direction (some based on FTDI, original Epsolar USB cable ).

Converter that also work is UART to RS485 which have little more evolved circuit for automatic switching. Example of working one:
image

So luckily I do not need to mess with inter-byte delays or what not. Maybe @jekkos has just issues with RS485 converter and not inverter itself?

@jasoncodes
Copy link
Copy Markdown

For what it’s worth, I’m using a very cheap generic USB 2-wire RS485 adapter from eBay with my Aurora PVI-5000-OUTD-S-AU over about 5 meters of speaker wire and it’s reliable enough for my needs. I haven’t opened mine up but it uses a CH340 and looks like the one in the blog post. (Thanks for the link to that. Interesting read.)

I am using telegraf to store all datapoints sent over MQTT by solarmeter to InfluxDB for reporting. An occasional timeout or CRC error in solarmeter’s logs but nothing persistent. Most of the errors seem to correlate with to dips in solar production and/or MPPT sweeps, making me think the occasional errors I see are from the inverter side.

@ahpohl
Copy link
Copy Markdown
Owner

ahpohl commented Feb 29, 2024

Maybe @jekkos has just issues with RS485 converter and not inverter itself?

That could very well be the reason. I had this library and the corresponding solarmeter daemon running for years until my Aurora inverter died. I used the USB to TTL/RS485/RS232 adapter from Waveshare without issues. It's based on the original FT232RL, which is very well supported by the Linux kernel.

@jekkos
Copy link
Copy Markdown
Author

jekkos commented Feb 29, 2024

Interesting, currently I use this adapter. I have the impression that the timeouts only occur when there is not a lot of sun. I thought that maybe this can still be solved in software, by tuning the timeout value once a read timeout occurs. Ofc we should not go slower then the baudrate and keep a bit of margin but it might be worth a try

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

Successfully merging this pull request may close these issues.

4 participants