The SnO2 semiconductor layer in the MQ2 gas sensor is heated to a high temperature, allowing oxygen to be adsorbed on the surface. When the air is clean, electrons from the conduction band of tin dioxide are attracted to oxygen molecules, forming a potential barrier which makes the SnO2 film highly resistive.