The application describes a diaphragm pacemaker that uses an implanted CO2 sensor to constantly monitor CO2 in the body and adjust the pace of breathing based on the amount of CO2. The sensor is preferably placed in tissue such as fat or muscle to sense CO2. The CO2 sensor and diaphragm pacemaker unit are preferably implanted in the shoulder or neck area so that the entire device may be implanted and connected to the body without invading the stomach or diaphragm area.