-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Hi,
I'm hoping to use an Arduino to read the VPV reading from MPPT, then to use this to vary the speed of a small motor - creating an artwork that encourages interaction with a solar panel to see how it affects the voltage generated.
V happy to find your library and code as a starting place, thank you @StrathbogieBrewing ! However... I'm having problems getting it to work, please could you help.
I'm using an Arduino Uno so have added SoftwareSerial. At the moment it's coming up with the error ''class VEDirect' has no member named 'update' - it also doesn't like 'ping'.
Grateful for your help!
Thank you
`#include "VEDirect.h"
#include "SoftwareSerial.h"
// VE Direct Plug
// ┏━━ ━━┓
// ┃ 1|2|3|4 ┃
// ┗━━━━━━━━━┛
// 1. GND
// 2. VE.Direct-RX - connects to Arduino TX1
// 3. VE.Direct-TX - connects to Arduino RX1
// 4. Power +
#define rxPin 7
#define txPin 8
SoftwareSerial mySerial (7, 8); //RX, TX
//VEDirect mppt(rxPin, txPin); //not sure if this is needed?
void mpptCallback(uint16_t id, int32_t value);
VEDirect mppt(mySerial, mpptCallback); //changed from serial1 to mySerial
uint16_t panelVoltage = 0;
uint16_t chargeCurrent = 0;
void setup() {
mySerial.begin(57600); //software serial - listening to MPPT
Serial.begin(9600); //hardware serial - talking to PC serial monitor
mppt.begin();
}
void loop() {
static unsigned long secondsTimer = 0;
mppt.update();
unsigned long m = millis();
if(m - secondsTimer > 1000L){
secondsTimer = m;
mppt.ping(); // send ping every second
}
}
void mpptCallback(uint16_t id, int32_t value) {
if (id == VEDirect_kPanelVoltage){
panelVoltage = value;
Serial.print(F("Vpv : "));
Serial.println(value * 0.01);
}
if (id == VEDirect_kChargeCurrent){
chargeCurrent = value;
Serial.print(F("Ich : "));
Serial.println(value * 0.1);
}
}`