As a builder of gadgets and a scuba diver I have been trying to build an oxygen analyzer for a bit now. The big problem is that most micro controllers can’t read the mv that the sensor puts out. I played with opamps, but never got it to work properly. Finally I found the Texas Instruments ads1015, an analog to digital convertor chip “adc”. Adafruit makes a nice breakout board to make your life easier.

Now I only need a micro controller, an LCD screen, an oxygen sensor, a push buttons and like 9 resistors or so and I got yourself an oxygen analyzer.

Step 1: Shopping List

Below are the components and parts with the links to where you can buy them

Step 2: Connecting It All Together


VDD Pin to 3.3v

GRD Pin to Ground

SCL Pin to A5 Pro Trinket

SDA Pin to A4 Pro Trinket

A0 Pin to Connected to the Audio Jack - O2 Sensor + pole

A1 Pin to Pull up Resistor 10K

A2 Pin to Pull up Resistor 10K

A3 Pin to Pull up Resistor 10K

Nokia display

VCC Pin to 3.3v

GRD Pin to Ground

SCE Pin to D8 Pro Trinket

RST Pin to D6 Pro Trinket

D/C Pin to D5 Pro Trinket

DN(MOSI) Pin to D11 Pro Trinket

SCLK Pin to D13 Pro Trinket

LED Pin to 200 ohm resistor to 3.3 V

Push Button

1 pin to Ground

2 Pin to D3 and a 10k pull-up resistor to 3.3v

Lipo Backpack

G Pin to Grd on Pro Trinket

3V 3V Pro Trinket

Pro Trinket

All the connections to the pro trinket are described in the above descriptions. I have added one 10k ohm pullup resistor to the RX pin. The Pro Trinket has the habit to sometimes hang on boot. This pullup resistor seems to remedy this. Why?..... Don’t know, a much smarter tinkerer on one of the Adfruit forums told me this piece of wisdom.


The Lipo Backpack is the power source for the project. Every 3v connection needs to be connected to the Lip Backpack 3v and all the Ground connections need to be connected to the Lipo Backpack Ground including the audio jack witch is connected to the Ground of the Oxygen Sensor.

Step 3: The Code

All the libraries used are from Adafruit and are easy to download from their site at www.adafruit.com. The formula for calculation the O2 % is simple.

(current mv from sensor / mv from sensor in the air) *20.9.

The only thing you need to do is store the "mv from sensor in the air" value in a variable before you try to analyze any gas. I do this in setup routine of my sketch or when you press the push button. Just download this zip file and upload the sketch to your pro trinket.

Step 4: Finishing Toughes

To complete the project I put all the components in an enclosure and added 5v Regulator like a the 7805T witch I connected to the 5V in pin and the ground pin on the Lipo backpack to charge the battery.

I also added some code to calculate the maximum operating depth “mod” of the analyzed gas for a PO2 of 1.4,1.5, and 1.6

Formula for Imperial “Feet”

mod= ((po2/fraction of gass)-1)*33

Formula for Metric “Meter”

mod= ((po2/fraction of gas)-1)*10;

I also added a button so I could create a menu to select your mod unit “Meter or Feet”. To prolong the battery life I made it so that you can turn the backlight on the LCD display on and off.

I could show you how to do these things but figuring this stuff out is half the fun. If you get stuck I can help a little. If you know how to improve on the project please let me know as it is always good to learn new things.

