pmcg31 / esp32_victron_test

Contains an Arduino project for Espressif ESP32 that will run a web server with web sockets to display data from a Victron MPPT charge controller in real time.
22 stars 2 forks source link

No data although serial comm. is working with MPPT #3

Open Peemouse opened 3 years ago

Peemouse commented 3 years ago

Hi,

I can't see any data on the web page from ESP32 although I successfully receive data if I upload a basic "Serial pass-though" sketch to the ESP32 hooked to a 75/15 MPPT. Could you point me out how to troubleshoot ?

It would have been great to add some debug over serial to know how things are going in the ESP32.

Anyway, thanks for this nice project !

Clément LP

pmcg31 commented 3 years ago

Hi,

I can't see any data on the web page from ESP32 although I successfully receive data if I upload a basic "Serial pass-though" sketch to the ESP32 hooked to a 75/15 MPPT. Could you point me out how to troubleshoot ?

It would have been great to add some debug over serial to know how things are going in the ESP32.

Anyway, thanks for this nice project !

Clément LP

Which serial port on the ESP are you connecting the solar controller to? This code is expecting to use serial port 2 for this. Debug output is produced over serial port 0 (the default serial port connected to the usb if you're using a dev board; it is on GPIO1 & 3 for tx & rx). Serial port 2 is GPIO 17 & 16 for tx & rx. This is explained in more detail in the readme.

Did you update the config.json file in the data directory with the WiFi credentials for your network? Is the ESP connecting? WiFi progress is logged to serial port 0. This should be displayed in the serial monitor in the Arduino IDE.

There isn't any logging for the victron activity, but you could easily add this in the loop function.

I'm just curious; what is the goal you're working toward regarding talking to the charge controller?

--Rich

Peemouse commented 3 years ago

I connected the MPPT to the Serial2. The ESP32 connects successfully to my wifi network, I can see the web page with the orange background but no data are displayed next to the voltage or current labels. I can see also the debug on serial port 0 (serial monitor on PC), everything goes ok. I commented out the last lines but it doesn't compile. Commenting out only the first "serial.print("Updates available, sending: ");" makes it appear on the serial monitor, but only once. Still no data on the web page.

My project is to build a dashboard to monitor and control my van (electricity, water, lights, temperatures and so on).

Clément

pmcg31 commented 3 years ago

If you look at the javascript on the web page it serves you can see the craziness it does to figure out where the websocket server is. You could hardcode that part. I've had issues with a different project connecting to the websocket when I don't have an internet connection. That would explain the lack of data.

I don't know why you would only get a single shot of output. Did you also comment in the json line below it? Did whatever data you got look correct?

My project plans are the same.

I have not run this code for a long time, and it has now been re-organized into a new project on here called ve.direct-temp-mqtt. There is also ve.direct-hex-mqtt which implements the hex protocol and allows changing settings on charge controllers or bmv. Both projects need a discovery server which I have not uploaded the code for yet, but I can. I run that and the mqtt broker on a raspberry pi. Node-RED provides the web interface from the pi for now. Both are a work in progress. I need to get back to them. I had one of my charge controllers fail right after plugging/unplugging my esp32 stuff. Thankfully victron replaced it for free. I think it was just a coincidence (because they are replacing any controller that gets the error mine threw, which has to do with current sensing), but I've been afraid to mess with them since then!

Even if you don't have an mqtt server or a pi around, you could still try the new code pretty easily because all of the victron stuff has been encapsulated into classes. I'm using PlatformIO now instead of Arduino IDE, but the classes for the victron stuff would still work just fine if you add all the hpp and cpp files to a new arduino project. Same goes for the main code, which is called main.cpp under PlatformIO. You can simply rename it to .ino, where "your-project-name" is the name of the arduino project (and directory) you created.

There is no serial logging in those projects because they are set up to use all 3 hardware serial ports to talk to 3 different victron devices at the same time (a bmv and two mppt controllers in my case).

You could easily change that at the end of setup() by changing the first input to the serial port you are using and commenting the other two out. Then fix the for loop in loop() to not count all the way up to 3, just 1 or 2 depending on how many you connect. There will someday be a variable to control that...

You would have to comment a few other things out as well, unless you happen to be using an Si7021 temp/humidity sensor.

Anyway, try some of that if you want and let me know where you're getting hung up and we'll figure it out!

--Rich

Peemouse commented 3 years ago

Hi, Thanks for your detailed reply.

Did you also comment in the json line below it? Did whatever data you got look correct?

I obtained this result. But not only once, it updates periodically this time.

Updates available, sending: {
  "i": "-20",
  "i_units": "mA"
}

FYI, I run the MPPT on a lab power supply, powered on battery side, no PV panels connected. I'm wondering why only the current is sent in the update.

Here is a snap of raw text sent by the MPPT :

PID.0xA053
FW.154
SER#.HQ2022BSCQY
V.14010
I.-10
VPV.10
PPV.0
CS.0
MPPT.0
OR.0x00000001
ERR.0
LOAD.ON
IL.0
H19.0
H20.0
H21.0
H22.0
H23.0
HSDS.0
Checksum.÷

The current value matches the one your sketch update. But only this one is recognized. Anyway.

On my project, I'm not sure I'll implement a web interface (I know basically nothing of HTML, javascript...) only C (and even tho, at an intermediate level). However, as I'm a huge fan of Open Source projects, I want to build one with a HW board and SW for those who don't know anything into electronics but still want to add a "central brain" to their van for making their life easier.

If you're interested to join the project, it would be a great pleasure !

Clément

pmcg31 commented 3 years ago

I believe this version of the code only sends fields that have changed. If you don't have any panels attached, most of the fields wouldn't change and so it makes sense that maybe only the current was fluctuating a little. It still should have shown you everything once, so I'm not sure what happened there.

One thing I've noticed is that after uploading new code, the serial monitor can sometimes take a second to connect again. Sometimes I don't see the first few messages when this happens. Could you try resetting your esp board with the monitor running so we're sure you get everything? This probably isn't the problem, but I don't have any other ideas at the moment.

Given what you said about html, look up mqtt and node-red. The new version of this code is using mqtt to send out its data. Once in that form, there are lots of tools already out there to consume it. One of those tools is node-red, and it lets you manipulate the data using a concept called a flow and also has facilities for creating a decent web interface without any programming.

The architecture I'm currently shooting for has a bunch of esp32s gathering data/controlling whatever systems I want to integrate and a raspberry pi running node-red to manage it all. That could change if I learn of a better framework, but out of what I've learned so far this looks like the best course, at least for me.

Please have a look at the newer projects, ve.direct-temp-mqtt or ve.direct-hex-mqtt. Those are the ones I will be actively developing from here forward, specifically the hex version.

We are both heading for the same goal, so in a way we are joined already! I'd be happy to share information and code along the way.

--Rich