Contact Sales & After-Sales Service

Contact & Quotation

  • Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
  • Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Drag & Drop Files, Choose Files to Upload You can upload up to 3 files.

Notes:
For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.

Vibration Sensor Arduino: SW-420 Module Guide

When you need to detect vibrations, shocks, or sudden movements in your electronics projects, the SW-420 vibration sensor paired with Arduino provides an affordable and reliable solution. I’ve used these modules in everything from anti-theft systems to machine monitoring setups, and they consistently deliver solid performance for their price point.

In this guide, I’ll walk you through the complete process of interfacing the SW-420 vibration sensor with Arduino, covering the working principle, wiring connections, code examples, and practical applications based on real project experience.

What Is the SW-420 Vibration Sensor?

The SW-420 is a non-directional vibration sensor module designed to detect physical vibrations, shocks, tilts, and sudden movements. Unlike accelerometers that measure acceleration values across multiple axes, the SW-420 provides a simple binary output indicating whether vibrations are present or absent.

The module combines three key components: the SW-420 vibration switch itself, an LM393 voltage comparator IC, and an adjustable potentiometer for sensitivity tuning. This combination produces clean digital signals that any microcontroller can easily interpret.

How the SW-420 Vibration Sensor Works

Inside the SW-420 switch, there’s a conductive spring and a metal rod housed within a small tube. In a stable, vibration-free state, the spring maintains contact with the rod, keeping the circuit closed. When vibrations occur, the spring moves away from the rod momentarily, breaking the circuit and creating a resistance change.

The LM393 comparator monitors this signal and compares it against a reference voltage set by the onboard potentiometer. When vibration amplitude exceeds the threshold, the comparator outputs a digital HIGH signal. Otherwise, it outputs LOW.

SW-420 Vibration Sensor Arduino Specifications

Understanding the technical specifications helps you integrate the sensor properly into your projects.

ParameterValue
Operating Voltage3.3V – 5V DC
Output TypeDigital (HIGH/LOW)
Comparator ICLM393
Output Drive Capability>15mA
Default StateNormally Closed (NC)
Module Dimensions32mm x 14mm
MountingBolt holes included

SW-420 Vibration Sensor Pinout

The module has a straightforward three-pin interface that makes wiring simple.

PinNameFunction
1VCCPower supply input (3.3V-5V)
2GNDGround connection
3DODigital output signal

The module also features two LED indicators: a power LED that illuminates when voltage is applied, and an output LED that lights up when vibration exceeds the set threshold.

Wiring the SW-420 Vibration Sensor to Arduino

Connecting the vibration sensor Arduino circuit takes just three wires. Here’s the complete connection diagram:

SW-420 PinArduino Pin
VCC5V
GNDGND
DODigital Pin 2 (or any digital pin)

For projects that include visual or audible alerts, you can add an LED with a 220-ohm current limiting resistor connected to pin 13, and a buzzer connected to pin 3.

Sensitivity Adjustment

The onboard potentiometer allows you to fine-tune detection sensitivity. Turn it clockwise to increase sensitivity (detect smaller vibrations) or counter-clockwise to decrease sensitivity (require stronger vibrations to trigger).

I recommend starting with medium sensitivity and adjusting based on your specific application. For security applications, higher sensitivity catches subtle tampering attempts. For machine monitoring where some vibration is normal, lower sensitivity prevents false alarms.

Arduino Code for SW-420 Vibration Sensor

Here’s a complete, tested code example for basic vibration detection:

// SW-420 Vibration Sensor Arduino Code

const int sensorPin = 2;    // Digital input from sensor

const int ledPin = 13;      // Built-in LED for indication

const int buzzerPin = 3;    // Optional buzzer

void setup() {

  Serial.begin(9600);

  pinMode(sensorPin, INPUT);

  pinMode(ledPin, OUTPUT);

  pinMode(buzzerPin, OUTPUT);

}

void loop() {

  int vibrationState = digitalRead(sensorPin);

  if (vibrationState == HIGH) {

    digitalWrite(ledPin, HIGH);

    digitalWrite(buzzerPin, HIGH);

    Serial.println(“Vibration Detected!”);

    delay(100);

  } else {

    digitalWrite(ledPin, LOW);

    digitalWrite(buzzerPin, LOW);

    Serial.println(“No vibration”);

  }

  delay(50);

}

Code Explanation

