Supplemental oxygen is used by millions of people each year in hospitals and at home. The device and methods described allow people on supplemental oxygen through a feedback loop to optimize their blood oxygen level by measuring oxygen and/or carbon dioxide and/or other related gases in the blood. Because the device and methods optimize the level of supplemental oxygen and/or carbon dioxide and/or other related gases, complications (from too much or too little oxygen and/or carbon dioxide) including death can be prevented. In addition, users can reduce their costs by reducing the amount of oxygen needed as well as labor costs. Additionally, helicopters, ambulance, and mobile surgical sites can reduce weight in critical situations. In addition, the device and methods described also allow patients on ventilators through a feedback loop to optimize ventilation by measuring carbon dioxide in the blood; which can reduce complications, and reduce labor costs. Finally, the device and methods provides a warning system when the oxygen supply is compromised, has or is exhausted.