This paper presents a versatile heterogeneous sensor network simulator library that incorporates an online power model for real-time resource management research projects. The library integrates a well-known multi-agent simulator library Swarm, a popular sensor operating system, TinyOS, and a sensor network simulator tool called TOSSIM. The motivation of designing our library is to address difficulties in studying large-scale wireless sensor networks with energy constraints. The library supports the non-linear energy model used in PowerTOSSIMz, but unlike PowerTOSSIMz, which only supports an offline post-processing battery simulation, our library provides an online energy model. Furthermore, the integration with Swarm enables rich features of the Swarm libraries such as run-time probes, pre-defined simulation environments, data collection and analysis tools, powerful random number generators, and graphical user interfaces. We also enhanced TOSSIM so that heterogeneous TinyOS applications can be executed on simulated sensor nodes. Furthermore, the same source codes that run on the simulator can be deployed on actual hardware sensor nodes supporting an easier hardware/software co-design. The resulting simulator library, SWARM-eTOSSIM, provides versatile visualization tools for diagnostic analysis and a development environment for heterogeneous applications with consideration of real-time energy constraints.