Projects / Ultrasonic cleaner timer

Ultrasonic cleaner timer

Beginner1 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANO

    Wire the display and encoder

    Test the numbers change.

  2. NANO

    Add the buzzer

    Test one beep.

  3. NANOON

    Add the relay module

    Test it clicks with no mains connected.

  4. NANO

    Upload the sketch

    Check set, start and stop.

  5. NANO

    Have the mains side wired

    By a qualified electrician, in a closed box.

  6. NANO

    Test a short run

    Thirty seconds with water in the tank.

  7. NANO

    Label the box

    Note the maximum load.

In short

How do you build an ultrasonic cleaner timer?

Add a programmable timer to a cheap ultrasonic cleaner for cleaning PCBs and flux. You need Arduino Nano, TM1637 4-digit display, Rotary encoder module (KY-040), Relay Module 5V and Active buzzer 5 V. It takes 7 steps and about 60 minutes.

Level
Beginner
Time
About 60 min
Parts
5

Parts list

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

Wiring

FromToWhy
TM1637 CLK and DIONano D2 and D3Time display
TM1637 VCC and GNDNano 5V and GNDPower
Encoder CLK, DT, SWNano D4, D5, D6Set the time and start (inputs use the internal pull-ups)
Encoder common (GND)Nano GNDReturn path
Relay module INNano D7Switches the cleaner
Relay module VCC and GNDNano 5V and GNDCoil power
Buzzer plus and minusNano D8 and GNDBeep when finished
Cleaner supply leadThrough the relay contacts, by a qualified electricianMains side

Code

Ultrasonic cleaners are mains appliances, so the safe way to add a timer is to leave the cleaner itself untouched and put a relay in its supply lead. The mains side of this build must be wired by a qualified electrician, inside a closed enclosure, with the relay module's rating checked against the cleaner and a fuse in the supply. Do not wire mains yourself unless you are qualified. You can build and test everything else without mains: connect an LED and a resistor to the relay's contacts from a battery and watch it switch. Turn the knob to step the time in 30-second jumps from half a minute to half an hour, press to start, and the relay clicks on until the display reaches zero, then three beeps. A second press stops early. Cleaners used on flux need a ventilated place, and never put a hand in the tank while it runs. The relay is off while the Nano starts, so the cleaner cannot switch on by itself. 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).

// Ultrasonic cleaner timer: turn the knob to set the time, press to start, press again to stop.
// Library: TM1637Display (Avishay Orpaz). Board: Arduino Nano.
#include <TM1637Display.h>
TM1637Display disp(2, 3);
const uint8_t PIN_A = 4, PIN_B = 5, PIN_SW = 6, PIN_RELAY = 7, PIN_BUZ = 8;
const bool RELAY_ON = LOW;               // most relay modules switch on with a LOW input; set HIGH if yours is the opposite
int setSeconds = 180;
bool running = false;
unsigned long endAt = 0;
int lastA;
void show(long secs) {
  disp.showNumberDecEx((secs / 60) * 100 + (secs % 60), 0x40, true);   // 0x40 lights the colon
}
void finish() {
  digitalWrite(PIN_RELAY, !RELAY_ON);
  running = false;
  for (int i = 0; i < 3; i++) { tone(PIN_BUZ, 2000, 250); delay(400); }
  show(setSeconds);
}
bool pressed() {
  if (digitalRead(PIN_SW) == LOW) {
    delay(30);
    while (digitalRead(PIN_SW) == LOW) {}
    return true;
  }
  return false;
}
void setup() {
  pinMode(PIN_A, INPUT_PULLUP); pinMode(PIN_B, INPUT_PULLUP); pinMode(PIN_SW, INPUT_PULLUP);
  pinMode(PIN_RELAY, OUTPUT);
  digitalWrite(PIN_RELAY, !RELAY_ON);    // start with the cleaner off
  disp.setBrightness(5);
  lastA = digitalRead(PIN_A);
  show(setSeconds);
}
void loop() {
  if (!running) {
    int a = digitalRead(PIN_A);
    if (a != lastA && a == LOW) {
      if (digitalRead(PIN_B) == HIGH) setSeconds += 30; else setSeconds -= 30;
      setSeconds = constrain(setSeconds, 30, 1800);
      show(setSeconds);
    }
    lastA = a;
    if (pressed()) {
      running = true;
      endAt = millis() + (unsigned long)setSeconds * 1000UL;
      digitalWrite(PIN_RELAY, RELAY_ON);
    }
  } else {
    long remaining = (long)(endAt - millis());
    if (remaining <= 0) { finish(); return; }
    show((remaining + 999) / 1000);
    if (pressed()) finish();             // press again to stop early
    delay(100);
  }
}

Test checklist

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

CheckExpected
Turn the knobTime moves in 30 second steps
Press to startRelay clicks on, display counts down
Reach zeroRelay off, three beeps
Press during a runStops at once

If it does not work

Relay is on at power-up

Your module is active-high; change RELAY_ON.

Display shows nothing

Check CLK and DIO are not swapped.

Knob counts the wrong way

Swap the A and B pins.

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

Ask Lark AI

Common questions

What parts do I need for the ultrasonic cleaner timer?

Arduino Nano, TM1637 4-digit display, Rotary encoder module (KY-040), Relay Module 5V and Active buzzer 5 V.

How long does the ultrasonic cleaner timer take to build?

About 60 minutes for a beginner maker, in 7 steps.

How do I know the ultrasonic cleaner timer works?

Turn the knob: Time moves in 30 second steps. Press to start: Relay clicks on, display counts down. Reach zero: Relay off, three beeps.

Relay is on at power-up: what should I check?

Your module is active-high; change RELAY_ON.

Display shows nothing: what should I check?

Check CLK and DIO are not swapped.

Knob counts the wrong way: what should I check?

Swap the A and B pins.