Abstract : Smart buildings and smart cities rely on interconnected sensor networks that collect data about their environment to support various applications. Developing and deploying the data collection architectures of these systems is a challenging problem. The specificities of the sensor platforms compel software engineers to work at a low level. This makes this activity tedious, producing code that badly exploits the network architecture, and hampering reuse of data collection policies. Moreover, several data collection programs cannot be guaranteed to be deployable on a shared infrastructure. In this paper, we present an automated approach that supports (i) the definition of data collection policies at a higher level of abstraction, (ii) the representation of the diverse platforms and the network topology, and (iii) the automatic composition and deployment of the policies on top of heterogeneous sensing infrastructures following different strategies. The approach is tooled and has been assessed on both realistic and simulated deployments.