Hacktrox - the Kitable DIY Scuba Nitrox Sensor

by RolandC7 in Circuits > Arduino

1118 Views, 5 Favorites, 0 Comments

Hacktrox - the Kitable DIY Scuba Nitrox Sensor

IMG_9108.JPG
November 7, 2023
Assembly_sketchup.jpg

A simple arduino based scuba tank nitrox sensor device that builds on some previous DIY projects with improvements to the case, circuit board, added a rechargeable battery, and improved DIY-friendliness. Goal of the design is to be truly kitable for hobbyists of varying ability.

First, a little bit of back story:

I recently got recertified PADI open water last year after not diving for decades ( I was originally certified on 2000!! ), and began diving pretty regularly on vacation and weekends. I live in Vancouver, so cold water diving is what we have and that demands a dry suit and lots of extra gear and tech. One of my dive instructors, Nikita, from Vancouver Diving Locker suggested this DIY project when he learned about my background with arduino and general engineering. After that it became a quick fun weekend project mostly based on the "Divetech" project below.

Now, when you dive Nitrox, one of the rules is that each diver must verify the oxygen percentage in the tank and calculate their own MOD (Maximum Operating Depth) based on a safe partial pressure of oxygen (usually somewhere between 1.4 to 1.6 ATM). But then, if you don't have your own Nitrox sensor you will be relying on the dive shop device which, if you are in a remote location, may have not been calibrated recently. This way, even the casual diver can afford their own sensor. No warranty provided.

When I got Nitrox certified I actually used the DIY sensor I had built and brought to Thailand with me. That was very fun. The dive shop was impressed, so I viewed that as a good sign.

Alterations from previous projects are fairly numberous, but mainly, having a good amount of experience 3D printing with my Flyingbear 3D I could not resist redesigning the entire case. The case is much beefier in my opinion, and screw together using M3 countersunk screws for a nice hefty look and feel.

The basics are the same as most of the other projects out there. Key components are: Arduino + AD board to measure the low voltage from the oxygen sensor, a small screen to display results.

Additional improvements I made was designing a nice simple circuit board with which to plug everything together.These are so cheap now that I rarely make my own soldered breadboards. Once the circuit has been verified with a plugin breadboard, I just design it and send it off. These took less than two weeks to deliver to Vancouver from China. I used AllPCB, but any number of other fab factories would work. I'll include the design files for the board below.

Also added a rechargeable battery to make everything simpler. Two 300mAh 14250 cells fit nicely into a single AA holder and provide 7.4V that will last about a day of constant use.

Some Required Skills and Tools:

1) Arduino programming

Although I will include the sketch, things invariably go wrong and the ability to debug programs is vital. It is also a good idea to download some commonly available test scripts for the OLED screen and the ADS1115.

2) 3D printing

Every 3D printer is slightly different and will require different settings. I used PLA on a Flyingbear Ghost 5 slicing with CURA. Expect to spend some time tweaking the settings to get everything to fit together properly.

3) Soldering

The main board, the arduino pro mini, the ADS1115, and the switches and buttons will all require a little bit of quick soldering. Its not too hard, but its a good idea to practice a few times before you attempt the main board. All components are designed to plug in easily so this will mitigate some of the problems.

When designing this project I built upon many other projects that are out there. Here are a few of them:

https://www.instructables.com/Home-Made-One-Hand-Nitrox-Analyser-Arduino-Based/

largely based on work by this person (Eunjae Im),

Also https://www.divetech.com/post/the-20-nitrox-analyzer

and https://gasblender.org/en/nitrox-analyser


Here is a link to the thingiverse STL files: https://www.thingiverse.com/thing:6300317

Here is a link to the arduino code and the KiCAD files: https://github.com/rolandoman/DIYNitroxSensor

Supplies

IMG_9125.JPG
IMG_9123.JPG

General Tools and Supplies:

  1. metric allen key set (2mm and 2.5mm for the 3M machine screws)
  2. a good multimeter
  3. soldering iron
  4. flux pen/needle
  5. solder
  6. solder kit helping hands
  7. wire cutter/stripper
  8. sharp exacto-style knife
  9. some shrinkwrap for the wires
  10. Two of everything to save you when you blow something up

Order Parts

IMG_9121.JPG

Sometimes the links below from aliexpress will change or not exist at a later date, so just use a description of the part. I also included pictures of all the components to make this easier.


