Abstract:With the development of the Internet of Things (IoT), efficient consensus algorithms are the key to applying blockchain technology to the IoT. This study proposes an improved PBFT consensus algorithm based on the binary K-means practical Byzantine fault tolerance algorithm (BK-PBFT) to address the issues of high communication times, lack of consideration for consensus power consumption, and high consensus latency in IoT scenarios. Firstly, it obtains the geographic coordinates of the nodes, calculates the comprehensive evaluation values of the nodes, and divides the nodes into a two-layer multi-center clustering cluster by the binary K-means algorithm. Then, PBFT consensus is performed on the blocks in the lower-level cluster and then in the upper-level cluster. Finally, the cluster validates and stores the blocks to complete the consensus. Additionally, this study proves that the algorithm can achieve the minimum number of communication times when nodes are evenly distributed in each cluster, and obtain the optimal cluster number under the least communication times. The analysis and simulation results show that the proposed algorithm can effectively reduce communication times, consensus power consumption, and consensus latency.