Sketch wont compile,arduino mega

Hi would anyone know why the below code wont compile,it somes up with the following error

exit status 1
no matching function for call to ‘VEDirect::VEDirect(HardwareSerial&)’

Iam using arduino ide and have Auruino mega seletced as the current board…Below is the code.
Thanks

#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);
}

2 Likes

Hi Sunone,

Welcome to the forum!!

For this you will have to step into the libraries code itself, the .h file contains most of the function declarations and the .c file has the substance of them, I’m not certain how this library works but the error would be coming from line 10.

Liam.

1 Like

Thanks liam,ill have a look

1 Like

Thanks Jim,ill look into it

@Sunone
Deleted my previous posts as they are irrelevant, they were the process I went through to find a solution.

I recommend using the Arduino IDE for any libraries because they are most likely to be updated and debugged. However there are other libraries, often on GitHub, that have not made it into the Arduino IDE for whatever reason. These libraries could be under development and can be downloaded as a .zip file; allowing them to be added to the local Arduino IDE.

I found 3 libraries related to VEDirect all using the same keywords. (makes for a confusing situation)
Each of the libraries uses a different way to implement VEDirect.

The library, linked below, worked to compile your code. The others did not. A successful compile does not mean the program will actually work with the device, but it is a good start.

Because the libraries use the same keywords they cannot all be loaded in the Arduino IDE at the same time. The steps below is what I did to make it work.

  1. Closed the Arduino IDE.
  2. Removed the VEDirect library loaded by the Arduino IDE.
    On my PC it was located in /documents/Arduino/libraries/VEDirect
    Delete the folder VEDirect, renaming it will not work, the Arduino IDE will find it when started.
  3. Download the .zip file from the GitHub library. Click on the green Code button and Download Zip.
  4. Start the Arduino IDE.
  5. Select menu option Sketch / Include Library / Add .ZIP Library...
    Find the .zip file dowloaded at step 3 and open it. After a few seconds it should say library added.
    In the libraries it will be listed as VictronVEDirectArduino, clicking it will add #include <VEDirect.h> at the top of your code.
  6. Remove the line #include “VEDirect.h” from your code.

There are other ways to do this and the libraries are not extensive and could be added as separate .h & .cpp files the project.

Note: even though a different name is used for the library folder, the keywords file in the library has KEYWORD1 as VEDirect for all 3 libraries. (not a good idea) KEYWORD1 is how the Arduino IDE identifies a library. It should be unique for all libraries.

Hope this has helped.
Cheers
Jim

3 Likes

Thanks for this Jim very detailed,I’ll have a look at it

4 Likes

@ James46717
Thanks for looking at this it now compiles and works

3 Likes

try copy paste the error into a google window see what it spits out also auduino must have a forum try posting there … im a bit late but often you can find much help just by googling them

2 Likes