Battery detection