  Today's IoT devices rely on batteries, which offer stable energy storage but
contain harmful chemicals. Having billions of IoT devices powered by batteries
is not sustainable for the future. As an alternative, batteryless devices run
on long-lived capacitors charged using energy harvesters. The small energy
storage capacity of capacitors results in intermittent on-off behaviour.
Traditional computing schedulers can not handle this intermittency, and in this
paper we propose a first step towards an energy-aware task scheduler for
constrained batteryless devices. We present a new energy-aware task scheduling
algorithm that is able to optimally schedule application tasks to avoid power
failures, and that will allow us to provide insights on the optimal look-ahead
time for energy prediction. Our insights can be used as a basis for practical
energy-aware scheduling and energy availability prediction algorithms. We
formulate the scheduling problem as a Mixed Integer Linear Program. We evaluate
its performance improvement when comparing it with state-of-the-art schedulers
for batteryless IoT devices. Our results show that making the task scheduler
energy aware avoids power failures and allows more tasks to successfully
execute. Moreover, we conclude that a relatively short look-ahead energy
prediction time of 8 future task executions is enough to achieve optimality.
