Check this DIY:
http://forum.e46fanatics.com/showthread.php?t=451510
BTW, the battery is rechargeable and is charged by the ring antenna when the key is in the ignition. Would be usefull to swap your key and spare key sometimes to maintain battery level.