An overview of different ways to measure electrical conductivity.

I've been gathering links and resources for my new EC project, and I've posted a summary of that information on the Cave Pearl Project Blog:

Since the people on this forum have probably already tried their hand at several of the EC methods I've described, and more that I've missed, I'd love to hear about any new material I could add to that overview.

cheers!

You missed the very simplest way out there, using two resistors and a capacitor (the resistors are there just to protect the pins of your microcontroller - the bare minimum is the capacitor) to create a high frequency AC (3-100 kHz or so). Minor downside: it needs three digital pins.

I'm getting <2% error measuring 0.1-5 mS/cm this way on my ESP8266 (haven't implemented in on an Arduino yet). Original research paper here. Arduino will be less accurate. The ESP can measure 12.5 ns intervals; the Arduino if you can get to count clock ticks will be able to do 62.5 ns which is still good enough for this.

My implementation of this is due to be open sourced soon.

I already had that paper in the links, but the cap-discharge idea starts with the intro from Jim Conner’s youtube video, because I liked the way he walked through how the blue truncheon (a sensor that uses this method) works.

I noticed your schematic which is similar, but seems to miss the opposite current - essential to stop electrolyses. By using an AC you can measure essentially non-stop.

The hardest part is the probe that goes in the water - I bought a bunch off Taobao, but they turn out to leak and EC creeps up over time :frowning: Only in China... non-waterproof water sensors...

I've changed the color on that cap discharge paper link to make it more visible.

We used the epoxy/graphite EC probes I list in the table for a cave monitoring project many years ago, and they were submerged for more than 2 years with stable results. My only problem with them is that they are K=1, so they have too much surface area for the fresh to marine (actually to hard brine) environments we have our deployments in. I might try coating them with new epxoy just to push the cell constant higher.
Sometimes people sell those Hanna pen-probes "broken for parts" on eBay, and its worth picking those up just for the EC probe.

Planning to use gold coated pin headers myself. Almost the same dimensions as the standard EC probes that I bought.
Pretty cheap, and can be directly soldered onto the PCB.

Actually I don't care about cell constants, not even about the actual value of the capacitor and resistors. That's where the calibration comes in. Can be done with just two measurements: one where you short the two pins, one where you place them in a known solution.

I don't know how well my solution performs in seawater. It's easy to bring the range up to a higher conductivity, just use a larger capacitor for that (now 22 nF which is great for hydroponic solutions, may have to switch it for a 220 nF or even 470 nF one for seawater kind of salinities).

You and I are probably working on exactly the same things right now but with two different methods. It will be interesting to see who gets there first :slight_smile:

Like you I am ignoring cell constants (and a host of other complicating factors), but because of that it will be a few days before I wrangle my fit equations into something with low enough error. My target range is 0.5mS/cm to 55mS/cm, but getting the fit to go that far is taking some work...

Waiting for some nichrome 80 wire to come in as well, as my current diy probes barely make it 6 hours in seawater equivalent before they start to drift. Marine grade stainless steel simply isn't. It's a sales myth.

Is there some problem with making probes the old fashioned way? Platinum wire sealed in a thin glass tube.

Paul

WRT platinum, the issue is simply cost. One of my goals is to find an electrode that doesn't cost $100 each but is still reliable. If possible I'd also like it to be something that does not take a great deal of time to assemble. Not sure if all that is possible at the same time though.

Paul_KD7HB:
Is there some problem with making probes the old fashioned way? Platinum wire sealed in a thin glass tube.

Paul

Price is one. Those are expensive, and just about impossible to build yourself.

The sensor I'm developing I expect to sell at well under USD 10, probably less than half that. It'll be open source & open hardware so the DIY crowd can try and build their own if they want.

Eagerly awaiting PCB prototypes with just this sensor. Gotta get them soon, will definitely have to test them in sea water kind of concentrations (55 mS/cm is 27500 ppm of NaCl in water; trivial to make).

I'm now using a 10 nF capacitor, and have a time of just over 2 microseconds for the 1840 ppm solution. At a 12.5 ns resolution that's comfortable. It also makes for an overall AC frequency of about 250 kHz.

To get to 27500 ppm, one would need a capacitor of 150 nF to get to the 2 us discharge times. Of course at the other end of the scale, it's going to be slower to discharge with lower frequency.

The problem of the AC frequency: under about 3 kHz and above about 300 kHz it's not linear. It's just a little off down to 1 kHz, and you can go to maybe 500 kHz or even 1 MHz on the upper end, but that's it. The accurate range is about two order of magnitude, an extended range would be nearing three orders of magnitude.

This means a 0.5-55 mS/cm range is no problem, but I will have to use a bigger capacitor and not sure if that's going to fit that well in my tiny tiny probe (for more stable timing in this very wet environment, I've opted for film capacitors rather than smaller, cheaper ceramics). It could even give your an extended range of 0.1-100 mS/cm - total three orders of magnitude.

For my hydroponic application I'm going to use a 22 nF capacitor, to push the upper range a bit, as I hope to end up at a 0.1-10 mS/cm range. Typical hydroponic solutions are 1-2 mS/cm.

EKMallon:
WRT platinum, the issue is simply cost. One of my goals is to find an electrode that doesn't cost $100 each but is still reliable. If possible I'd also like it to be something that does not take a great deal of time to assemble. Not sure if all that is possible at the same time though.

It took me a minute or two to wire up on a protoboard, then a month to get the software done. That was tricky. Learnt a lot about programming in the process, which in part is why it took so long to get right.

Major hurdles were figuring out how to use interrupts, how to keep the ISR in memory, and how to stop those dreaded "wdt reset" crashes from the ESP8266 from happening...

