Wireless Sensor Actuator Networks (WSANs) extend wireless sensor networks through actuation capability. Designing robust logic for WSANs however is challenging since nodes can affect their environment which is already inherently complex and dynamic. Fixed (offline) logic does not have the ability to adapt to significant environmental changes and can fail under changed conditions. To address this challenge, we present In situ Distributed Genetic Programming (IDGP) as a framework for evolving logic post-deployment (online) and implement this framework on a physically deployed WSAN. To demonstrate the features of the framework including individual, cooperative and heterogeneous evolution, we apply it to two simple optimisation problems requiring sensing, communications and actuation. The experiments confirm that IDGP can evolve code to achieve a system wide objective function and is resilient to unexpected environmental changes. Categories and Subject Descriptors I.2.2 [Computing Meth...