Battery Level NXT-G Block ver. 1.1
NXT Repository/Programming/NXT-G/

This block reads the battery level (in miliVolt) from the UI module IOMAP. It can also be used as a sensor block (for example, placed as a Wait block on a parallel sequence wire followed by commands to go back to docking station for recharging batteries… Anyone cares to implement this?).
UPDATE (April 19 2007) - version 1.1 now has a ‘Rechargeable?’ YES/NO output which tells if NXT uses the NXT Rechargeable Battery (#9798)
Download the block here.