IPv6 over low power wireless personal area network (6LoWPAN) is promising to be used in many different IoT applications. Recently, many protocols have been proposed for 6LoWPAN networks such as RPL routing protocol which is developed by the ROLL working group and expected to be the standard routing protocol for 6LoWPAN. Many problems are facing 6LoWPAN as it connects to the Internet such as congestion. In this paper, we propose a new RPL routing metric called Buffer Occupancy which reduces the number of lost packets due to buffer overflow when congestion does occur. Also, a new RPL objective function called Congestion-Aware Objective Function (CA-OF) is presented. The proposed objective function works efficiently when congestion occurs by selecting less congested paths. Simulation results show that CA-OF improves performance in the presence of congestion by an overall average of 37.4% in term of number of lost packets, throughput, packet delivery ratio and energy consumption.