Temperature detection for battery charging