The leJOS Tutorial

| Start of Tutorial > Start of Trail

Trail: Essential leJOS classes
Lesson: Utilities

# Utilities: Battery

While your robot depends on the charge of its energy supplier, i.e. the batteries, at times you might feel the urge for dynamically checking this (and maybe returning home when battery charge is low).
To do so, you can use the static methods of the `josx.platform.rcx.Battery` class:

- `public static int getVoltageMilliVolt()` delivers the current charge in mV
- `public static float getVoltage()` delivers the current charge in Volt

For rechargable batteries a value of 7.5 V is common, for non-rechargable ones it is 9 V.
As a rule a rapidly decreasing value prods to the batteries becoming drained.

When switching on the RCX, the LCD shows the actual charge also.

## The Battery API

may be found here.

The leJOS Tutorial

| Start of Tutorial > Start of Trail