This paper presents equations for the electron density of the two-dimensional electron gas (2DEG) in AlGaN/GaN heterostructures in three realistic scenarios: (1) AlGaN/GaN heterostructure with surface exposed to ambient with mobile ions, (2) metal gate deposited on the AlGaN surface, and (3) a thick dielectric passivation layer on the AlGaN surface. To derive the equations, we analyzed these scenarios by applying Gauss’s law. In contrast to the idealistic models, our analysis shows that the 2DEG charge density is proportional to the difference between spontaneous polarization of AlGaN and GaN, whereas surprisingly, it is independent of the piezoelectric polarization.