Hello every one,
I am trying to get the Power Shield going, but I am not having the results I expect. Here is a little code that I wrote.
// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>
#include "PowerShield.h"
//#include "Particle.h" // C++ Preprocessor will not need to add it automatically
//#include "Arduino.h" // Added to support extended Arduino APIs
BlynkTimer timer;
char auth[] = "xyxyxyxyxyyxyxyx";
PowerShield batteryMonitor;
void setup()
{
Blynk.begin(auth, IPAddress(111,222,333,444), 8080);
batteryMonitor.begin(); // This essentially starts the I2C bus
batteryMonitor.quickStart(); // This sets up the fuel gauge
timer.setInterval(1000, CheckBattery);
}
void CheckBattery()
{
float cellVoltage = batteryMonitor.getVCell(); // Read the volatge of the LiPo
float stateOfCharge = batteryMonitor.getSoC();// Read the State of Charge of the LiPo
Blynk.virtualWrite(V0, "Voltage : ", cellVoltage, "\n");
Blynk.virtualWrite(V1, "Charge : ", stateOfCharge , "\n");
}
void loop()
{
Blynk.run();
timer.run();
}
This line:
Blynk.virtualWrite(V0, "Voltage : ", cellVoltage, "\n");
is suppose to show me the actual voltage of the battery, am I right? Instead, I get a permanent 5 volts indicator, then the battery runs out of power, and that’t it. How can I get the actual voltage?
Thanks.