Sensor networks empower Internet of Things (IoT) applications by connecting them to physical world measurements. However, the necessary use of limited bandwidth networks and battery-powered devices makes their optimal configuration challenging. An over-usage of periodic sensors (i.e. too frequent measurements) may easily lead to network congestion or battery drain effects, and conversely, a lower usage is likely to cause poor measurement quality. In this paper we propose a middleware that continuously generates and exposes to the sensor network an energy-efficient sensors configuration based on data live observations. Using a live learning process, our contributions dynamically act on two configuration points: (i) sensors sampling frequency, which is optimized based on machine-learning predictability from previous measurements, (ii) network usage optimization according to the frequency of requests from deployed software applications. As a major outcome, we obtain a self-adaptive platform with an extended sensors battery life while ensuring a proper level of data quality and freshness. Through theoretical and experimental assessments, we demonstrate the capacity of our approach to constantly find a near-optimal tradeoff between sensors and network usage, and measurement quality. In our experimental validation, we have successfully scaled up the battery lifetime of a temperature sensor from a monthly to a yearly basis.