Macro programming a distributed system, such as a sensor network, is the ability to specify application tasks at a global level while relying on compiler-like software to translate the global tasks into the individual component activities. Bayesian networks can be regarded as a powerful tool for macro programming a distributed system in a variety of data analysis applications. In this paper we present our architecture to program a sensor network by means of Bayesian networks. We also present some applications developed on a microphone-sensor network, that demonstrate calibration, classification and anomaly detection.