Battery#

Introduction#

The battery class is derived from the brain base class and provides access to the IQ (1st gen) Brain’s battery, allowing your robot to monitor capacity, voltage, current draw, power usage, temperature, and efficiency.

Access#

Brain.Battery

Member Functions#

The battery class includes the following member functions:

  • capacity — Returns the brain’s remaining battery capacity.

  • voltage — Returns the battery voltage.

  • current — Returns the battery current draw.

Before calling any battery member functions, a brain instance must be created, as shown below:

// Create the Brain
brain Brain = brain();

capacity#

Returns the remaining capacity of the IQ (1st gen) Brain battery.

Available Functions
uint32_t capacity( 
  percentUnits units = percentUnits::pct );

Parameters

Parameter

Type

Description

units

percentUnits

Optional. The unit used to represent battery capacity: pct / percent — percent

Return Values

Returns a uint32_t representing the remaining battery capacity as a percentage from 0 to 100.

voltage#

Returns the voltage of the IQ (1st gen) Brain battery. Voltage is the electrical pressure supplied to the battery, which can help you check whether the battery is charged enough for the robot to run reliably.

Available Functions
double voltage( 
  voltageUnits units = voltageUnits::volt );

Parameters

Parameter

Type

Description

units

voltageUnits

Optional. The unit used to represent voltage: volt (default) — volts, or mV — millivolts

Return Values

Returns a double representing the battery voltage in the specified units, ranging from 7.0 to 8.0 V or 7000 to 8000 mV.

current#

Returns the electrical current drawn from the IQ (1st gen) Brain battery. Current is how much electrical flow the robot is using from the battery, which can help you see how hard the robot is working or whether motors may be under extra load.

Available Functions
double current( currentUnits units = currentUnits::amp );

Parameters

Parameter

Type

Description

units

voltageUnits

Optional. The unit used to represent current: amp (default) — amperes

Return Values

Returns a double representing the electrical current drawn from the IQ (1st gen) Brain battery in amperes, ranging from 0.0 to 15.0 Amps.