Projects / RO water purifier filter life counter

RO water purifier filter life counter

Intermediate2 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANOS201

    Fit the flow sensor

    On the tank to tap line.

  2. NANO

    Wire the display and button

    Test the screen.

  3. NANO

    Check the pulse count

    Pour one litre and compare.

  4. NANO

    Adjust PULSES_PER_L

    If the count is off.

  5. NANOTDS

    Add the TDS probe

    Compare with a known sample.

  6. NANO

    Test the reset

    Hold the button for 3 seconds.

  7. NANO

    Set the litre limit

    From your filter's rating.

In short

How do you build an RO water purifier filter life counter?

A flow sensor counts litres drawn from an RO purifier and a TDS probe checks output quality, reminding you when to change the filters. You need Arduino Nano, Water flow sensor YF-S201, TDS sensor module, 16x2 LCD with I2C backpack (PCF8574) and Tactile push button 6 mm. 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
YF-S201 signalNano D2 (interrupt)Pulses, about 450 per litre
YF-S201 red and blackNano 5V and GNDPower
TDS module signalNano A1Water quality reading
TDS module VCC and GNDNano 5V and GNDPower
LCD SDA and SCLNano A4 and A5I2C display (address 0x27 or 0x3F)
LCD VCC and GNDNano 5V and GNDPower
Reset buttonNano D3 and GNDHold 3 s after a filter change (internal pull-up)

Code

A filter's life is set by how much water has passed through it, so the sensible reminder is a litre counter, backed up by a quality check. The YF-S201 gives about 450 pulses per litre, and it needs a flow of at least about one litre a minute to count reliably, so fit it on the line from the storage tank to the tap, where the flow is higher, not on the slow trickle that fills the tank. Fit it in a clear section of tube with the arrow pointing along the flow, and use food-grade fittings. The count is stored in EEPROM once per litre so a power cut does not lose it. The TDS probe reads dissolved solids in the output water, and a steadily rising number means a membrane is tiring; it needs to be in water, and its number is only a rough guide. Set LIMIT_L from the manufacturer's rating, and treat the display as a reminder, not as proof that water is safe to drink. If you have any doubt about the water, test it properly or change the filters. 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).

// RO filter life counter: counts litres, reads TDS, stores the total in EEPROM, reminds at a set number of litres.
// Libraries: LiquidCrystal I2C (Frank de Brabander), EEPROM (built in). Board: Arduino Nano.
#include <EEPROM.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);          // try 0x3F if the screen stays blank
const uint8_t FLOW = 2, BTN = 3, TDS_PIN = A1;
const float PULSES_PER_L = 450.0;            // YF-S201 datasheet figure; calibrate with a measuring jug
const unsigned long LIMIT_L = 3000;          // set from your filter's rating
volatile unsigned long pulses = 0;
unsigned long totalPulses = 0, lastSavedL = 0, lastLcd = 0, btnDown = 0;
void onPulse() { pulses++; }
float readTds() {
  long sum = 0;
  for (int i = 0; i < 20; i++) { sum += analogRead(TDS_PIN); delay(5); }
  float v = (sum / 20.0) * 5.0 / 1023.0;
  return (133.42 * v * v * v - 255.86 * v * v + 857.39 * v) * 0.5;   // common formula for these modules at 25 C
}
void setup() {
  pinMode(FLOW, INPUT_PULLUP); pinMode(BTN, INPUT_PULLUP);
  EEPROM.get(0, totalPulses);
  if (totalPulses == 0xFFFFFFFFUL) totalPulses = 0;       // blank EEPROM
  lastSavedL = (unsigned long)(totalPulses / PULSES_PER_L);
  lcd.init(); lcd.backlight();
  attachInterrupt(digitalPinToInterrupt(FLOW), onPulse, RISING);
}
void loop() {
  noInterrupts(); unsigned long p = pulses; pulses = 0; interrupts();
  totalPulses += p;
  unsigned long litres = (unsigned long)(totalPulses / PULSES_PER_L);
  if (litres != lastSavedL) { EEPROM.put(0, totalPulses); lastSavedL = litres; }    // one write per litre keeps the EEPROM healthy
  if (digitalRead(BTN) == LOW) {
    if (btnDown == 0) btnDown = millis();
    if (millis() - btnDown > 3000) { totalPulses = 0; EEPROM.put(0, totalPulses); lastSavedL = 0; btnDown = 0; lcd.clear(); lcd.print("Count reset"); delay(1500); }
  } else btnDown = 0;
  if (millis() - lastLcd > 2000) {
    lastLcd = millis();
    float tds = readTds();
    lcd.clear();
    lcd.setCursor(0, 0); lcd.print("Used "); lcd.print(litres); lcd.print(" L");
    lcd.setCursor(0, 1);
    if (litres >= LIMIT_L) lcd.print("CHANGE FILTERS");
    else { lcd.print("TDS "); lcd.print((int)tds); lcd.print(" ppm"); }
  }
}

Test checklist

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

CheckExpected
Pour 1 litreCount rises by about 1
Power off and onTotal is kept
Hold the button 3 sCount resets
Reach the limitShows CHANGE FILTERS

If it does not work

Count stays zero

Flow is too low; fit it where flow is higher.

Count too high or low

Adjust PULSES_PER_L with a jug.

TDS jumps

Keep the probe still and out of air bubbles.

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

Ask Lark AI

Common questions

What parts do I need for the RO water purifier filter life counter?

Arduino Nano, Water flow sensor YF-S201, TDS sensor module, 16x2 LCD with I2C backpack (PCF8574) and Tactile push button 6 mm.

How long does the RO water purifier filter life counter take to build?

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

How do I know the RO water purifier filter life counter works?

Pour 1 litre: Count rises by about 1. Power off and on: Total is kept. Hold the button 3 s: Count resets.

Count stays zero: what should I check?

Flow is too low; fit it where flow is higher.

Count too high or low: what should I check?

Adjust PULSES_PER_L with a jug.

TDS jumps: what should I check?

Keep the probe still and out of air bubbles.