Internet of things (IoT) is a modern technology where data can be transmitted to any things (human, animal, or object) over communications networks, whether Internet or intranet. Congestion occurs when the input data rate to the node, higher than the output data rate of node. Congestion control in computer network modulates traffic entry into a network in order to avoid congestive. This paper suggests a method for congestion control in the internet of things in two phases. The first phase is intra-cluster congestion control, which uses two parameters congestion score (CS) and buffer empty space (BES) to congestion avoidance. In this phase based on these two parameters, 9 states are defined to determine the congestion status of each node, and based on these 9 states the appropriate decision is made to the node. The second phase is inter-clusters congestion control. In this phase, after determined cluster head priority, the parameters of back off timer (BFT), waiting time to receive acknowledgment (WTTRACK), sequence number (SEQ) and retransmission counter (RC) are used for congestion control. The proposed congestion control method is simulated by NS-2 software. A comparison between the performance of proposed method and conventional methods shows that applying proposed method results in a significant improvement in average congestion score (CS), packet lost rate, energy consumption and end-to-end delay.