datjan / esp8266-victron-mppt-solarchargecontroller

This is a online information server with rest api based on esp8266 and Victron Solar MPPT Solar Charge Controller
MIT License
9 stars 1 forks source link

Problem with software serial? #1

Open jdrescher2006 opened 1 year ago

jdrescher2006 commented 1 year ago

First I want to say thank you for this solution and all your work.

My problem is that it just doesn't work, I am quite sure that I did everything right. The actual guess is that the esp8266 has a quite bad software serial and is not capable to receive the correct data from victron device (MPPT 75/15).

For debug purposes, I modified the code in function RecvWithEndMarker like so: rc = victronSerial.read(); Serial.println("Daten empfangen!"); Serial.println(rc);

The output of this looks strange: image

I am sure that I have the same hardware as you have. Here is my setup: image

Do you have any idea what could be the problem?

jdrescher2006 commented 1 year ago

After a bit of investigating, I found two problems (maybe there are even more):

jdrescher2006 commented 1 year ago

So my current situation is the following:

I am sure that the data flowes porperly from the 75/15 to the ESP-01. But for some reason the parsing is not successful. The data packet is much larger than from the Phoenix device, that may also cause problems.

rin67630 commented 11 months ago

Just a remark I had as I begun looking at your code. Your need SoftwareSerial because you need a second UART to communicate with the device, right? It is much more elegant to use the library Telnetstream for the user communication with the ESP over WiFi (you "print" to Telnet instead) which liberates the serial hardware UART to read efficiently from the Victron MPPT port. After initialisation, the hardware UART is switched to D7 / D8 with the command Serial.swap() That solves your timing/performance problem and you don't even need a cable to your ESP to read the data.

rin67630 commented 11 months ago

I have tested a version using Serial.swap() instead of SoftwareSerial. The serial communication to the user happens over Telnet. Works perfectly and is ways faster. See my pull request. Else you can see my fork here: https://github.com/rin67630/esp8266-victron-mppt-solarchargecontroller-Telnet/tree/main Regards

rin67630 commented 10 months ago

P.S. If you have reasons not to use Telnet and want absolutely to use serial communication, may I suggest to use Serial.swap() to let the hardware UART process the flow of data coming from the VE port and use SoftwareSerial to communicate with the user. The later is not demanding on Rx like the VE port is.