Skip to content

Commit b3d7f82

Browse files
committed
nicla-system: Add error messages to sketch.
1 parent b16d5ea commit b3d7f82

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

libraries/Nicla_System/examples/NiclaSenseME_BatteryStatus/NiclaSenseME_BatteryStatus.ino

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,23 @@ bool updateBatteryLevel() {
5858
updateTimestamp = millis();
5959
auto percentage = nicla::getBatteryVoltagePercentage();
6060

61-
if (percentage < 0) {
62-
return false; // Percentage couldn't be determined.
61+
if (percentage < 0) {
62+
Serial.println("Battery voltage percentage couldn't be determined.");
63+
return false;
6364
}
6465

6566
// Only if the percentage has changed, we update the values as they depend on it.
6667
if (batteryPercentage != percentage) {
6768
int8_t currentChargeLevel = static_cast<int8_t>(nicla::getBatteryChargeLevel());
6869
if(currentChargeLevel == 0){
69-
return false; // Unknown battery charge level.
70+
Serial.println("Battery charge level couldn't be determined.");
71+
return false;
7072
}
7173

7274
auto currentVoltage = nicla::getCurrentBatteryVoltage();
7375
if(currentVoltage == 0){
74-
return false; // Unknown battery voltage.
76+
Serial.println("Battery voltage couldn't be determined.");
77+
return false;
7578
}
7679

7780
batteryPercentage = percentage;

0 commit comments

Comments
 (0)