Arduino Pro Mini board - this is a nice compact version of arduino that will fit nicely in the case. I used 5V, but 3V variant would probably be fine (you may need to get a FTDI programming cable if you don't already have one): https://www.aliexpress.com/item/1005002721890892.html?spm=a2g0o.order_list.order_list_main.59.1f4c1802e7bJ2E

0.96 inch 128x64 OLED screen - make sure you get the I2C version (4pins) not the SPI version (7pin): https://www.aliexpress.com/item/1005005034354794.html?spm=a2g0o.order_list.order_list_main.53.1f4c1802e7bJ2E

ADS1115 board - get the smaller format one (usually purple, while the larger one is usually blue). This will fit better inside the small space: https://www.aliexpress.com/item/1005001703504835.html?spm=a2g0o.order_list.order_list_main.41.1f4c1802e7bJ2E

Simple Switch - Get the 2pin version (I might change this in later iterations. The switch accidentally turned on in my backpack once and drained the battery): https://www.aliexpress.com/item/1005001513153469.html?spm=a2g0o.order_list.order_list_main.120.1f4c1802e7bJ2E

Mode Button - Almost any small button will do. I chose a small one with diameter 12mm. This is used to change settings: https://www.aliexpress.com/item/4001291695467.html?spm=a2g0o.order_list.order_list_main.105.1f4c1802e7bJ2E

Rechargeable 14250 Lithium Batteries - The 14250 size is great because two of them fit in a AA holder and provide 7.4V. Be careful when you order because sometimes this size is sold as not rechargeable. I also only showed one battery in the picture above, but two will be needed for the device. Normally I find them sold in sets of 5 anyway : https://www.aliexpress.com/item/32892705121.html?spm=a2g0o.order_detail.order_detail_item.4.90cdf19cCFsvj5

AA battery holder - This will hold two of your 14250 lithium batteries in series to create a 7.4V power supply: https://www.aliexpress.com/item/1005004825062091.html?spm=a2g0o.order_list.order_list_main.135.28d51802gwxsCu

2S Lithium charge board - This will use a USB-C connector to charge your batteries. The one I got glows blue when charged and glows red when charging: https://www.aliexpress.com/item/1005005665854131.html?spm=a2g0o.order_list.order_list_main.105.28d51802gwxsCu

Female Headers - The male headers should have come with the arduino and ADS board. Order minimum of 2 X 12P for arduino, 1 X 10P for the ADS1115, 1 X 2P for the I2C of the arduino: https://www.aliexpress.com/item/1005004273173212.html?spm=a2g0o.order_detail.order_detail_item.7.43dff19cm0W8rT

JST XH cables and plugs - these will allow the battery, button, switch, OLED screen and sensor to plug into the main board. You will need at least 4 X 2P, 1 X 4P (make sure you get both the cables and the plugs, also make sure the cables are pre-made. They can be a pain to crimp yourself): https://www.aliexpress.com/item/32954418743.html?spm=a2g0o.productlist.main.1.6b6070112y1TQI&algo_pvid=0abaecd8-8919-4867-aba4-2d78e16b49a1&algo_exp_id=0abaecd8-8919-4867-aba4-2d78e16b49a1-0&pdp_npi=4%40dis%21CAD%212.30%212.3%21%21%211.63%21%21%402101eab016995419035141202e18d6%2166344746550%21sea%21CA%212032184915%21&curPageLogUid=Gguz2wt2WpqG

23 x SS M3 10mm flat head countersunk screws

SS M3 10mm socket cap and washers (need just a few to help embedding the M3 nuts into the 3D printed parts)

23 x SS M3 nuts

Obtain Oxygen Sensor, Test I2C and ADS1115

AI-O2-Fuel-Cel.jpg
Nitrox Board.jpg
IMG_9129.JPG
IMG_9130.JPG

These oxygen cells can run you over $100 new, but luckily most dive shops have a good supply of used ones. See: if they are used in rebreathers they must be replaced every year, but most of them last 2-4 years. Make friends with a local dive shop tech that services rebreathers and I guarantee you will be able to snag a few of them for free. I got my cells in exchange for making a few extra of these Nitrox sensors as gifts.

I also ordered one on aliexpress for around $25 and it worked just as well as the high quality ones I got from the dive shop.

The basic principle of the cell is simple: A chemical reaction occurs which creates a small voltage. The chemical reaction proceeds in proportion to the partial pressure of oxygen, thus, by measuring the voltage, you measure the partial pressure of oxygen. The trouble is, the voltage is quite small. The oxygen cell outputs anywhere from 6mV to 12mV in ambient air (21% oxygen) depending on how new it is.

Therefor, to measure such a small voltage, your arduino needs a little help in the form of an ADS1115 analog to digital converter board. This will be used to measure the small voltage from the oxygen cell and digitally relay the information to the arduino using the I2C bus.

So, the first thing to do is to connect the ADS1115 to the arduino and see if you can measure the small voltage from the cell. This is an important step because a lot can go wrong with I2C and you can verify the arduino can talk to the ADS1115 properly. I relied heavily on other how-to pages for this step. Here is a link to a good one.

You don't even need the battery for this stage. The Arduino should be able to do the job all by itself being powered through the USB port of your computer.

Design and Order Custom PCB

PCB Board.jpg
PCB Back.jpg
PCB front.jpg
Allpcb.jpg

This project was actually the first time I've used KiCAD (historically I have used upverter, but that project unfortunately has been discontinued), so I can attest that the program is exceedingly easy to learn and use for simple boards such as this.

Spend an hour or so watching some initial help videos, and then start designing.

Here is a link to the Github page containing KiCAD files and final gerber files I sent to AllPCB for fabrication.

I used the sparkfun Solder-able mini breadboard as an initial physical model for designing the project board and making sure all the JST connectors had enough space, so as long as the final board you design fits in a 1.3" x 1.8" (33mm x 45.7mm) shape then this will match with the slots on the 3D printed parts and will fit inside the case.

I ordered 10 boards from AllPCB and received them in about 10 days (DHL) for $41.55 CAD, so only $4.16 per board delivered! This would be cheaper in larger quantities, but I am only interested in making a few of them for now. Feel free to adapt the design as necessary.

Solder Together Main Board, Arduino and ADS1115

IMG_9120.JPG
IMG_9132.JPG
IMG_9131.JPG
IMG_9148.JPG

Take this part slow. Hold the boards securely and always apply flux to every pin before soldering. Remember to physically check the configuration before soldering because it is very hard to remove a soldered header once it is in place.

3D Print Case Parts

IMG_9112.JPG

STL Files can be found here: https://www.thingiverse.com/thing:6300317

These were made using the free version of sketchup. There are a total of 9 parts to print and will use a total of about 130g of PLA.

I designed all the parts over a few weeks, and they had to undergo constant tweaks to make everything together properly. The final configuration is pretty good, but some feedback I have received is that the device is a little big. I will be working over the next few months on a version 2 which will shrink the case substantially. Stay tuned.

Please adapt the parts as needed. The most important aspect of these parts is that they fit with countersunk flathead M3 machine screws, and the hexagonal recesses fit the M3 nuts. I carefully tweaked the settings so that the M3 nuts would compress into the parts snuggly (proceedure described in the next Step) and capture the nut so that the case nicely screwed together.

Printer I used was a Flyingbear Ghost 5, with Ultimaker Cura as a slicer.

If you use a brim like I did, then you will have to trim this off. Most parts will print without supports, except for the bottom plate. There is a small recess that needs supports. The recess creates a little room for the programming pins of the pro mini. It also makes the plastic a little thinner in this area and allows you to see the color of the LED when the batteries are charging.

Embed M3 Nuts Into Case Parts

November 9, 2023
IMG_9143.JPG

I used M3 flat heads with washer in this step. This way you will not damage the 3D printer parts. If everything printed just right the nuts should be able to be squeezed into the hexagonal hole and not come out unless forced out. If it comes out too easily, this will be a problem so adjust your printer settings accordingly.

There are 23 hex holes total (12 on the button side, 10 on the top side, and one more to hold the battery holder against the side plate) so take your time. If these are correctly embedded, then the rest of the assembly will be much easier.

This was also my first instructional video on youtube. I decided to wear the painters gloves in admiration of one of my heros: Andreas Spiess. His videos have helped me immeasurably over the years.

Solder Up Wires and Connectors

IMG_9152.JPG
IMG_9154.JPG
IMG_9153.JPG
IMG_9156.JPG

OLED - 4P connector wire should go to 4 female header plugs to click into the screen. I found a 4pin cable I could use and these can also be ordered.

Switch - solder the 2P wires directly on the switch

Button - again, solder the 2P wires directly, just make sure you get the right two pins on the switch so it is normally open

Sensor - use the 2P cable, and just find some female header plugs. This way if you get the polarity wrong, you can just reverse them. This is easier than using the molex as shown.

Battery Assembly - This is a little more involved. If you got the right kind of AA holder, then it should fit with the 3D printed part as shown. There are channels in the part to fit the wires from the holder. These can be soldered to the charge board as shown, and joined with the 2P connector wire. Be careful on polarity of the connector here. This is one of the only places where polarity really matters and you could blow up your arduino (This happened to me).

Test Full Circuit Prior to Assembly

IMG_9159.JPG

Before the entire assembly is screwed together, its good to test whether the system works. Plug everything together except the battery and the switch. Since we will be powering the arduino through the FTDI connection, we will just need the sensor, OLED, and button to operate.

This is the main chance to check the arduino code, make sure all the libraries are installed correctly, and to make sure that the screen is all setup right. If you used a different sized screen, the code has obvious places to change this setting.

If something goes wrong at this stage here is a chance to stretch your debugging muscles.

There could be a short due to bad soldering.

There could be a glitch in the code.

There could have been a mistake in the connector wiring.

Any number of tiny errors could cause a problem here.

Final Assembly of Nitrox Sensor

IMG_9162.JPG
IMG_9164.JPG
IMG_9165.JPG

Careful with the countersunk screws. The 2mm allen key will not supply very much torque before stripping. Be gentle. Feel the nut engaging, and do not over tighten.

Fitting all the cables in the tight space can be a challenge. Hopefully you left enough slack to move them around and not too much slack so the cables take up too much space.

One of the last steps is to attach the side with the switch. When doing this, take note of the position of the battery charge board. There is a small slot that just fits the board and allows the entire assembly to click together. Prepare to jiggle this a little to get it to fit.

The last step is to attach the top. Be mindfull of the slot on the top assembly piece that will hold the main PCB. This prevents the PCB from jiggling around in the case and makes the entire assembly very tough.

Once it works, make sure that it reads 20.9% in open air. Then breath on it. If you breath slowly into the sensor the oxygen percent should decrease to 17-18% from the lower percentage in your breath.

Happy Diving!