Arduino Nitrox Analyzer For The Submarine Hacker

For Hackaday readers who don’t spend their free time underwater, nitrox is a blend of nitrogen and oxygen that’s popular with scuba divers. Compared to atmospheric air, nitrox has a higher concentration of oxygen; which not only allows divers to spend more time underwater but also reduces the risk of decompression sickness. Of course when fiddling with the ratio of gases you breathe there’s a not inconsequential risk of dying, so nitrox diving requires special training and equipment to make sure the gas mixture is correct.

Divers can verify the ratio of oxygen to nitrogen in their nitrox tanks with a portable analyzer, though as you might expect, they aren’t exactly cheap. But if you’re confident in your own hacking skills, [Eunjae Im] might have the solution for divers looking to save some cash. He’s come up with an Arduino based nitrox analyzer that can be built for considerably less than the cost of a commercial unit.

Now before you get the torches lit up, we should be clear: ultimately the accuracy, and therefore safety, of this device depends on the quality of the oxygen sensor used. [Eunjae] isn’t suggesting you get a bottom of the barrel sensor for this build, and in fact links to a replacement sensor that’s intended for commercial nitrox analyzers as a way to verify the unit is up to the task. The downside is that the sensor alone runs $80. If you want to go with something cheaper, you do so at your own risk.

With a suitable sensor in hand, the project really boils down to building up an interface and enclosure for it. [Eunjae] is using an Arduino Nano, a 128×64 OLED screen, and a battery inside of a rugged waterproof case. He also added an ADS1115 16 Bit DAC between the oxygen sensor and the Arduino for fast and accurate readings over I2C. With the hardware assembled, calibrating the device is as simple as taking it outside and making sure you get an oxygen reading of 20.9% (the atmospheric normal).

While [Eunjae] is happy with his analyzer on the whole, he does see a few areas which could be improved in future revisions. The case is bulky and rather unattractive, something that could be addressed with a custom 3D printed case (though waterproofing it might be an issue). He also says the only reason he used a 9V alkaline battery was because he had it on hand, a small rechargeable battery pack would be a much more elegant solution.

We’ll go out on a limb and say that most Hackaday readers aren’t avid scuba divers. For better or for worse, we’re the sort of folks who stay in the shallow end of the pool. But when one of our ilk does dip below the waves, they really seem to go all out.

