Projects / Salinity meter for aquariums and salt pans

Salinity meter for aquariums and salt pans

Intermediate2 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANODS18B2021.9°C

    Build the probe

    Two stainless screws at a fixed gap.

  2. NANO

    Wire the circuit

    Series resistor and Nano pins.

  3. NANO

    Measure conductance

    Alternating polarity.

  4. NANO

    Add temperature

    Compensate to 25 degrees.

  5. NANO

    Calibrate

    Known salt solutions.

  6. NANOHelloPCF8574

    Show on the LCD

    Temperature, conductance and salinity.

  7. NANO

    Check against a refractometer

    For an aquarium.

In short

How do you build a salinity meter for aquariums and salt pans?

Two stainless electrodes driven with AC measure water conductivity to estimate salinity without plating the electrodes. You need Arduino Nano, Resistor 1 kΩ, DS18B20 waterproof probe, Resistor 4.7 kΩ and 16x2 LCD with I2C backpack (PCF8574). It takes 7 steps and about 120 minutes.

Level
Intermediate
Time
About 120 min
Parts
5

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Nano D2Stainless electrode ADrive one side
Electrode BTest node, Nano A0Other electrode and sense point
Test node1 kΩ resistor to Nano D3Series sense resistor
DS18B20 dataNano D4, with 4.7 kΩ to 5VWater temperature
LCD SDA and SCLNano A4 and A5Display
SupplyUSBPower

Code

Salt water conducts well, and the more salt, the better. Pushing a steady current through two electrodes would plate and corrode them and give drifting readings, so the sketch reverses the direction on each measurement and leaves both pins low in between; the average of the two directions gives the conductance, together with the 1 kΩ series resistor. Conductivity rises about 2 percent for each degree, so the temperature sensor lets the sketch correct every reading to 25 degrees. To calibrate, make solutions of known strength by dissolving a weighed amount of salt in a measured amount of water, for example 35 grams in a litre for roughly sea strength, take readings, and set K so the display matches; check at two strengths, as the relationship is only roughly a straight line. Use stainless screws epoxied in a holder at a fixed spacing, and rinse and dry them after use. For an aquarium, verify with a refractometer before relying on it, as sensitive animals die from errors in salinity. The probe is not for drinking-water or safety checks. Arduino IDE, board "Arduino Nano" (try the Old Bootloader option if the upload fails).

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// Salinity meter: alternating-polarity conductivity, temperature compensated. Libraries: OneWire, DallasTemperature, LiquidCrystal_I2C. Board: Arduino Nano.
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
OneWire ow(4);
DallasTemperature probe(&ow);
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int A = 2, B = 3, SENSE = A0;
const float RSENSE = 1000.0;
float K = 1.0;                                      // calibration constant, parts per thousand per millisiemens: set from a known solution
float conductance() {                               // in siemens
  float sum = 0;
  for (int i = 0; i < 20; i++) {
    pinMode(A, OUTPUT); pinMode(B, OUTPUT);
    digitalWrite(A, HIGH); digitalWrite(B, LOW); delayMicroseconds(300);
    float v1 = analogRead(SENSE) * 5.0 / 1023.0;    // voltage across the series resistor (B is low)
    digitalWrite(A, LOW); digitalWrite(B, HIGH); delayMicroseconds(300);
    float v2 = 5.0 - analogRead(SENSE) * 5.0 / 1023.0;
    digitalWrite(B, LOW);                           // both low between measurements: no net DC through the water
    float vr = (v1 + v2) / 2.0;
    float vw = 5.0 - vr;
    if (vw > 0.02) sum += (vr / RSENSE) / vw;
    delay(5);
  }
  return sum / 20.0;
}
void setup() {
  probe.begin(); lcd.init(); lcd.backlight();
}
void loop() {
  probe.requestTemperatures();
  float t = probe.getTempCByIndex(0);
  float g = conductance();
  float g25 = g / (1.0 + 0.02 * (t - 25.0));        // 2 percent per degree compensation
  float ppt = K * g25 * 1000.0;                     // salinity estimate
  lcd.clear();
  lcd.setCursor(0, 0); lcd.print(t, 1); lcd.print("C  "); lcd.print(g25 * 1e6, 0); lcd.print("uS");
  lcd.setCursor(0, 1); lcd.print("Sal ~"); lcd.print(ppt, 1); lcd.print(" ppt");
  delay(1000);
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Fresh waterVery low conductance
Salt solutionsConductance rises with salt
Warm and cold samplesCompensated readings agree
CalibrationMatches known solutions

If it does not work

Reading drifts

Rinse the electrodes and check the polarity switching.

Always maximum

Electrodes touching or shorted.

Low accuracy

Fix the electrode gap and calibrate at two strengths.

Corroded screws

Use proper stainless and rinse after use.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the salinity meter for aquariums and salt pans?

Arduino Nano, Resistor 1 kΩ, DS18B20 waterproof probe, Resistor 4.7 kΩ and 16x2 LCD with I2C backpack (PCF8574).

How long does the salinity meter for aquariums and salt pans take to build?

About 120 minutes for a intermediate maker, in 7 steps.

How do I know the salinity meter for aquariums and salt pans works?

Fresh water: Very low conductance. Salt solutions: Conductance rises with salt. Warm and cold samples: Compensated readings agree.

Reading drifts: what should I check?

Rinse the electrodes and check the polarity switching.

Always maximum: what should I check?

Electrodes touching or shorted.

Low accuracy: what should I check?

Fix the electrode gap and calibrate at two strengths.

Corroded screws: what should I check?

Use proper stainless and rinse after use.