ESP 32 & Victron VEDirect library - SERIAL problem

Hello!
I am trying to use the VEDirectArduino library https://github.com/winginitau/VictronVEDirectArduino with an ESP32 to read the values of a victron MPPT. Issue is this line:

// VEDirect instantiated with relevant serial object
VEDirect myve(Serial3);

No matter what I put there, I will never get it to compile. I tried using the HardwareSerial library, creating an object and using it but also, no luck.

What am I missing?

Thanks for any advice!

The first thing is the compiler error report as well as post the entire code.

Okay, here is the code, it is basicall the example from the library:

/******************************************************************
 VEDirect Arduino
 Copyright 2018, 2019, Brendan McLearie
 Distributed under MIT license - see LICENSE.txt
 See README.md
 File: ReadVEDirect.ino / ReadVEDirect.cpp
 - Provides example use of the VEDirect library
******************************************************************/

#include "Arduino.h"
#include "VEDirect.h"

// 32 bit ints to collect the data from the device
int32_t VE_soc, VE_power, VE_voltage, VE_current;
// Boolean to collect an ON/OFF value
uint8_t VE_alarm;

// VEDirect instantiated with relevant serial object
VEDirect myve(Serial3);

void setup() {
	Serial.begin(9600);		// Adjust as needed
}

void loop() {
	Serial.println("Reading values from Victron Energy device using VE.Direct text mode");
	Serial.println();

	// Read the data
	if(myve.begin()) {									// test connection
		VE_soc = myve.read(VE_SOC);
		VE_power = myve.read(VE_POWER);
		VE_voltage = myve.read(VE_VOLTAGE);
		VE_current = myve.read(VE_CURRENT);
		VE_alarm = myve.read(VE_ALARM);
	} else {
		Serial.println("Could not open serial port to VE device");
		while (1);
	}

	// Print each of the values
	Serial.print("State of Charge (SOC): ");
	Serial.println(VE_soc, DEC);
	Serial.print("Power:                 ");
	Serial.println(VE_power, DEC);
	Serial.print("Voltage                ");
	Serial.println(VE_voltage, DEC);
	Serial.print("Current                ");
	Serial.println(VE_current, DEC);
	Serial.print("Alarm                  ");
	Serial.println(VE_alarm, DEC);
	Serial.println();

	// Copy the raw data stream (minus the \r) to Serial0
	// Call read() with a token that won't match any VE.Direct labels
	Serial.println("All data from device:");
	myve.read(VE_DUMP);
	Serial.println();
	delay(10000);
}

This is the line giving me problems. I changed from Serial3 to Serial2, neither work

VEDirect myve(Serial2);

The error is:

no matching function for call to 'VEDirect::VEDirect(HardwareSerial&)'

Fine. Thanks.

Using the link in Your first post I found this:

Usage:

#include "VEDirect.h" 
VEDirect my_bmv(Serial3); 
my_int32 = my_bmv.read(VE_SOC);

As I can see You have not installed the VEdirect library correctly.

Take a few moments and inspect the Arduino/library. There You should see other libraries. Do You find the VEDirect there?

Thank you for your reply! I checked everything and the library was in the /Arduino/library folder - but its name was

VictronVEDirectArduino

I deleted the "Arduino" from the end and recompiled - now it seems to work.
Was that the mistake you saw? And - How could you determine that from just the code? Curious to learn for next time :slight_smile:

I didn't guess that, rather that the Victro.... folder was saved somewhere else or installed the wrong way. Copy and paste criss cross the folders might fail...

Well done!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.