51 thoughts on “Arduino Nitrox Analyzer For The Submarine Hacker

  1. Urg… You really don’t think there is more to it that the quality of the oxygen sensor that can have a negative effect on the accuracy? Have fun. In my mind things of this type are akin to weaving a rope to lift a truck up over your head. It might work, it might not. It might work for you and not the next guy… Definitely not anything I would want to depend on in real life.

  2. Long time technical diver, HAD reader and uber-geek and first time poster. Quite simply this is foolhardy, regardless of your technical skill. To be clear Oxygen becomes toxic at depth. Normal air becomes toxic (causing convulsions and other not good symptoms) at just below 60m depth (~200ft). Increasing Oxygen in the mixture (called Nitrox which this Arduino hack is analyzing) reduces the depth at which the gas in you scuba tank becomes toxic. Common Nitrox mixes can become toxic in as little as 80’ (25 meters). The analyzers used to test gases (often provided on dive boats for free) are expensive for a reason – they are life critical devices. Do you really want to risk your life with the Arduino IDE? This is akin to makin your own pacemaker. Enough said.

      1. You are a technical diver, and although you could definitely use this for your trimix the reported use case for this is nitrox, which in reality has a much wider safe zone because it is used at recreational depths. You need greater precision and reliability than a recreational diver. As a scuba instructor, I routinely teach while breathing nitrox because it minimizes my nitrogen loading such that it is possible to be in the water teaching in open water for most of the day without feeling the hangover of excessive nitrogen absorption. Yes, one needs to consider oxygen toxicity, but a properly trained enriched air diver understands and respects this issue. And the oxygen sensors are, essentially, a very large but very low capacity nonrechargeable battery whose voltage is directly correlated to the partial pressure of oxygen in the gas. All you need to hack is an ADC, not like there are hundreds of high-precision devices of that variety readily stocked at Digikey.

      2. You miss the point. Both are life critical devices and you don’t bet your life on some geeks homebrew concoction. Worse guys like the designer have no skin in the game.

        If his toy is used by some clueless diver and he gets the bends or worse dies. The geek will simply vanishes into the woodwork.

        There are things you don’t play around with and this is one of them.

        1. You’re right that the implementation is life critical…. But you are aware that people make their own aircraft, motorcycles, helicopters ocean going vessels, and. the like, right?

          I’ve worked in a few life-critical technology environments including environmental sensing and medical devices…. And I’ll say here, for the record, that I’d trust my own handiwork over a lot of what I’ve seen in commercial devices.

          There is nothing about purchasing a piece of equipment that makes it magically safe, and a reasonably competent technician can run a more extensive battery of tests than is typical in a commercial environment.

          Things aren’t magically safer just because they are built in a factory somewhere by someone who will never use the device.

        2. If somebody plans to give such a sensor to some other “clueless” divers, then certificates and tests are required for good reason. But everybody shall be allowed to decide himself, what kind of risk he takes. A pacemaker is for sure a higher danger.

    1. an arduino at its core is just a microcontroller and all the support components you need to make it operate. you do not have to use the arduino ide. break out winavr write the whole damn thing in c and ffs use the watchdog timer. likewise there is probably nothing special about the mcu in the commercial unit, they all have features for maintaining functionality in mission critical applications. the take away here is that if you dont half ass it and you verify and test it under all possible failure modes you should have a device you can rely upon. and a good diver is likely going to trust his instincts and experience over any piece of gear.

      1. I have taken apart a home CO alarm. It was made by KIDDE and I was surprise to find a bog standard PIC microcontroller. It seemed to do the job fine and I’m pretty sure that model had been subject to independent checks.
        So standard micro controllers do have a place in life critical applications.

    2. Sorry, but you really need to take a close look at the “commercial” equipment you’re using. Having had to carry out repairs to the leading nitrox analysers, I was astounded at how similar they were internally. These units generally do the mV to O2 %age calculation using a relatively simple amplifier and (worrying cheap) DVM. My own analyser (similar to this design, but with calibration selection and linearity tracking, provided the right gases are available) has proven to be as accurate as, and more reliable than the club analysers.
      All the standard analysers rely on having a good cell, and the rest is down to unit conversion. Simplest method is to amplify your mV (~13mV => 200mV), whereas this design reads the real mV and runs the maths in the uC. Neither method is “correct”, but a simple matter of choice.

    3. As a tech diver & tech instructor, I have made and used my own O2 Analyzer. OxyCheq even sells a kit to make them. ( https://www.oxycheq.com/el-cheapo-ii-analyzer-kit.html )

      Not sure where you think this is so dangerous. Measuring O2 with a sensor cell is literally just reading the voltage from the sensor. You have to adjust for temperature and humidity (and you can do that with a diode and a know gas source) and then read the voltage and convert to a O2 %.

  3. I’m using rebreather o2 cell for this project (yes I’m a ccr diver). Oxygen analyzer is simply read analog signal and display value and it’s not a rocket science.
    I have couple of commercial product and of course results is same as mine but I like mine better because I can customize what value to display.
    Hope this help. Happy hacking!

  4. Interesting and a great project for me to study. I have been wanting an oxygen sensor for use in old mines. As the saying goes, what is your life worth? I can understand the arguments above, but we have all heard stories of medical equipment with bugs with life critical consequences. So, who do you trust?

    1. That’s easy, a firm that stands behind their equipment rather than some faceless geek who has no track record, no nothing and will vanish the moment their device kills someone.

      1. You’re making us sound really scary! I’m not brave/foolish enough to trust somthing I made with my life in most circumstances, and even if I am, I don’t place other’s lives on the line. But while people who make life-saving devices professionally are held to a higher standard, this doesn’t mean that we as hobbyists should be prevented or banned from attempting to work with lifesaving mission-critical gear as long as we don’t endanger others with it.

    2. I mean they said in no uncertain terms in the article and build log that it’s risky and relies on competent handiwork and diligent calibration. There’s a lot of machines that are life-critical. Scuba diving is just a scary and unusual way to die compared to most, and that appeal to spectacle makes us much more wary compared to, say, installing your own brakes on a vehicle. Go on a forum about car or motorbike maintenance and people aren’t nearly as paranoid.

      That kind of diy project is also life-critical and should be treated with respect and care, and those who have doubts about their competency should book up and learn what they’re doing or seek out an expert. But the mundane life and death machines we deal with everyday very rarely attract the kind of terror and respect as this kind of gadget, which realistically isn’t going to kill a statically significant number of people.

      Yes, you should be safe. I don’t think anyone is suggesting otherwise.

  5. The first 2 comments made me laugh… firstly, you calibrate the device against the atmospheric norm of 20.9% so you have a validation of the accuracy there. Secondly, most people who are analysing Nitrox gas for diving are doing so on tanks to confirm their contents – so you have an expectation that it will be 28% or 32% or whatever blend was requested. If you analyse it and it’s as expected then fair to say the analyser is working correctly. Similarly if it’s miles away from what you were expecting then you know there’s a problem – exactly the same as when you’re using a commercial analyser. These guys make it sound like you analyse a tank with no idea what’s in it and then take the analyser reading as gospel… that’s never the case for scuba diving

  6. Not quite !
    While you can calibrate at normal atmosphere, this does NOT tell you anything about the linearity of the sensor, just a single data point.

    Suggest calibrating at normal atmosphere (~ 80%) and 100% oxygen, and draw a line between them.

    then, you’ll get a much better approximation of the slope.

    -glen english
    Canberra Australia

    1. Guys… you’re doing that every time you use the analyser – SOP is first calibrate against normal air at 21% O2 (not 79% Glen, that’s the nitrogen content…) and then you’re testing the Nitrox in your tank (typically between 28-36% for recreational diving, max 40%, and up to 50-100% for technical diving). So bingo, there you have your two data points

        1. You must be American. Single-point calibration is how it’s done with every commercially available oxygen analyser… anyway I think you misunderstand the entire gas analysis process – you already know what the expected result will be, it’s not analysing a ‘mystery gas’ and then solely following the results of the analysis. The gas in blended to a specific target, if you fill 72 bar of O2 and top off with Air to 200 bar you will get Enriched Air Nitrox 50%. The analysis is simply validating the result. Obviously if your analyser reads much higher or lower than 50% then something is wrong and you wouldn’t just go and dive it and kill yourself. It’s because of people like you that they have to put “Warning: May Contain Peanuts” labels on jars of peanuts

          1. All that hate’s gonna burn you up kid.

            Single point calibration is perfectly valid, but again, only because someone ran the sensor through a full calibration curve prior to shipping. It’s analytics 101. There’s nothing stopping you from throwing a cheap 99% welding O2 tank on the analyzer to get a better calibration. If you routinely use higher O2 blends it’d probably be a good idea. 30% is a wide range to cover off one datum. Your dive shop should have higher precision O2 than welding gas.
            The fact that you’re testing your breathing gas means it is a mystery what’s in your tank. Did you do the math right? Did the dive shop do what they said they did? Are their tanks filled correctly?
            More relevant here, is your analyzer working correctly?
            I’m not criticizing his use of a DIY sensor, just pointing out an improvement in his method.

          2. Obviously high precision gases are better but you’re not going to be breathing this, you’re testing the linearity of your sensor over a range.
            The lowest grade of O2 is 99%. The only difference these days (at least in the US) between medical grade and welding grade is whether the tank is evacuated prior to refill. It all comes from the same bulk tank.

          3. Nobody buys a tank of welding gas to calibrate their analyser. Nobody. Despite this amazing fact, the world is not littered with dead bodies… Anyhoo, leaving all that aside for a minute: whoever blends your tank it is going to be something between 21% and 100% no matter how badly they screw it up. And, they’re going to tell you it’s XX%. So when you stick your analyser, regardless of whether it’s commercial or homemade, IF YOU DON”T GET the same result then you know you have a problem somewhere, and you don’t dive it. The only people who die are those who don’t analyse their tanks in the first place

          4. We have been told, that one of the biggest dangers is, that somebody just mixes filled tanks up at the compressor station. Because of human error. So to be safe you test it before you put it on your back.

        2. No, the idea that somebody can sue somebody else is of no value for me. If I am dead, no lawsuit would resurrect me. Of course the single point calibration is only a check and only acceptable, if the basic principle is in a way, that most errors would be detected. But a complete inversion of the sensor response is very unlikely. So if the device shows 21% in normal air it will show less for less O2 and more for more O2. Additionally: If it shows an unexpected value you would be very careful, if you want to use this tank at all. You would check other tanks from the filling batch, if they are equal, you check the oxygen concentrator, you could check a bottle of pure oxygen, which is normally available for first aid.
          So if it says 21% for air and the expected e.g. 31% for your nitrox, then I would feel quite safe.

  7. I loved it when the article stated: “Now before you get the torches lit up…”

    If the sensor is connected/applied in the proper way then this project is nothing more then a simple unit converter, voltage to oxygen. The ADC used has an internal reference, good choice. So other then a programming mistake in the formula used to calculate the result value, I’m pretty sure the risks are minimal. Therefore checking against a known value is a good idea, but never rely on a single reference, always confirm for the correctness of the outer limits/range too. Basic rule for every measurement device but even more important when your own life depends on it.

  8. Yay for innovation! Every non-DIR Tech diver needs one of these, as literally every other piece of gear is also designed to get divers back out of the deep and un-bent. Right now all I have to go by is the shop analyzer where I get my mix, and I’ve seen it get dropped before, so following Eunjae’s lead is better than not having a second mix check (or using a dropped several-times shop analyzer). Building your own adds a little incentive to sourcing the right parts, and soldering while sober.
    I wanted to say ‘Not a Hack’, but he re-purposed his sensor from his CCR, and I think the 9v came from his one of his smoke detectors. Where else is there an ample supply of 9vs? Well done.

  9. I understand the concern for the system’s accuracy, but A- as long as it was made for personal use, the developer has only himself to blame should it fail, and B- if he’s a CCR diver, it’s fairly safe to assume he understands the risks and has developed it to satisfy his desire to keep breathing, above or below the surface.

    The only other comment I’d make on the article would be to correct the advantages of nitrox. It offers extended dive times OR increased safety, not both*. If you dive to the limit on nitrox, your risk of DCS is no less than diving to the limit on air. If you dive to air limits but breath nitrox, then your risk of DCS is less.

    *Of course, if you dive somewhere in between, you can have varying degrees of each. But in general, people dive nitrox to gain dive time, and dive right up to the limits, so the benefit is extended time, not increased safety.

  10. Things are expensive, because they are tested, tested again, and then retested. I wouldn’t trust my life to that.

    My own automatic garage door opener, sure.

    Making my own dialysis machine, not so much.

    Coming up Next:

    -Make your own CPAP
    -Make your own Blood-Glucose monitor
    -Make your own dialysis machine
    -Make your own ECG machine
    -Make your own pacemaker

    Follow Ups:

    -Making your own coffin
    -Making your own funeral pyre
    -Making your own critical care ICU
    -Making your own tombstone

    1. as for DIY medicare:

      CPAP – probably not a good idea, way too many ways to kill a person if something fails.
      glucose meter – the readout is really simple, it’s the test cell that does all the magic. If you’re getting the consumables from a factory – sure. If not – hell no.
      dialysis machine – I suggest you look at how the first prototypes looked…doable, but only if there’s no other way. Would be very hard on keeping everything sterile + you would need an assistant for using it (the possibility of bleeding out and all that fun)
      ECG – it’s a diagnostic instrument, it will not kill you if it’s showing bullshit. Your actions based on said bullshit however, might. Reasonably easy and has been DIYed many times.
      pacemaker – the device – not THAT hard. “Installing” it however, is a whole different ballgame.

      and for the “aftercare”:

      Coffin – advanced woodworking, not easy, but doable with experience :P
      funeral pyre – erm, (literally) Burning Man? :D
      ICU – it’s the personnel, not the equipment that make the difference between an ICU and an instrument storage room.
      tombstone – masonry…

      Some things are simple, some are not. As stated in the comments, there are people that are confident flying in aircraft that they built themselves. Everything we do is a calculated risk.

    2. Pretty sure I’ve seen something about a blood-glucose monitor on here. I know I’ve seen an ECG article, and there’s also been a blood-oxygen monitor project as well. However, they are not usually titled “Make your own …”, that’s Instructables you are thinking of.

    3. CPAP? Not so dangerous.
      BGM? A single off-reading will not kill you.
      ECG? Why not, except for one reason: When I need one I don’t have enough time co construct and build one :-) The only really important thing for an ECG is to be pretty sure to have very good galvanic isolation/separation from mains current.
      Pacemaker? For sure not. And somebody had to cut me up and install it. :-)
      dialysis machine? No. That has direct connection to the bloodstream with high risk of infection.
      The four later can not be follow ups :-) You have to prepare them in advance.

  11. Hello, I am interested in this project. may I ask if I replace the model of the oxygen sensor, do I need to change the Arduino code? Because I can’t find the output voltage curve of the R-17MED Oxygen Sensor, and the code seems to use the difference in oxygen between the air and the target gas to calculate the oxygen concentration, is that correct?

  12. I know this thread is a few years old, but I find these replies to be rather funny. People talking about testing, and validation…hahaha. Oxygen analyzers are simply that. You take a o2 sensor, that starts off in a specific mv range (~8-14mv in air), and move it to a higher percentage of o2 creating a linear increase in voltage. Then you use a A/D convertor with the correct resolution to change it into something a microcontroller can read. This isn’t rocket science, and fairly foolproof. As long as the sensor is valid. It is always good to calibrate, and check the mv output in air before trusting it. I just don’t see why a project like this is giving people heartburn.

    1. I don’t think a lot of the naysayers are rebreather divers and also don’t understand much about how oxygen is analyzed with a cell. I’ll be building something like this for a nitrox stick, slightly modified so I can have a display and external cell installed in the stick. Should be a fun project.

Leave a Reply to MartinCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.