In this paper, the problem of distributed resource allocation is studied for an Internet of Things (IoT) system, composed of a heterogeneous group of nodes compromising both machine-type devices (MTDs) and human-type devices (HTDs). The problem is formulated as a noncooperative game between the heterogeneous IoT devices which seek to find the optimal time allocation so as to meet their quality-of-service (QoS) requirements in terms of energy, rate, and latency. Since the strategy space of each device is dependent on the actions of the other devices, the generalized Nash equilibrium (GNE) solution is first characterized, and the conditions for uniqueness of the GNE are derived. Then, to explicitly capture the heterogeneity of the devices, in terms of resource constraints and QoS needs, a novel and more realistic game-theoretic approach, based on the behavioral framework of cognitive hierarchy (CH) theory, is proposed. This approach is then shown to enable the IoT devices to reach a CH equilibrium (CHE), a concept that takes into account the various levels of rationality corresponding to the heterogeneous computational capabilities and the information accessible for each one of the MTDs and HTDs. Simulation results show that the CHE solution maintains a stable performance. In particular, the proposed CHE solution keeps the percentage of devices with satisfied QoS constraints above 96% for IoT networks containing up to 10000 devices without considerably degrading the overall system performance in terms of the total utility. Simulation results also show that the proposed CHE solution brings a two-fold increase in the total rate of HTDs and deceases the total energy consumed by MTDs by 78% compared with the equal time policy.