Skip to content

Battery

RoboBoard X3 Servo motor ports

RoboBoard can be powered from standalone battery to run whole circuit and motors. Also features charging and state monitoring.

  • RoboBoard X3 - 3.7V 250mAh Li-Po (2 Amps peak)
  • RoboBoard X4 - 11.1V 2200mAh Li-Ion (6 Amps peak)

Code snippets

// Initialize program
void setup() {
  Serial.begin(115200);
}
// Loop program
void loop() {
  // Print battery info
  Serial.printf("SOC: %d%%\n", Battery.getSOC());
  Serial.printf("Voltage: %.2fV\n", Battery.getVoltage());
  if (Board.getNumber() == 3) {
    Serial.printf("Current: %.2fA\n", Battery.getCurrent());
    Serial.printf("Charging: %s\n", Battery.isCharging() ? "Yes" : "No");
  }
  // Wait 1 second
  delay(1000);
}

Functions

Status

Functions to read battery status.

SOC Battery.getSOC()

Get battery State Of Charge (voltage based).
Returns:
SOC - battery charge level [0:100]%.

voltage Battery.getVoltage()

Get battery voltage.
• X3: range [2.6:4.2]V. Shows ~4.8 if USB connected.
• X4: range [8.40:12.60]V
Returns:
voltage - battery voltage (float).

amps Battery.getCurrent() X3 only

Get battery current flow (Amps). -(discharging), +(charging).
Returns:
amps - battery current (float) [-2.0:0.5]A.

state Battery.isCharging() X3 only

Check if battery is currently charging.
Returns:
state - is charging yes/no [true:false].