Wireless sensor networks have a wide range of applications and are deployed in increasingly varied situations. Many deployments have focused on long term monitoring, which uses nodes that are delay-tolerant and depend on low-power sleep to minimize the energy consumption and extend operational lifetime. These nodes often have many software modules contending for system resources, making both software development and power management difficult. These challenges call for middleware layers that are different from those for real-time, dense networks. This middleware must be flexible to accommodate and control the vast variety of available hardware peripherals and software applications, as well as to provide simple methods to manage a node's energy consumption. It must also provide an easy-to-use interface for software modification and at the same time take advantage of the long idle periods typically experienced by delay-tolerant sensor nodes.The middleware we propose in this paper is designed for long-term use in delay-tolerant networks. Our middleware keeps a unique system time for more than one year, offering very long-term event scheduling. This middleware takes advantage of the low node utilization of long-term networks and executes software modules in sequence. This avoids complexities in context switching of multiple threads on a single threaded processor, and improves the simplicity of software implementation. Our middleware has a small code footprint of less than 3.5KB, as well as very low scheduling overheads of less than 40 μs to run scheduled applications. This structure also allows the system energy to be centrally managed by the middleware, which minimizes node power consumption and simplifies real world software development.