The feasibility of sensing carbon dioxide with a IR singlebeam optical structure is studied, and a novel carbon dioxide gas sensor based on IR absorption is achieved. Applying the Lambert-Beer law and some key techniques such as current stabilization for IR source, using a high-quality IR detector, and data compensation for the influences of ambience temperature and atmosphere total pressure, the sensor can measure carbon dioxide with high precision and efficiency. The mathematical models for providing temperature and pressure compensation for the sensor are established. Moreover the solutions to the models are proposed. Both the models and the solutions to the models are verified via experiments. The sensor possesses the advantages of small volume, lightweight, low power consumption, and high reliability. Therefore it can be used in many associated fields, such as environmental protection, processing control, chemical analysis, medical diagnosis, and space environmental and control systems.