Now the fun of porting to Arduino (got a 16 MHz, 5V, pro micro clone for that), and ATtiny (8 MHz, no external crystal, so even slower in timing, got the 13, 25 and 85 - assuming it's even possible to pull off on those chips).

I just Googled platinum wire and found thermocouple wire, Platinum-Rhodium Thermocouple Wire, that looks pretty cheap to me. Glass tubing to fit and a gas flame to melt the glass around the wire seemed pretty easy to do.

Paul

Paul_KD7HB:
I just Googled platinum wire and found thermocouple wire, Platinum-Rhodium Thermocouple Wire, that looks pretty cheap to me. Glass tubing to fit and a gas flame to melt the glass around the wire seemed pretty easy to do.

Ah, you forgot the important part: getting a reading from that probe. That's actually the hard part, an EC probe is not much more than two pieces of conductive material placed a bit apart from one another in the liquid you want to measure. The probe is made much cheaper with two pieces of nickel or stainless steel and some plastic to hold it in place. Or, what I've ordered and what hopefully works well: gold plated pin headers.

The hard part is getting a reading out of the probe. You're trying to measure an ionic substance, which means you can not apply a DC current as almost instantly the ions start to move and a moment later electrolyses starts and your resistance changes. So you have to use some form of high frequency AC, to prevent that from happening. But also not too high frequency as then you get other effects.

Just using very short pulses of DC is also not good, you must apply the same amount of current in the opposite direction as well to compensate.

wvmarle:
This means a 0.5-55 mS/cm range is no problem, but I will have to use a bigger capacitor and not sure if that's going to fit that well in my tiny tiny probe (for more stable timing in this very wet environment, I've opted for film capacitors rather than smaller, cheaper ceramics).

Good - high value ceramics are hopeless for measurement, they are highly non-linear, highly
temperature sensitive and respond electrically to mechanical shock and impacts. Plastic film is the
correct choice.

High value capacitors have a problem though - charging them directly from a microcontroller pin
overloads the pin for longer, increasing the chance of damage to that pin's output FETs. Adding series
resistance to the C+/C- pins would probably be wise to do.

That's what I did. But only on the C+ pin, as that protects the C- pin just the same. And one on the EC pin to have a minimum resistance there, too. Come to think of it, I could drop one by moving it onto the C- pin. As long as one side of the capacitor has the resistor, both sides are protected.

This resistor may become an issue for larger capacitors and high EC values as the resistance of the liquid becomes very small compared to that of the protection resistor, and a current much greater than 20 mA would be required, and with it some kind of driver circuit.

Would this work to charge/discharge a capacitor faster? (it reverses the signal: high on the output connects this side of the capacitor to GND, low connects it to Vcc). This would be the C- side. Two more of these circuits (without R2) for the C+ and EC pins.

R1: 1k or so.
R2: small resistor, maybe 10 Ohm, to protect the switching transistors (not sure if needed) - maybe only on C- side.
C1: largish capacitor, 200-500 nF, which needs some 200 mA to charge fast enough.
Sea water, 55 mS/cm, expecting about 5-10 Ohm resistance between two small pins, 2.5 mm apart.

Not sure though how to deal with the detection part now; C+ can't be used for that; may need a fourth pin even.

It wouldn't work to do that, it would work to short out your supply and fry two transistors though.

Two separate base resistors are required.

You'd have to characterise the switch-off time of the transistors.

Logic-level n-MOSFET and p-MOSFET would be better, you can get a complementary pair in a single
SOIC8 or SOT23-6 package.

MarkT:
It wouldn't work to do that, it would work to short out your supply and fry two transistors though.

Mmm... yes, that's right.
The switch time I was thinking of already, I guess the venerable BC547 won't do here :slight_smile:

Logic-level n-MOSFET and p-MOSFET would be better, you can get a complementary pair in a single
SOIC8 or SOT23-6 package.

Suggestions for specific components? May be interesting for future experimenting.

Schematic needs to be a bit more complex than I first anticipated. This as both EC and CapPos have to be set to INPUT and at times in the cycle, so there has to be a way to switch off both MOSFETs at the same time. That's where the pull-up and pull-down resistors and the two diodes come in play. Resistors to switch off the MOSFET, diodes to prevent them messing with each other.

Ignore the part number; that's just one that happens to be in KiCAD. No idea if the part is suitable for this application, it's just a combo of N and P channel MOSFET.

@wvmarle

Stepping back a bit: If you are still making prototypes, then would it be possible to leave a couple of solder points available to increase the capacitor/range as an option later?

I will be keen to hear how long those gold pins last in solution.

Also, I was wondering if this was your post about digital pin weirdness with the cap discharge method:

https://www.queryxchange.com/q/26_302096/water-conductivity-measurements-esp8266-getting-strange-results/

I'll be trying different caps in some situations, but the circuit is so simple it can be very easily built on a protoboard or even solderless breadboard and still be highly reliable. The mosfet circuit is not something I plan to build now, my target is hydroponics, but it's interesting for the future. Seawater is of course common, and not only ocean researchers but also seawater aquarium enthusiasts may benefit from such a probe.

That post you linked to was indeed mine (original should be on stackexchange iirc). Looking at it for weeks; getting rather consistent results across the board (highly reproducible even across hardware), in the end found out it's a mathematical error. The shape of the curves gave that away: I needed to the the reciprocal of one of the parameters. Forgot what it was exactly, but after that correction everything, including older measurements, fell into place.

I'm also curious how the gold pins will last. It'll be placed inside a housing, so protected from touch. I have opted for the 3u thickness, the highest available, to give me the best chance. In theory at least it should be completely unaffected by corrosion.

If that doesn't work I've to look at other materials. Stainless steel while up to the job can't be soldered, so it'd be something else. Cost and manufacturing complexity do go up this way.