<p>i want to connect this to piezoelectric valve. the purpose is to keep oxygen at 5% in a small space close environment of biological organism. is it just simple modification of your code? Can someone point me the right direction? thanks!</p>
<p>Hi! Does this reads water oxygen level?</p>
<p>No it does not, it is a gas analyzer. I am not even sure if there is a probe or sensor that reads dissolved O2 in a liquid . </p>
<p>Dissolved oxygen is one of the most common wastewater analyses conducted. Multiple vendors provide ion-specific electrodes</p>
<p>Hi, Can it measure the oxygen in the air like in the room???</p><p>I want to buid it to measure the oxygen in the factory...</p>
Hi and thanks for replying.<br>Finally got time to play with it again and do some debugging.<br>I was using ADS1115 board and at gain 16 it must have been too sensitive or something. Did a coversion of the reading to real mV on the screen and once set to gain 4 I finally get readings that are similar to the multimeter.<br>Thanks again for the great post!
<p>Hello. Have you tested the readings against some reference oxygen meter?</p><p>I have some issues with results - I do get the output, put the readings are dependent on the air pressure to the sensor.</p><p>My simple reference is just a multimeter. For my sensor it reads 10.1mV in air.<br><br>I am actually testing for nitrogen, so expecting to see a drop. With <br>nitrogen mix of about 10% O2, on the multimeter I get about 5mV. But on <br>the arduino the readings translate to like 8%. </p><p>I also tried O2 at<br> high % (did not do reference read on the multimeter, so do not know <br>what it was) - the readings on the arduino changed into negatives =(</p><p>Also, after calibrating to 20.9% O2, if I unplug the sensor it still reads around 1.5% on the arduino.</p><p>What am I doing wrong?</p>
I have tried it with the sensor mentioned in the build. I had an oxycheck o2 analyzer with the same sensor. I had a period of time where I was using nitrox almost every weekend. I have tested it against other analyzers and it was well within 1% which is the acceptable <br><br><br>I build it to calibrate against compressed air 20.9% O2. You need to calibrate as the voltage your sensor output changes with the age of the sensor and the temperature the sensor is in.<br><br>Q did you alter the code? <br>Q did you use the same components<br>Q Is your sensor within factory spec outputs. I have had bad sensors before.<br><br>If you can send me diagram or pic of your build I can look it over. My email is akurk@4divers.ca. <br><br>
<p>Can this _DO_ anything with the readings? Can it be made to trigger a solenoid? I know nothing about Arduino stuff but have an idea for a need that I have and found your article. I would like to monitor the levels of a chamber, and trigger a solenoid when they get too high. Is this easily/readily possible? Thank you for your time. </p>
It would not be hard to modify this project to activate a solenoid if O2 levels change or reach a threshold. The arduino is well equipped to activate a solenoid.
<p>does it measures when there is an airflow ? </p><p>I would like to measure of o2 concentration of a closed box which there is no an airflow</p>
<p>Hi,</p><p>Great work! And thanks for sharing it.</p><p>I'd like to ask how does it behaves when altitude change? What it would show on the screen with the same settings at 10000 feet for example? I mean is it measuring the partial pressure of Oxygen? </p><p>Also I couldn't find a datasheet could you send a link of it please if you have.</p><p>Thanks again.</p>
<p>Hello, is it possible to connect 3 O&sup2; sensors?</p><p>Thanks!</p>
<p>Hi. I'm also a keen diver and very keen to attempt this project. I am trying to figure out what Oxygen Sensor to use as the Teledyne R17 doesn't seem available easily in the UK (and shipping costs seem huge from the US). Do you know what the difference between the designations are (R17-MED, R-17AV etc.)? Is it just the connection that varies? Could a automotive O2 sensor be used or are there issues with accuracy? Sorry for the sprawl of questions but any advice you can give me on what to look for in a sensor would be much appreciated!!</p>
<p>UK Store</p><p>http://www.vandagraph.co.uk/?uid=&amp;sessionid=&amp;page=catagory&amp;cat=295</p>
<p>I have a few of questions,if someone could answer...</p><p>1.Is this for a pressurized system or can i measure &quot;open air&quot; with this sensor?</p><p>2.Is there a ramp up time for the sensor before readings are accurate?</p><p>3.Does the sensor need to be calibrated or is it calibrated out of the box? </p>
<p>can we use ADS1115 instead of ads1015 ? </p>
<p>Analyzer looks super!</p><p>How do you calculate Sensor_lowrange and Sensor_highrange? ads1015 has 12 bit resolution. That is 4095 steps, but i don't understand what is maximum analog input you divide it with. Can I also use ads1115 and just change libraries at beginning?</p><p>TY</p>
<p>Very nice analyzer ! Looks super cool :)</p><p>I am doing some research on building a &quot;Po2 meter&quot; using simular setup.</p><p>Plan to fit it to an old rebreather.</p><p>how much mods to your code will it take to have it show po2 ? </p>
Not a lot. The po2 calculations are already in the code for calculating mod. You are going to have to add a pressure sensor to get a realtime calculation. I guess if you want to directly calculate the po2 you are going to need the formula for that. If you first calculate %o2 you can derive the po2 from that.
This reads the blood oxygen level right??
<p>Hi wheeljam </p><p>No it does not read blood oxygen levels. This is a gas analyzer, it analyzes your breeding gas for Nitrox scuba divers. Most scuba divers use air witch is 20.9% O2, Nitrox divers use higher oxygen levels to prolong their diving time.</p>
Ah, ok. Thanks

About This Instructable




More by akurk:Easy To Build Oxygen Analyzer Using An Arduino Compatible Micro Controller  
Add instructable to: