The Micro Word Clock 2021 Edition

I am planning on teaching some people to use kicad, since its my new favorite EDA tool. I searched high and low for a decent circuit that would do something cool, with a good variety (but small number) of parts. Basically something fun and not intimidating. I got hooked on formatc1702’s micro word clock. It is an excellent use of the atmega8 series unusually high current drive outputs.


left- original gyxm-778 matrix. Right adafruits luckylight KWM-20882CVB matrix

The one catch was that I had a lot of trouble finding the GYXM-788ASR LED matrix called for in the bill of materials. Fortunately adafruit sells a similar 8×8 matrix from luckylight. I tried to design around this by including both footprints, but I ended up mostly making a mess (and I still couldn’t find the 788!). Both are common cathode but the row/column nomenclature is flipped. To formatc’s credit, they did a good job with the firmware. It was easy to find pindefs.h, which let me swap around pins until I was happy. My strategy was to create a test pattern and make sure it shows up where you want it on the matrix. This was much faster than tracing every signal and creating the right pin definition the first time.

The second catch was that after programming, I couldn’t get the time to change! After glossing over the code it seemed like this must have something to do with the RTC- and after some gentle probing/touching the board it would occasionally work. Initially I attributed this to the crystal not starting up, but after many power cycles and other pokes, it seemed like the crystal would actually run just fine. As a last resort I read the datasheet, and lo and behold, the Vbat pin needed to be grounded.

I bridged these two pins

A blob of solder quickly remedied this deficiency in my pcb, and afterwards changing the time worked just fine. I suspect that sometimes the chip “just works” if that pad happens to be at the right potential on reset, but sometimes it doesn’t. The button presses update the RTC time, not a time on the micro. So if the RTC does not start up, then you can’t change the time.

Other Notes

Pin1…probably. I prefer a dot!

I used the default footprints from kicad for a lot of the parts, and the pin 1 designators are a little wishy-washy. They look more like an printing error than a clear indicator for pin 1. I guess I will get used to it instead of re-creating every part from scratch, but if I only have a few parts, throwing a dot on the PCB would go a long way during assembly.

I should have also added a polarity marking on the power connector, and a couple of i2c test points wouldnt have hurt either. Since this was a quick board just for me and the parts are big, I didn’t worry about it.

Upgrades for V2

I figured if I was going to do this board again, I may as well overdo it. I managed to cram everything into a board roughly the same size as the matrix itself, even after I added a coin cell and a USB connector for 5V power. The coin cell will keep the RTC running for about 10 years, even if it loses usb power. This way I can program it, ship it to someone, and they can just plug it in and the RTC will know what time it is. The ground plane is far from perfect but its about as good as I will get with a board this size

Since the time will basically never need resetting, the switch for changing the time is very very small. I used the NanoT switch which is about the same size as an 0805, which is very very small indeed. And because programming is now a one-time affair, I moved the programming header to castellated vias/PTH on the edge of the board. They .1″ pitch so they should be easy to solder to headers if I cant scare up a pogo pin jig for them. For some reason the ground pad shows an air wire. The 5V is purposely left floating since I don’t care about that connection.


The git repo can be found here. Its probably not ready for prime time yet, but check the readme. I will update that when its reproducible.

Sitec Inflator Valve Service

As a scuba diver, I know that its only a matter of time until my gear looses the battle against corrosion and crud. Unlike most other sports, getting gear serviced is very frustrating- I have yet to find a place that can tell me exactly how long service will take and even for simple service, kits are often not in stock, or are a pain to get.

So this is a post about servicing my inflator valve, which has felt a little leaky. While I have not noticed any noises, it has felt like there is always a lot of air in the suit, even if I have not added any.

To be fair to sitec, they do make very reasonably priced kits available (from Europe), which contain a few orings, as well as a special clip that will almost certainly be broken when the valve is disassembled. They also do provide disassembly tools, if you want to buy them.

If I could get a kit for a reasonable price (from the US), I would have- however, I have a 3d printer and not a lot of patience, so I decided to fix it myself.

If you cant open it, you don’t own it…

Step one was to get the valve out. Whoever tightened it down really did a “good job”. To avoid waiting to get the special wrench from sitec to even find out if my valve was leaking, I printed my own. You can get the files here. These wrenches fit down over very small lugs on the inside and outside of the inflator valve.

maybe the culprit!

Next, the BARE sticker was peeled off and the button underneath was unscrewed with a 2mm and 4mm hex key. This allowed the valve barrel to be removed and the orings inspected. Interestingly, the bottom one was nicked-possibly the source of the leaking.

My model of the inflator valve, sitec part number

I started my maintenance with taking my inflator valve apart. After measuring some orings, it seems like the two small orings in the valve itself can be replaced with -008 orings, the oring in the nipple is a -009 oring and the swivel oring is metric 19.5 ID x 3mm cross section. All are available on McMaster, and buna N should be sufficient. Basically for the same price as a single repair kit, I got about 50- aside from one crucial part- the clip.

The Clip

RIP clip

I really cant explain why sitec chose to use a plastic clip to retain the outside of the valve to the inside of the valve. While it obviously works, there is no way to get it off without destroying it. Other folks have replaced it with C clips and spacers. I also bought said c clips, but I also modeled the clip and printed one on a pretty beefy multijet fusion printer.

Sweet sweet 3d printed clip

It seems like it works fine! I have managed to stay completely dry while using it. There is no perceptible “wiggle” in the assembly, and it still rotates fine. If you want to make your own, the files for the clip (and the whole valve) are on grabcad.


There was some crusty stuff in the screw that holds the valve together. I imagine it is a sealant to keep water from leaking under the sticker, through the screw, and into the suit. To keep this sealed, I added a little aquaseal during reassembly.

Also, the sticker seems to have gone back on just fine- which is surprising, given that it was left off for several days.

Sitec QuickNeck Install

My drysuit neck seal has always been about a 90% fit, which means that 100% of the time my suit floods. Sometimes a little, sometimes a lot! Considering the dropping air and water temps, I decided to do something about it.

Sending my drysuit out for repair was not a good option for me- its prime diving season here in the northeast, and the idea of sending any of my critical gear off for an unknown amount of time makes me sad. If I valued my own time, I don’t think I “saved money” by doing this install, but I certainly now know how I can fix my suit- and how long it will take. To me that is worth it.

Here are my notes- nothing special, and sadly not enough photos.

Material and Process

  • Sitec Quickneck ring
  • 220 grit sandpaper
  • silver sharpie
  • acetone
  • heat gun
  • DRIS dry adhesive (heat activated sheet adhesive)
  • Gear-Aid Aquaseal-NEO (NEO. not normal aquaseal!)

First I had to remove the old seal. I heated mine up with a heat gun and it peeled right off. My original seal was on the outside, but this ring will be installed from the inside of the suit, as you can see above.

I needed to enlarge the neck hole ever so slightly on my suit. I started by stenciling the outside of the neck seal onto the inside of the suit. Then I very carefully trimmed the inside hole 2-3 mm at a time until the neck seal could fit through without any distortion of the fabric.

Once that was done, I sanded the area between the stenciled silver sharpie and the neck hole with 220 grit sandpaper, then wiped it with acetone with a lint free rag (aka used “procedure” face mask). Now that the fabric was roughed up, I put down three coats of aquaseal NEO to create a surface that the dry ahesive would stick to. According to DRIS, the sheet adhesive wont stick to some fabrics.

Prepping the ring went just about the same way- I trimmed the adhesive to the size of the ring. Then I sanded the ring with 220 grit, and wiped it with acetone. Then I heated the seal with the heat gun, and pressed it down onto the seal with a brayer/roller.

The photo is after the release liner was removed- you can see the milky white glue where it is cool and the clear glue where it is still hot.

To finalize the installation, I followed the same process of heating the ring and pressing it into the suit. This is fairly forgiving, but it pays to be patient and work you way around the seal.

Results + Recommendations

Two big thumbs up for the new neck ring. I am now dry all the time, and if I tear a seal I can quickly install a new one. More importantly, I now know how to patch my own drysuit, which means I don’t need to worry about sending it out for a few months if it gets a hole in it.

I would recommend this kind of work to anyone who has a drysuit who priorities deterministic execution of repairs over the great mystery of sending stuff out- however its not for the faint of heart since you do have to cut up your drystuit. If you do decide to do this take your time, and good luck!

Integrated Dive Information and Oxygen Transmitter (I.D.I.O.T)

I.D.I.O.T wrist mounted display

Knowing your PO2 goes a long way towards making it safer to go deeper with an oxygen rebreather. If you want to go pure O2, it can be used to monitor how purged the loop is, and if you want to go a little deeper it can basically turn an O2 rig into a sort of mixed gas rebreather (or a full mixed gas rebreather with proper diluent addition).

Sensors tucked away in the counterlung. This will be switched to the inhale side of the CL.

In order to conveniently know my PO2, I have purchased O2 sensors. Having built in temperature compensation and having reliable manufacturing seems like a big plus vs fabricating, assembling, testing, QCing and calibrating my own.

For my first iteration I have started with just two cells. A third would be easy to add if this works out.

Layout and Logic

Not to scale

The electronics are going to be split into three parts- the cells/stuff in the counterlung, an electronics box, and a display. I decided that the only things in the counterlung should be the sensors themselves and a connector.

Wiring is absolutely a nightmare.

The “Electronics Box” will house the brains of the operation (an ESP32), and the battery. Batteries and other flammables will be kept outside of the oxygen rich environment of the rebreather, for obvious reasons. In the unlikely event of the battery shorting to the cells, hopefully the high impedance of the cells will limit resistive heating or fire. In the future, a USB port with a cap will be wired in for charging.

Box as tested

This box has been tested to ~80 FSW with just the cord grips+cord installed, and it passed without noticeable leaking. The cord grips are MSM-M SKINTOP connectors. They don’t seem like the should work, and yet they do. Mcmaster sells these as “submersible cord grips”. N.B. they make a face seal with the enclosure, and do not require a gland like an SAE o ring boss (ORB) fitting.

The main oring seal is a 1.5mm oring made from cord stock and superglued at the ends. You can see the join just above the middle heat set insert in this photo. Surprisingly this does not seem to create any significant leak paths, although there is always a slight possibility that I will have to eat my words on that someday.

The display will be upgraded to a HUD at some point, but for now it will be wrist mounted. It displays two PO2 cell readings, a compass heading, and (in the future) the depth. As you can see in the photo, the top row is “highlighted” to show a problem- the cells are disconnected and are reading a very high PO2.

The Electronics

EE layout

Reading an off the shelf galvanic O2 cell is dead easy, since the temperature compensation and shunt resistor are built in. However, the output voltage is fairly low, and so it should not be fed directly into the ADC of a typical micro. It is possible to read such a voltage (~20mV), but it wastes a good portion of the resolution of the ADC.

For example, the maximum output expected is 2V (representing a PO2 of 2). With a 5v ADC, we are only ever using 2/3 of the range of the ADC, which effectively limits our resolution of PO2s to 2/3 the resolution of the ADC.

Since these signals are also not amplified or buffered in any way, it seems good to keep them away from the mcu. I have resolved to put them on an I2C DAC with an internal gain stage, which will let me both maximize resolution and keep the signal wires for the cells short. To this end, I used an ADS1015 breakout from adafruit.

Since it was on hand, I also threw in an LSM303 to use as an electronic compass. Since the compass has no “inertia” it has kind of jumpy readings, but doing some smoothing should help to get it to be a little less jittery. I could also try some compensation for nearby electronics, but they seem to have little effect. The LSM accelerometer/magnetometer lives in the wrist piece, although I did consider mounting it in the “head”, which would show you body heading, but not necessarily what you are looking at.

The display is the 128×64 OLED featherwing. Its easy to integrate, and it is fairly compact in terms of “extra space” for unused headers/buttons.


Believe it or not, this was taken in 10 feet of water while the sun was still up. Zoop for backup depth gauge/dive timer

I headed to the mystical mystic lake to do some testing. The combination of near zero visibility to start with and a haze of sediment/algae/stuff I don’t want to think about made for a more-or-less night dive like conditions, even with a light, during the day. However, the little O2 cell reader and compass seemed to behave relatively well. Most importantly the firmware did not crash, and no water seemed to get in. Cant wait to test it somewhere actually fun!

Galvanic Sensor and the Science Sr.

The Science Sr. doing what it does best

In the last post I alluded to a larger pressure pot- the Science Sr. This was totally based off of the $50 Cell Checker from the wreckless diver, which is based off of a now defunct post on some other website. I’ll do my best to document what I have made here, since its an awesome tool. I’ll put a standard disclaimer on building one of these- don’t do it, it could blowup, etc, and it could really kill you, and it might hurt the entire time.

Why this could be a bad idea

The Science Sr. is based around an air filter canister. These are rated to 125 PSI…with water. they are 100% not for use with air as far as I can tell. Air, unlike water, is fairly compressible. That means if the amount of energy stored in pressurized air is huge compared to a hydraulic system at the same pressure. Filling this to 125 PSI might be fine, or it could explode due to some component being exposed to chemicals or because it has been cycled too many times or because it has been cycled too rapidly. Plastic will fatigue over time, and that will reduce the margin between exploding and not exploding.

Just like the wreckless diver, I have added an over pressure relief valve (OPV) to prevent going over ~45 PSI or so. This is not a guarantee that it will not go over 45 PSI- I have it hooked up to a scuba reg with an IP of ~120 PSI that can provide something like 100 SCFM (cubic feet/min of gas at some standard temp and pressure). That is fast enough to drain a typical AL80 scuba tank from 3000 PSI to 0 in under a minute. There is no guarantee that the OPV can keep up with this flow rate, so I am VERY careful operating the valve.

Also, in some kind of blue-moon case where my first stage reg goes haywire, its designed to fail open. This would be bad news because this will shoot tank pressure right out of all the low pressure hoses. In a dive situation this is great, because you have ~30s to breathe off a free flowing reg. In a pressure test situation this is bad, because up to 3000 psi (more for some tanks) will be shooting out of every reg and inflator hose, including the one stuck to the pressure tester, which will almost certainly explode it.

This was mitigated somewhat by testing with a mostly empty (500 PSI) tank, and by very careful control of the valve. For cell checking applications, it may be a good idea to fill this with water partially to reduce the amount of volume that is full of air, reducing the potential energy. Anyway, on to how to build it.

Science Sr. Construction

Science Sr. Assembly. Note notch/hole at 6 oclock on the blue part.

Here it is, in all its glory. On the top is basically a X manifold that houses all the important stuff. At 12 oclock is a NPT to BC hose adapter going into a ball valve. At 3 oclock is an 1/4-MPT to 1/8-FPT adapter and a 1/8 NPT pressure sensor. These are available on ebay and seem to work just fine. It seems like they are for some kind of automotive application based on the connectors, and they are available in a variety of ranges. At 6 oclock is a 1/4-MPT – 14-MPT adapter. This attaches the female pipe thread cross fitting to the female pipe thread of the canister head. At 9 oclock is a 1/4-MPT 45 PSI overpressure valve.

Close up of epoxy job

On the other end is a 1/4″ MPT- 1/8″ FPT adapter. The threads on the filter are one-time-use soft plastic NPTs, so I essentially “replaced” them with a metal 1/8″ npt. Screwed into this is a 1/8 MPT to hose barb adapter with a bunch of wires epoxied to it, creating an airtight pass through. I like the 60 second epoxies that have narrow mixing nozzles for this, because they cure FAST and the nozzle fits into the fitting well. However, they are expensive and usually only come with two nozzles, which is wasteful if you only use a few ml per fitting. Silicone seems to work ok for this, but its probably best to apply with some kind of syringe. While none of these fittings have shot out the epoxy/silicone plug yet, it is probably best to get as much plug in as possible, especially on the inside of the plug. This should create a step in the plug to make it much stronger.

It is important to install this on the side labeled IN, since there is a large pass through there, and the wires will be much easier to pull into the canister body (see the assembly picture above).

Here is a shopping list:

*I had these on hand but this mcmaster part should be equivalent

Testing and Results

After some initial testing, it seemed like I would need to return to the teflon tape as a membrane to get good sensor response. I suspect this will let electrolyte evaporate out over time (based on previous experience), but it does give a very satisfactory response time, and over short periods the sensor is serviceable enough. It was necessary to make the sensor up in the electrolyte to eliminate bubbles. This meant pouring the eletrolyte into a dish and then wearing gloves to assemble the sensor “underwater”. Excess KOH was washed off.

As a note- for this exact size of sensor, a ~510 ohm resistor seemed “right”. More discussion of that below.

Step Response

Yellow = sensor, Green = Pressure. 500mV = 1ATM

Here is an example of the step response to pressure. With the ball valve, its a little nerve wracking to throw it fully open, and I wasnt keen on testing the opv, so the pressure step here actually has a rise time of ~250 ms. The rise time of the sensor is about the same- It does not seem like this step is fast enough to elicit any kind of delay in the sensor. The pressure here goes from 1 ATM to 1.5 ATM, and the sensor rises from ~220 mV to 325 mV, which is what we would expect.

The next test was to wrap the sensor up in a bag with the inflator hose, and to shoot O2 straight into it. This should give a value for 100% O2 at 1 ATA.

Yellow = sensor

I wasnt sure how much O2 to squeeze in there or where it was really saturating, so there is a little bump in the middle as I jostled the sensor. But after spewing out a good amount of gas, it looks like the maximum value is 500mV. This is an interesting result and shows that the sensor is actually no good up to 100% O2. If the sensor were linear, the resulting voltage should be 5x atmospheric what it is in normal “air” which is ~20% O2. That would be 1V, which it does not achieve. I believe this means the cell is current limited.

yellow = sensor

Here is the other end of that test- me tearing the bag to introduce normal air back in. From the initial jostle at 10s, it looks like it takes about ~1 min for the O2 to go back to normal levels. This is not representative of sensor performance because the gas actually has to get agitated for the O2 to go anywhere. In other words, it does not purely measure sensor response, but also incorporates the gas diffusing/getting blown away.


A good sensor is a linear sensor

This is a plot of pressure (Y) vs sensor value (X). To produce this, the chamber was cycled several times from 1 ATA (.5V) to 2 ATA (1V). Cursors represent the starting point, and where the sensor “should go” at 1 ATA. Doubling pressure should double sensor value from 190 mV t 380 mV, and that is almost exactly what the line shows. Doubling the pressure represents going from a PO2 of .2 to .4. The voltage is below the 500 mV that the sensor saturates at, so it comes out beautifully linear.

Since the sensor was cycled several times, we can detect some other interesting sensor characteristics, namely a small amount of hysteresis and non-linearity. The cursor generally tracks on the right side on the way “up” in PO2/pressure, an tracks on the left as PO2 drops. This means a sensor will read slightly differently after it has been exposed to higher pressure- it has “memory”. The maximum value of this is almost 50mV!

There is also straight up non-linearity, as the shape of the curve is not straight. However, this seems to be fairly small.

A single very slow run

Here is another hysteresis example, with the rise and fall done as slowly as possible. This should give an idea of the minimum hysteresis.

Slow and fast traces

Here is an example of a slow and a fast pressurization and depressurization. I couldn’t color the two differently, but it is easy to see that the rightmost trace (which was a pressure drop) looks quite different- it drops to 0 pressure then moves tot the left to drop the voltage.

Current Limit/Resistor Size

This is the setup I have, only the amplifier is an oscilliscope

I mentioned above that I used a 510 ohm resistor as a current shunt, and that the cell is current limiting. O2 cells, while read out in mV, are actually current-producing devices. Typically this is measured by putting a shunt resistor across the cell, and measuring the voltage. With low resistances, this produces a small voltage drop which can be difficult to measure. Higher resistances produce higher voltages- but you can only go so high! This is because the cell can only tolerate so much voltage across the cell*, and can only generate so much current. Therefore it is a balancing act to find an appropriate resistance to use- too small and readings get jumpy, too big and the cell wont change value at all, since it will be current limited.

*I am admittedly fuzzy on this but you probably do not want to get close to the open circuit voltage of the cell, which is 1.2v



Building a galvanic O2 sensor is possible and actually fairly easy. I suspect even the polarigraphic sensor would have been fine if capped in electrolyte, and if it did not leak. The sensors can obviously be tuned to give good responses, as this is exactly the same way that commercial O2 sensors work. However, building a really good sensor that could be used for diving, where the sensor is monitoring life support, requires a lot of sensor characterization which is way beyond what I want to do. There’s a lot more to an O2 cell than just getting it to spit out a voltage proportional to the O2 concentration- for example:

  • Temperature compensation
  • shelf life/storage condition determination
  • repeatable assembly/manufacturing processes

Any one of these could take a month (or longer) to do, and they would require a lot of units. I will stick to commercial O2 cells for now (and in the future), but now that I have a cell checker/pressure pot it should be interesting to compare a “real” cell to home made!

Pivot to a Galvanic O2 Sensor

After a maddening time with polarigraphic sensor, I decided I would try to build the galvanic flavor of oxygen sensor. After reading this tech tip from Oakton Instruments, it seemed pretty obvious that galvanic cells have big advantages. The main draw for me was that the output was easy to measure, eliminating the need for the fancy DMM. This would also simplify the electronics needed for reading polargraphic cell.

Electronics Comparison- Galvanic vs Polarographic

Here is what I think would be needed to read a polargraphic cell- a precision buck or LDO to bias the cell, with a feedback pin at the top of the cell. This eliminates the burden voltage of the shunt resistor that is fed into some kind of stack of op amps that then produce a voltage on the other side. This might not be so bad, and given that we have a 0 drop shunt resistor, we no longer need to worry about having a tiny burden voltage.

For a galvanic sensor, its pretty much as simple as it can be- a single resistor and a high impedance amplifier to match the voltage output range to the desired ADC.


The first galvanic sensor I made just replaced the silver electrode with a zinc electrode. Platinum or gold (or likely any noble metal) makes a good anode for this system. Zinc, in contrast to silver or platinum, is a very, very agreeable metal to machine. I can easily take a millimeter or more off at a 25mm diameter. The rod I got from rotometals appeared to be cast, although without any apparent porosity after ~2mm into the diameter. The one offputting thing is that zinc fumes are toxic, and the melting point is alarmingly low~ 400C. So all the operations were done with a lot of coolant, and the soldering to the electrodes was done very gently to prevent or minimize any zinc vapors.

As you can tell from me stating that there was a first sensor, there is also a second sensor. The first sensor seemed to have the same drift problem as the polarigraphic sensor, which makes me suspect that the root cause of both sensors drifting is electrolyte loss through the membrane or leaking at the press fit of the metal to the delrin. I also wanted to increase the area of the zinc so that the electrode and the volume of the electrolyte. More zinc will alleviate any concerns about using up the electrode, and more electrolyte will reduce the impact of loosing small amounts of fluid, or bubbles. This is because each bubble or amount of lost fluid will be small compared to the sensor, since it is bigger.


Step response to a blast of O2

Much like the polargraphic sensor, it kind of works. It certainly can detect a change in the level of oxygen, but it does it in kind of a non linear way. For example, I would expect that if 20% air is ~300mV, pure O2 should be 5x that, or 1500mV. It is possible that the cell just cant generate that much current, and that I should try a smaller resistor, but I certainly have not verified that yet.

With the improved sensor body, the sensor was also a lot more stable. It dropped a few mv over a fw hours, and its hard to know if that was related to temperature, drift, or the actual O2 concentration in the room. However, this stability was achieved over ~30 minutes as the sensor reached equilibrium. Likely the O2 in the bubbles in the electrolyte needed to be used up first, as they are in direct contact with the electrolyte. I suspect that after that happened, the sensor reached equilibrium with gas diffusing across the membrane and stopped sensing O2 trapped in the sensor.

A small dip from breathing on the sensor

On the other hand, it does seem very sensitive. Breathing on the sensor produces a small dip, and there is a noticeable difference in value (~30mV) from when I sit right in front of it and breathe on it vs when I leave the room- this is mostly anecdotal but interesting.

XY plot of pressure vs voltage of sensor. Thanks scope!

The linearity is not very good, as you can see. This is a plot of the pressure transducer vs the sensed voltage. Its all over the place, but is vaguely the right shape. Ideally the sensor should trace a straight line here, but there may be some hysteresis that causes non-linearity.

Unfortunately, just like with the step response, the change here should be much bigger. This test pressurized the sensor from 1 bar to roughly 6 bar- the reading should be about 6x as big, but it only went up a few mv! So this is not that impressive, as it shows either a non-linear sensor or some kind of enormous DC offset.

The last issue seems to be that the sensor leaks somehow. It may be that water vapor is permeating the membrane, because when left overnight the sensor dried out. In a humid environment like a rebreather this may not be a issue, but for storage it certainly is. This answers a question I have had for a while- why are rebreather sensors so slow? They are rated to a rise time of 6s to get to 90% of the final value. This is much slower than any of the sensors that I have seen, and does not seem to be an inherent characteristic of the sensor. My suspicion is that a much thicker membrane is used on rebreather sensors to reduce electrolyte water loss.


This sensor seems a lot easier to use, but it seems like a lot of the issues I have noticed may be due to my membrane selection and leaking. I have parts on order for a larger pressure pot (the under $50 cell checker) to see if I can get the larger sensor to behave in a linear way with a polyethylene or FEP (or even teflon tape) membrane. I think this cell checker will be very useful for a number of other things like depth gauges/computers/ingress testing so I am excited to have it on hand. I will have to make an effort to keep my pressure pot electrolyte free this time!

Oxygen Sensor and the Science Jr.

Testing the oxygen sensor will need to be done over a wide range of temperatures and PPO2s, and the cheapest, easiest, safest way of doing this seems to be to not use pure O2 gas. Not only is O2 a somewhat “spicy” gas, but I don’t have a huge tank of it sitting around in my house.

Instead, I intend to increase the PPO2 by increasing the pressure of the air- this will also prove out that the sensor works “at depth”. While that might seem magical, its pretty easy to imagine- as gas density increases at higher pressures, there are just more oxygens per volume bouncing around. The odds that one of these O2s bounces off the sensor go up as the pressure increases, and it is linear with depth.

The Science Junior

With this in mind, I set about what I am calling the Science Junior, since it looks like a generic science widget from KSP. Basically its just a small pressure chamber with a window and some NPT ports, which can be used for various purposes:

  • Pressure port via schrader valve from bike pump
  • Sensor wire pass thru
  • Pressure sensor
  • Gas infeed (?)


For those interested in the construction, the O ring is a just superglued out of cord stock and the sensor wires are run through a 1/8-27 NPT hose barb and epoxied in place.

Designed for a maximum pressure of 150 PSI, the 1/2″ thick polycarb cover and 8x M3 bolts should be more than enough to keep things together. There is about 1lbf per PSI so at 150 lbf I didn’t bother with the math.

One thing I would do differently is to use something removable for the sensor wire infeed, probably something that would get dropped in through the front and get captured by a lip on the inside, as shown in the sketch.

Testing and Learning

For testing, I set the bias voltage and logged the pressure (using a pressure to voltage transducer) and current of the sensor simultaneously while varying the pressure, which controls the PPO2. When the pressure is plotted against the current, it should be roughly linear. The chart above shows the sensor working reasonably well- however there is an odd drop of in current after being pressurized which manifests as a non-linearity in the chart above.

If we turn the scatter plot into a line plot to represent it as a time series, it looks a lot like a typical plot of hysteresis, but that seems like a red herring.

Normalized Pressure and Current for the same test

Looking at the normalized time series of the test, we can see that the sensor seems initially very linear, but then the current drops off after being exposed to pressure.

Here is some data from another test- the same strange trend occurs.

Looking at several sets of data we can see some that are complete garbage (blue data, yellow data, orange data) while some seem highly linear (green, red). Not exactly a good look for a mission-critical sensor that is helping you make life support decisions. Imagine trying to drive the speed limit if your speedo didn’t work!


I strongly suspect that pressure is playing a role here. First, sometimes gas is trapped under the sensor membrane, which causes the sensor to always read high, and to actually drop in current as pressure is applied. This seems to happen as the gas contracts and the membrane basically vaccum seals to the cathode. While oxygen is now coming into contact with the cathode, there is no opportunity for it to interact with the electrolyte, and this causes the current to drop.

Another factor is that in order to get the membrane closer to the cathode, I have had to burp out some electrolyte manually. This probably causes a slight negative pressure on the sensor as the membrane tries to regain its shape- I suspect that this can pull in gas and cause the gas blocking problem.

To solve this, I tried reducing the gap between the top lip of the sensor and the cathode, and making the sensors up “underwater” in electrolyte. This did seem to help with bubble elimination, but I still had a maddening and slow loss of current over time- uA over minutes or hours. these sensors show that good linearity can be achieved, but this drift is unacceptable for rebreather applications.

Additionally, I suspect that the sensor may not be fully watertight. That’s no good, since there needs to be electrolyte in there or it wont work! Some of the slow DC drift that I see could be due to this, or to evaporation through the teflon tape. The volume is <<1ml so even a small amount of evaporation could have an effect. I may try to remedy this or I may try to make a galvanic sensor…it turns out all I need is a little zinc or lead.

To be continued I guess!

DIY Polarographic Oxygen Sensor: Fabrication

I originally started by writing this post, but then decided to write a little more about the theory of polarigraphic O2 sensors first. This will skip most of the theory and just talk about how I built the thing.


Aside from a few small wires and a small knob of delrin, this is what is needed for an oxygen sensor. A teeny chunk of platinum, a silver tube and Potassium Hydroxide (sold for making soap).

KOH Electrolyte

Based on some unscientific googling, I made up a ~4M solution of KOH because it seems to be a relatively common concentration. The electrolung used a .5 N (normal) solution and other papers quote 1 N solutions. For KOH, normality is the same a molarity, so I will need a much less concentrated solution in the future.

The three big takeaways here are that:

1) KOH seems to be kinda nasty stuff, and it should stay far away from your skin.

2) KOH is hygroscopic (picks up water), so it should probably be baked at 100C to remove water before weighing. I didn’t do this so who knows what molarity my solution really is- its “4M or below”

3) Mixing KOH into water is exothermic and also takes a while to fully dissolve. If you don’t know what you are doing, it seems best to let the angry little salts do their own thing.

KCl Electrolyte

After writing this and doing some testing, I found that KCl was also a fine electrolyte. 1-3M solutions can be purchased for a reasonable sum on amazon as dissolved oxygen (DO) cell storage solution. It would also be quite easy to make a solution of KCl, but I didn’t want to deal with dehydrating the salts.

KCl is my preferred electrolyte since it is more like salty water than draino. It feels a lot safer to be pipetting salty water at my desk vs super draino, and were I to re-do this I would skip the KOH for this sensor.

Fabrication Notes

The 6mm diameter platinum electrodes were cut from a small sheet of 95% Pt 5% Rh from Rio Grande. Pt is surprisingly dense, and actually very annoying to machine for many reasons- it is tough, and compared to other materials, expensive. So to get as many parts as possible, I went with a “boring” operation using a .5mm 4fl carbide endmill with ~.00025″ chip thickness and .0015″ feed per revolution. I think that sawing electrodes out with a jewelers saw is probably a little easier, since my fixturing method (2 side blue tape + superglue) did not hold up to machining for one of the electrodes. Fortunately, I recovered that electrode with some filing (which worked very well). The short version of this is that there is absolutely no reason to CNC machine this stuff.

The silver anodes (999 Ag tube) were machined on a lathe. Aside from the fancy oring gooves, there’s no reason this could not be done with a hacksaw (gently, so as to not mess up the tube). Originally I wanted to use a rubber boot instead of orings, but that would have taken longer with what I had on hand. The electrodes are 6mm long with an OD of .375″ and an ID of .335″.

Cross section view of sensor

The body of the sensor was made of delrin. As you can see in the cross section above, there are some grooves here and there for things like wiring the Pt electrode as well as a pocket for the electrode. There is even a hole for wiring the silver electrode, which is not necessary (but it is nice).

Since the o-rings were a last minute addition to avoid finding and drilling a hole in rubber, I also made a delrin sleeve to fit over the orings and hold on the membrane.


First a wire was soldered onto the Pt disc. This was done with normal SnPb electronics solder. This wire was run through the sensor body, and a dab of silicone was used to seal it to the body housing. NB these electrodes are pricey and a pain to make, but are also extremely reusable. Using silicone makes them more recoverable. For a “real” sensor, there is also room in the wiring hole to fit a thermocouple for temperature compensation.

Next, the silver electrode was added, and a wire was soldered on. This extra hole gives me some pretty slick wire routing. NB this was done by sanding down the silver a little to get the solder to wet. I don’t think silver oxides are easy to solder to so this needs to happen before the sensor is used.

With the orings assembled, a few drops of electrolyte are added to the surface and a teflon membrane was stretched overtop, before placing on a retaining ring to hold the teflon in place (pinched between the orings and the ring). The “teflon membrane” is plumbers pipe tape.


With the sensor wired up, of course I was curious if I had just completed an expensive art project or if I had actually made an oxygen sensor. Fortunately I had enough spare rebreather parts around to shoot some O2 at the sensor.

Initially I was disappointed because the sensor seemed to not do anything aside from operate like a galvanic cell that reacted to oxygen (see previous post). However, after switching to a very sensitive DMM (keysight 34465a) I was able to read uA changes based on O2 concentration with .6-.8 V of bias voltage. Typical current of the cell in air was very low- maybe less than 10uA. Blasting it with oxygen bumped it up to ~100uA. The response time was extremely low (immediate, as far as I was concerned).

I intend to do a little more work on this sensor, including improving the membrane, making up a proper electrolyte solution, and (of course) testing and temperature compensation. This kind of sensor is cool- unlike gold-lead galvanic cells, it seems like they can be revived with a little electrode cleaning and adding fresh electrolyte (kind of like sea monkeys). In the electrolung, they were actually hard-wired into the rebreather*.

According to the electrolung designers, they are also less sensitive to water covering the membrane. Another nice feature is that in theory, because they constantly consume all the O2 in the electrolyte, a polarographic sensor should fail low if it looses contact with the gas to be measured. This is more obvious than a galvanic cell that may have an O2 concentration “locked in” by water, which could make the PPO2 appear good when it is not good. A cell failing low will be an obvious indication that it has gone off the rails because if the cell reads 0 and you are still breathing, there must be oxygen somewhere.

To Be Continued…


This does not mean that is necessarily a good idea. The electrolung was not a huge success, in part because sometimes people drowned while using it. Additionally, to my knowledge, nobody has decided to use polarigraphic sensors in breathing equipment since then, although they are used for some really cool stuff like measuring cellular respiration rates and dissolved blood gasses.

DIY Polarographic Oxygen Sensor: Theory

If I had a dollar for every time someone tells me I’m going to die using my oxygen rebreather, I would have about $6. However, I did royally freak out two local divers who were mystified by how I could use a rebreather and not know my ppo2. While I kind of know my PPO2, I thought it would not be a bad idea to actually measure it. And with O2 sensors in a global shortage, and with a smidgeon of knowledge from rebreather history, I figured I would try to build my own. This has turned into a much bigger project than I expected initially, and the project is certainly not done, but I have learned a ton about oxygen sensors.

History: The First PO2 Sensors

1969 is when Walter Stark and John Kanwishwer introduced the ‘Electrolung‘, which was among the first electronically controlled rebreathers. It seems like it was the first time that one could really know their PO2. John Kanwisher had recently improved the Clarke Electrode (1962, used to prove that extracorporeal oxygenation works), creating a non-fouling oxygen sensor by using a teflon and polyethylene as an oxygen permeable membrane to protect the electrode.

Construction of the Electrode

Figure from “Polarigraphic Oxygen Electrode” by John Kanwisher

Mechanically, as you can see, the electrode is pretty simple. A Platinum disk with a silver-silver oxide electrode is covered by teflon, after trapping some KOH electrolyte underneath it. Less simple is the reaction. As I understand it, at the platinum electrode, dissolved O2, water, and electrons from the bias voltage to form hydroxides. At the silver anode, silver and hydroxides form silver oxides and electrons. One difference between the original clarke electrode and modern electrodes is that modern cell use KCl. Both certainly work, although KCl makes AgCl instead of Ag2O. I believe the reason for this switch is that KOH solutions are very chemically active and will turn people into soap, while KCl is a lot less active. Oddly both are food additives, although KCl has an LD50 of about 10x that of KOH.

The original paper suggests sticking the whole sensor into a vat of KOH solution and capping the sensor under the solution, so it seems a lot less scary to do that with salt water instead of a strong base. I hope they wore gloves (but I suspect they didn’t)!

Most importantly- it is key to understand what dissolved O2 is supposed to do in this sensor- it allows current to flow with a bias voltage across the cell (variable impedance), unlike a galvanic cell which causes current to flow (fuel cell/battery).

Observed Sensor Behavior

This type of oxygen sensor seems simple, but there are some subtleties that make the behavior a little difficult to understand. Below I will try explain some interesting observed behaviors of the sensor, and why these things happen. The chart above is a handy key to the rest of this post, which will discuss what happens as the bias voltage on the sensor is increased from 0V.

No Bias Voltage (Galvanic Mode Pt-AgAgO cell)

In this mode, the sensor is producing a voltage instead of a current. As most people know from things like potato clocks and glavanic corrosion, two dissimilar metals in an electrolyte will tend to produce a voltage (across the metals). Based on my measurements and not my knowledge of chemistry, it seems like it is still the case with this cell- a small voltage (500mV) is produced between the Pt and Ag in the electrolyte. However, when exposed to oxygen, it seems like that voltage is reduced, probably by discharging the accumulated charge (voltage) back through the electrolyte. This can be considered an internal short across the electrodes of the electrical cell. However, measuring oxygen based on the blocking of this charge accumulation (voltage) does not make for a good sensor and since the voltage source is very weak, has a long recovery time (minutes/seconds). It also reads 0V (saturates) below an amount of oxygen that is useful to measure. In other words, the readings get clipped below the O2 fractions that would be useful.

Insufficient Bias Voltage (constant current)

In this mode, there is enough oxygen that the cell produces a constant current, since the “use” of the O2 is much slower than how fast the O2 is replenished. This mode should be avoided for sensing since an increase in O2 will not be noticed, since the O2 in the cell is always not depleted.

Sufficient Bias Voltage (Current proportional to O2)

In this mode, the voltage is high enough that O2 is immediately used when it enters the sensor. Therefore, the current that is produced is related to how much O2 is moving across the sensor membrane. This is the “sensor” mode of a polarigraphic O2 sensor. Again, if the size of the electrode is too small or if the membrane is too large, at high O2 concentrations the O2 diffusion could possibly catch up to the current and saturate it.

One interesting thing is here is that when the bias voltage is switched on, there will be a large spike in the current for a short time (<1s) before it settles into its “sensing” current. This is the current produced when the dissolved oxygen in the sensor is initially depleted, and it can be large- on the order of 1000s of uA (~1 mA)! If operated in the insufficient bias mode, this spike will not be seen.

Hydrolysis Bias Voltage (Constant current)

At this voltage, the water in the electrolyte will start to break apart and form gas. I would imagine that the current here is dominated by the conductivity of the electrolyte, but I haven’t made any measurements here.

What the heck is a Polarograph?

from, an excelent reference

That’s a good question- the polargram is a representation of the sensor output, so called because it measures the response vs the electrode vs. the polarization voltage. The chart above shows what we should be able to measure with the sensor.

What O2 Sensors Really Measure

In the sufficient bias range, more oxygen speeds the reaction and therefore increases the current. Current is proportional to the dissolved oxygen in the electrolyte, which should be limited by the diffusion across the membrane and the size and proximity of the Pt electrode to the membrane.

Polarigraphic and galvanic lead-gold sensors are sensitive not to oxygen mass or oxygen fraction (% makeup of gas that is O2), but essentially measure the rate of diffusion across the membrane (assuming they are working right). This is then calibrated to some known O2 concentrations, usually two of whatever is conveniently available- 0% (nitrogen purge), ~21% (air) and 100% (O2 purge).

This diffusion should be related to the prevalence of O2 in the sensed gas or liquid. Normal air, at a higher pressure, will have a higher availability of O2, and O2 will diffuse faster. Oxygenated media flowing by the sensor will have a higher availability than non-moving media. Temperature will also affect gas solubility and diffusion.

Oxygen Gas Sensors for Diving

For diving, the pressure plays a large role in O2 sensing. As breathing gas is compressed, the pressure increases quite a bit (up to about 4x pressure at recreational limits). When divers talk about oxygen sensors, they really are talking about measuring the oxygen partial pressure. Given some container and gas mixture, a partial pressure is the pressure a gas would have if it were allowed to take up the whole container without the rest of the gas mix. Surprisingly (or not) the sum of the partial pressures equals the pressure of the whole mix.

For nitrox-savvy folks, reading PPO2 at the surface works out easily to O2 fraction (% of gas by volume) since the oxygen measurement is happening at the surface at 1 ATA. For nitrox, this PPO2 is then used to figure out how deep you can go (increasing PPO2) before you hit a maximum PPO2 limit.

For rebreathers applications, the thing that is interesting is direct reading of PPO2, so there is no need to convert to O2 fraction. As pressure increases, so does partial pressure of oxygen, creating a higher pressure differential of oxygen across the sensor membrane, resulting in faster diffusion, which is then sensed.

Rebreather i4 “Nudibranch”

Holding onto the rock of great buoyancy, in the Atlantic

After feeling a bit like a snail in a shell in my last rebreather, I decided I wanted to make something a lot smaller and more ergonomic. Hence the next generation of the rebreather being called the Nudibranch- Latin for “naked lung”. A suitable name for a design with a scrubber-in-lung and with the counterlung unenclosed in a shell.

Improvements over i3

I knew there were some features I wanted to keep from the previous revision, and some things that needed to be improved. The materials for example, all proved to be robust and appropriately resistant to chemicals. the manual add valve (MAV) functioned well, and the counterlungs were of a comfortable volume. Scrubber duration was adequate as well. However, there were some issues with i3:

  • Bulky design
  • Difficult to reach gas controls
  • MAV hard to locate
  • Low gas volume
  • Assembly took too long

With a focus on simplifying the assembly, i4 looks and feels more like a simple rebreather rather than some kind of science project.

Streamlining/shell-less design

photo of a medi nixe from, an excellent resource

The main inspiration for the new design was the Drager Model 138 rebreather. This model was famously used by Hans Hass in the Red Sea and later went on to be a “sport rebreather” diving system used for leisure, re-branded as the barrakuda or medi nixie. It turns out that it got a lot of things right.

One of the interesting aspects of the model 138 is that it is mostly cloth. When working at the scale of the human body, the cost of materials and the size of parts can add up quick. The last rebreather was encased in a large aluminum shell bolted to an 80/20 frame. This frame covered the gas cylinder, as well as two 8L couterlungs. Since the scale of these parts is cm, the small offsets to accommodate things like the counterung bulkheads or the gas addition fitting took a lot of room. Wrapping that all in aluminum made the shell quite bulky. comparing the two units above, you can see that i4 is much smaller.

The breathing hose routing is a lot cleaner, since the hoses run over the shoulder instead of straight outwards. This means I need less hose length. In the future I hope to convert to 1.5″ diameter hoses that are ~6 in shorter, for lower work of breathing.

Gas Volume/Valve Access

The Model 138 also has front mounted gas, which means all the valves and controls are easily accessible to the diver. They also are not mounted on a whip/hose like on the i3. With the i3 it was possible to “loose” the MAV since it was not mounted to anything.

Swapping bottles/shutdown- Photo taken with a nikonos on 400 speed film

The i3 valve was accessible, but it was extremely challenging to reach and required flexibility. On the i4, the valve is in the front and stationary, and only requires one intermediate hose compared to the two for the i3.

I knew from my previous design that I wanted a lot more gas so that I could stay underwater longer. I still haven’t figured out the best way to reliably get oxygen fills, so I stayed with the hardware store welding bottles, but I doubled up on them. More can be read about that here.

Ultimately, the only real issues I had with this design were MAV related. The gas regulators seem to restrict the flow far more than the old regulator, which makes the counterlung fill very slowly. It also seems like they cut off at a higher pressure, leaving a significant amount of gas left over in the tank. This makes buoyancy and breathing comfort a challenge, and limits range. However, twice as much gas is twice as good, and dives up to 45 minutes have been conducted without complete gas exhaustion.

Counterlung material selection and design

This is really the complicated part, and its particularly fraught since it is where all of the rebreather magic happens. The bag must be, relative to the demands of the dive (duration, pressure, volume of bag) completely watertight and made of a waterproof material. Some leak rate is permissible, but it has to be low. In order to capitalize on pre-existing materials and advanced technology, I decided to use a drybag. The other options are to sew a bag and seal it, heat seal a bag, or sew and completely impregnate a bag with silicone.

Sealing the end of the bag

Since I managed to find an appropriately sized drybag, I ended up just buying one. Testing of several bags revealed that the stock roll-top seals of dry bags are inadequate. Specifically, the way that most of them close is by clipping the ends together and rolling them shut. While this is fine for splashes or even putting it on top of water, submerging the bag will squeeze the air out of the wrinkles created by bending the rolled up seal.

Without bending the seal, it is possible to get good enough contact between the two sides of the bag that it will form an airtight seal. However, the particular bag I chose had stiff mounting points for the buckles- these interfered with collapsing the seal in that area, and provided a leak path. Absolutely fine for a drybag, but not good enough for a counterlung.

By removing the stiffener and making some aluminum clamps, I was able to seal the bag well enough. I flipped the bag inside out so the smooth urethane coating was on the inside of the bag, instead of the textured nylon surface. Additionally, it is important that the bag material was very thin so the seam in the material does not disrupt the seal.

This is really a dream for scrubber access and drying since the whole lung can be rinsed and turned inside out to dry.

Making holes in the bag

I knew there would need to be at least 3 penetrations into the bag- inhale, exhale, and gas add, in addition to the large hole in the bottom. all of these of course, are leak paths!

The inhale and exhale penetrations are sealed with these (put link here) handy PVC bulkhead fittings, which conveniently fit a piece of 3/4″ pipe stub on one end to attach the breathing hose. Instead of the stock gasket, I used an oring and a retaining groove. The gaskets that were provided may have worked, but I wanted to be sure that I could get good contact along the whole circumference. The provided gaskets had a rectangular cross section and were hard- requiring a lot of force to seal. The replacement orings are soft, have a reduced cross section, and a much finer surface finish.

As you can see in this diagram, some water is actually allowed into the bag via the threads on the bulkhead fitting, but it is stopped by the oring and the glue on the bulkhead.

The other hole is a standard dump valve/BCD inflation port. These were “successfully” used on the i1 and i2 rebreathers- successful in that they did not leak, less successful in terms of actual diving.

The modified component is the small white disk under the spring

The last (and yet tested) item is the drysuit exhaust valve/ overpressure relief valve. Once installed properly, this should help avoid over pressurizing the lungs on ascent. Its stock cracking pressure is adjustable between 3-10″ H2O, but by modifying the spring spacer I bumped it up to 8-16″ H2O. This is probably the leakiest of all the valves because it requires a large hole- a larger hole is harder to seal because the seal is longer. Usually these are installed with a sort of large rubber washer with a C-cross section. The material the seal is attaching to goes in the open part of the C, and the washer is glued in. Since I don’t have that washer, I haven’t installed it yet and I have been avoiding overpressure via the “oro-pharyngial” valve.

Leak Testing

Intensive leak testing (more here) allowed me to validate the design before committing to a whole build. That was important, because a lot of things did not work initially. For example, I couldn’t apply enough torque to the brass thumbscrews to seal the bag, so I had to switch to a nylock nut. Another example is that the original gasket for the bulkhead seals was determined to be inadequate.


harness hardpoints highlighted in orange

Just like with i3, the last thing I was really prepared to deal with was attaching this to my body. Unlike the i3, I knew that this challenge was coming. I considered something like a vest a la model 138, but that would require buying a few yards of fabric and knowing what to do with it, and getting a sewing machine. Instead, borrowed some inspiration from an oxydiver design (link) and backplates and designed in slots for a hogarthian harness. In the end, I actually think this is better since it is now compatible with all kinds of 2″ webbing accessories.

Divers view of the gas

Of course, there is no backplate, and the gas is mounted on the front of the diver. After playing around with a bucket of sliders and clips I came up with a simple loop around the two canisters, with a 2″ long loop at one end to put the waist strap through.


Another gem from the Nikonos

This rebreather is actually very fun to dive. I would actually consider diving this over OC on shallow dives. However, no project is ever perfect. The three things I will likely seek to improve in the inevitable i5 are:

  • Terrestrial O2 regs rust and fail. O2 is expensive in small disposable bottles, and having a million of them around is silly. There is also no SPG. Normal scuba cylinders and regs are far superior.
  • No place to put an inflation cylinder for drysuit. Even in 20′ of water I think I would prefer a drysuit over wet- especially if I were to dive in the winter.
  • People say YERGONNADIE if you dont know your PPO2. There is some merit to this claim, but I feel it is not likely if you respect the depth limitations of an o2 rebreather.

A lot of these changes or issues have implications- if you have an inflation cylinder, why not make it breathable as backup? If you add oxygen sensing, why not add that breathable cylinder as dil? If you give an engineer a cookie…