Salinity meter for aquariums and salt pans
Build it step by step
0 of 7 doneBuild the probe
Two stainless screws at a fixed gap.
Wire the circuit
Series resistor and Nano pins.
Measure conductance
Alternating polarity.
Add temperature
Compensate to 25 degrees.
Calibrate
Known salt solutions.
Show on the LCD
Temperature, conductance and salinity.
Check against a refractometer
For an aquarium.
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
- Development BoardsBuyArduino Nano × 1
- PassivesBuyResistor 1 kΩ × 1
- SensorsBuy
- PassivesBuyResistor 4.7 kΩ × 1
- DisplaysBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Nano D2 | Stainless electrode A | Drive one side |
| Electrode B | Test node, Nano A0 | Other electrode and sense point |
| Test node | 1 kΩ resistor to Nano D3 | Series sense resistor |
| DS18B20 data | Nano D4, with 4.7 kΩ to 5V | Water temperature |
| LCD SDA and SCL | Nano A4 and A5 | Display |
| Supply | USB | Power |
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.
| Check | Expected |
|---|---|
| Fresh water | Very low conductance |
| Salt solutions | Conductance rises with salt |
| Warm and cold samples | Compensated readings agree |
| Calibration | Matches 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 →
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.
