Internet of things (IoT) aims to shift intelligence to things and tends to increase the spectrum utilization efficiency. However, in doing so, it might generate high interference to the primary users (PUs) due to massive data flow into the networks. Cognitive radio smartly addresses this challenge by enabling different spectrum sharing modes while guaranteeing the quality of service. Motivated by this fact, the incorporation of cognitive abilities in IoT has given birth to a new sub-domain in IoT, known as Cognitive IoT (CIoT). This paper considers a single cell scenario in which multiple CIoT users (CUs) coexist with a PU in an underlay environment, and their communication performance has been optimized while adhering to the transmit power and interference constraints. Furthermore, two swarm intelligence-based implementations of the proposed algorithm have been provided, one based on Artificial Bee Colony (ABC) and the other based on Particle Swarm Optimization (PSO), and their effectiveness to solve the constrained power allocation problem for CIoT networks has been proved through simulations.