Wireless sensor networks (WSNs) are distributed systems integrated by tiny devices, called sensor nodes, with capabilities to monitor the environment and forward their measurements to a special node, the sink, where the results can be collected and further processed. The trend in WSN is moving towards heterogeneous networks that will contain different sensor nodes running different instances of custom operating systems. Given the growing demand of new hardware platforms and operating systems specifically designed for sensor nodes, the applications programming for sensor nodes is becoming a challenging process that needs to be alleviated. Currently, application programming for sensor nodes is a complex, ad hoc, and error-prone process where the portability among different platforms has been sacrificed. In this paper, we propose an open framework aimed to achieve application portability in heterogeneous sensor networks. Our approach provides the programming abstractions needed to support the application development process for sensor nodes. We have implemented an open framework that provides a set of tools on top of the most popular WSN operating systems to translate portable applications to the native operating system in an automatic, simple, and transparent way for developers. We have also evaluated the applications thus generated in terms of productivity and overhead, by comparing their footprint to those originally developed in each specific operating system. The results show that the overhead is minimal—4% in the worst case—and in some cases, it was even possible to reduce the footprint by using code optimizations. Copyright © 2012 John Wiley & Sons, Ltd.