Optimizing the Battery Energy Efficiency in Wireless Sensor Networks