We have developed a framework to allow Wireless Sensor Network (WSN) devices to evolve their logic during their lifetime in order to adapt to a changing world. Achieving evolutionary computation on such resource-constrained devices is no easy feat. The "In situ Distributed Genetic Programming" (IDGP) framework considers these constraints and exploits the distributed and wireless communications capability inherent in WSNs. By implementing this framework on a physically deployed WSN, we have demonstrated the world's first WSN where motes (the WSN devices) collectively evolve their logic using Genetic Programming. This allows devices in our environments to learn how to sense and act in order to achieve useful outcomes.