Optimizing the energy balance to achieve autonomous self-powering for vigilant health and IoT applications