The consensus protocol in heterogeneous opportunistic networks has a wide range of applications in handheld device networking, vehicle networking, and formation control.At present, most of the distributed consensus algorithms are ideally modeled and consider a single factor,But in real life, heterogeneous opportunistic networks need to consider more complex factors, such as node dynamics, delay and packet loss generated by node information transmission process, and deviation caused by the unbalanced nature of the network topology.Aiming at the heterogeneity of heterogeneous opportunistic networks, we propose a quantized caching mechanism, which solves the consensus problem of heterogeneous opportunistic networks .And the optimal number of cache blocks of each node is obtained, which makes the convergence speed reach the fastest .Our main contribution is to provide the basic theory of consensus protocols for heterogeneous opportunity networks,and prove the correctness of the theory through experiments.