ESP32 laundry cycle end beeper
Build it step by step
0 of 7 doneWire the sensor
VCC to 3V3, GND to GND, DO to GPIO27.
Wire the buzzer
GPIO26 and GND.
Upload the sketch
Open the Serial Monitor at 115200.
Tap the sensor
The board's light flickers and the count rises.
Set the dial
So that the light stays off at rest.
Fix the sensor
To the side panel of the machine with tape.
Run a short wash
The count rises, and after it ends five quiet minutes later it beeps.
How do you build an ESP32 laundry cycle end beeper?
An ESP32 with a vibration sensor stuck on a washing machine notices when the shaking stops for five minutes and sounds a short beep, so you know the load is done. You need ESP32 DevKit V1, Vibration sensor module (SW-420), Active buzzer 5 V and Breadboard 830 Tie Points. It takes 7 steps and about 130 minutes.
- Level
- Beginner
- Time
- About 130 min
- Parts
- 4
Parts list
- Development BoardsBuyESP32 DevKit V1 × 1
- SensorsBuy
- Motors & ActuatorsBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Vibration module VCC | ESP32 3V3 | Power at 3.3 V |
| Vibration module GND | ESP32 GND | Common ground |
| Vibration module DO | ESP32 GPIO27 | Pulses when it shakes |
| Buzzer + | ESP32 GPIO26 | Alert sound |
| Buzzer - | ESP32 GND | Ground |
Code
The SW-420 is a vibration switch on a small board with a comparator. When the board shakes, the switch inside opens and closes, and the output pin pulses. A small dial on the board sets how much shaking it takes. The program counts the pulses in an interrupt, which runs the moment a pulse arrives so that none are missed, and every minute it looks at the count. Five or more pulses in a minute means the machine is running. After it has been running, five minutes in a row with fewer than five pulses means the wash has finished, so the buzzer sounds. The delay of five minutes covers the quiet soaking pauses in a wash cycle. Stick the sensor to the side panel of the machine, not near a hot surface, keep the wiring clear of water and moving parts, and set the dial so that the board's light flickers only while the machine is shaking.
Runs on a virtual ESP32 Dev Module 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).
const int SENSOR = 27;
const int BUZZER = 26;
const unsigned long MINUTE = 60000UL;
const int RUN_PULSES = 5; // shakes per minute that mean the machine is running
const int QUIET_MINUTES = 5; // quiet minutes that mean it has finished
volatile unsigned long pulses = 0;
bool running = false;
int quietCount = 0;
unsigned long windowStart = 0;
void IRAM_ATTR onShake() {
pulses++;
}
void beepFinished() {
for (int i = 0; i < 5; i++) {
digitalWrite(BUZZER, HIGH); delay(150);
digitalWrite(BUZZER, LOW); delay(150);
digitalWrite(BUZZER, HIGH); delay(150);
digitalWrite(BUZZER, LOW); delay(1500);
}
}
void setup() {
Serial.begin(115200);
pinMode(BUZZER, OUTPUT);
pinMode(SENSOR, INPUT);
attachInterrupt(digitalPinToInterrupt(SENSOR), onShake, FALLING);
windowStart = millis();
}
void loop() {
if (millis() - windowStart >= MINUTE) {
noInterrupts();
unsigned long count = pulses;
pulses = 0;
interrupts();
windowStart = millis();
Serial.print("Shakes this minute: "); Serial.println(count);
if (count >= RUN_PULSES) {
running = true;
quietCount = 0;
} else if (running) {
quietCount++;
if (quietCount >= QUIET_MINUTES) {
Serial.println("Finished");
beepFinished();
running = false;
quietCount = 0;
}
}
}
delay(50);
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| At rest | Shakes this minute: 0 |
| Machine spinning | Many shakes each minute |
| Machine stops | Count falls to 0 |
| Five quiet minutes later | Five beep groups and Finished |
| Next load | Starts watching again |
If it does not work
Count is always zero
Turn the dial towards more sensitive and check DO is on GPIO27.
Count is high at rest
Turn the dial the other way, and fix the sensor firmly so it does not rattle.
Alerts during the soak pause
Raise QUIET_MINUTES to 8.
Never alerts
Check the buzzer wires and that the machine reached five shakes a minute.
Sensor falls off
Use stronger tape or a magnet.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the ESP32 laundry cycle end beeper?
ESP32 DevKit V1, Vibration sensor module (SW-420), Active buzzer 5 V and Breadboard 830 Tie Points.
How long does the ESP32 laundry cycle end beeper take to build?
About 130 minutes for a beginner maker, in 7 steps.
How do I know the ESP32 laundry cycle end beeper works?
At rest: Shakes this minute: 0. Machine spinning: Many shakes each minute. Machine stops: Count falls to 0.
Count is always zero: what should I check?
Turn the dial towards more sensitive and check DO is on GPIO27.
Count is high at rest: what should I check?
Turn the dial the other way, and fix the sensor firmly so it does not rattle.
Alerts during the soak pause: what should I check?
Raise QUIET_MINUTES to 8.
Never alerts: what should I check?
Check the buzzer wires and that the machine reached five shakes a minute.
