Actualizing Internet of Things undoubtedly constitutes a major challenge of modern computing and is a promising next step in realizing the unification of all seamlessly interacting entities, either human users or participating machines, under a shared, coherent architecture. While it has now become common belief that the related solutions should be based on compatible network infrastructure employing widely accepted communication schemes, the specifics of the intermediate system that would act as global interface for all involved "things" are yet to be determined. A rising trend to define such machine-based entities is through cyberphysical systems, in terms of collaborating elements with physical input and output. Certainly, sensor networks constitute the most representative realization of such systems. Taking these issues and opportunities under consideration, this work proposes a bioinspired distributed architecture for an Internet of Things that exhibits self-organization properties to enable efficient interaction between entities modeled as cyber-physical systems, mainly focusing on sensor networks. Furthermore, a middleware has been implemented according to the proposed architecture, which serves the role of the backbone of this network as a multiagent and autonomous distributed system. The evaluation results demonstrate the self-optimization properties of the introduced scheme and indicate global network convergence.