Improving quality of service (QoS) of low power and lossy networks (LLNs) in internet of things (IoT) is a major challenge. Cluster-based routing technique is an effective approach to achieve this goal. This paper proposes a QoS-aware clustering-based routing (QACR) mechanism for LLNs in Fogenabled IoT which provides a clustering, a cluster head (CH) election, and a routing path selection technique. The clustering adopts the community detection algorithm that partitions the network into clusters with available nodes' connectivity. The CH election and relay node selection both are weighted by the rank of the nodes which take node's energy, received signal strength, link quality, and number of cluster members into consideration as the ranking metrics. The number of CHs in a cluster is adaptive and varied according to a cluster state to balance the energy consumption of nodes. Besides, the protocol uses the CH role handover technique during CH election that decreases the control messages for the periodic election and cluster formation in detail. An evaluation of the QACR has performed through simulations for various scenarios. The obtained results show that the QACR improves the QoS in terms of packet delivery ratio, latency, and network lifetime compared to the existing protocols.