The code continuously monitors the digital output from the SW-420 sensor. When vibration triggers a HIGH signal, the Arduino activates both the LED and buzzer while printing a detection message to the serial monitor. The small delays prevent serial monitor flooding and provide debouncing for cleaner readings.

Vibration Sensor Arduino Project Applications

The versatility of the vibration sensor Arduino combination makes it suitable for numerous practical applications.

Security and Alarm Systems

Mount the sensor on doors, windows, safes, or valuable equipment. Any tampering attempt triggers an immediate alert. I’ve built anti-theft systems for bicycles and toolboxes using this exact setup.

Machine Condition Monitoring

Attach the sensor to industrial equipment, motors, or HVAC systems. Abnormal vibration patterns often indicate bearing wear, imbalance, or impending failure. Early detection prevents costly breakdowns.

Earthquake and Seismic Detection

While not laboratory-grade, the SW-420 can detect significant seismic activity for basic early warning systems or educational projects demonstrating earthquake concepts.

Vehicle and Transportation Monitoring

Install on shipping containers or fragile cargo to log shock events during transport. This helps identify handling problems and supports damage claims.

Door Knock Detection

Create smart doorbells that distinguish knocking patterns or trigger notifications when someone approaches your door.

Useful Resources for Vibration Sensor Arduino Projects

ResourceURLDescription
Arduino Officialarduino.ccIDE download and documentation
Circuit Digestcircuitdigest.comDetailed sensor tutorials
SunFounder Wikidocs.sunfounder.comSensor kit documentation
GitHub Arduino Librariesgithub.com/arduino-librariesOfficial Arduino libraries
How2Electronicshow2electronics.comProject tutorials and guides

Troubleshooting Common Issues

Sensor Always Shows HIGH or LOW

Check your wiring connections first. Verify that VCC connects to 5V (not 3.3V if using Arduino Uno) and GND connects properly. If wiring is correct, adjust the potentiometer through its full range while tapping the sensor.

False Triggers Without Vibration

Reduce sensitivity by turning the potentiometer counter-clockwise. Also check for electrical noise from nearby motors or switching power supplies. Adding a small capacitor (100nF) across VCC and GND can help filter noise.

Inconsistent Detection

Ensure the sensor is firmly mounted. Loose mounting dampens vibration transmission. The sensor works best when rigidly attached to the surface being monitored.

FAQs About Vibration Sensor Arduino Projects

What is the difference between SW-420 and an accelerometer?

The SW-420 provides simple binary detection (vibration present or absent) at very low cost, typically under $2. Accelerometers like the MPU-6050 measure actual acceleration values across multiple axes with precise readings, but cost $5-$20 or more. Choose SW-420 for basic detection tasks and accelerometers when you need quantitative motion data.

Can the SW-420 measure vibration intensity or frequency?

No, the SW-420 only indicates whether vibration exceeds your set threshold. It cannot measure how strong the vibration is or its frequency characteristics. For intensity measurement, you need an analog vibration sensor or accelerometer.

How do I increase the detection range of the SW-420?

The SW-420 detects vibrations transmitted through the surface it’s mounted on. For greater range, mount it on a larger rigid surface that conducts vibrations well, such as metal plates or wooden boards. The sensor itself doesn’t have adjustable range beyond sensitivity.

Can I use multiple SW-420 sensors with one Arduino?

Yes, you can connect multiple sensors to different digital pins on your Arduino. Each sensor operates independently, allowing you to monitor multiple locations or create directional detection by comparing which sensors trigger first.

Is the SW-420 suitable for outdoor use?

The standard module isn’t weatherproof. For outdoor applications, enclose the module in a waterproof housing while ensuring the sensor element can still detect vibrations from the mounting surface. Conformal coating on the PCB provides additional protection against humidity.

Conclusion

The SW-420 vibration sensor Arduino combination delivers reliable vibration detection at minimal cost. While it won’t replace precision accelerometers for demanding applications, it handles basic detection tasks perfectly for security systems, machine monitoring, and countless DIY projects.

Start with the basic circuit and code provided here, calibrate the sensitivity for your specific use case, and expand from there. The simplicity of this sensor makes it an excellent choice for beginners learning about Arduino interfacing while remaining useful enough for practical real-world applications.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Sales & After-Sales Service

Contact & Quotation

  • Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.

  • Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.

Drag & Drop Files, Choose Files to Upload You can upload up to 3 files.

Notes:
For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.