Vibration Sensor Module SW420


The Vibration module based on the vibration sensor SW-420 and Comparator LM393 to detect if there is any vibration that beyond the threshold. The threshold can be adjusted by the on-board potentiometer. When this no vibration, this module output logic LOW the signal indicate LED light,And vice versa.



Usually at any angle switch is ON state, by the vibration or movement, the rollers of the conduction current in the switch will produce a movement or vibration, causing the current through the disconnect or the rise of the resistance and trigger circuit. The characteristics of this switch is usually general in the conduction state briefly disconnected resistant to vibration, so it's high sensitivity settings by IC, customers according to their sensitivity requirements for adjustments.


Application Ideas

  1. Vibration detecting
  2. Burglary protection system
  3. Object Movement detecting
  4. Triggering effect reported theft alarm
  5. Smart car
  6. Earthquake alarm
  7. Motorcycle alarm


  1. The default state of the swith is close
  2. Digital output Supply voltage:3.3V-5V
  3. On-board indicator LED to show the results
  4. On-board LM393 chip
  5. SW-420 based sensor, normally closed type vibration sensor
  6. Dimension of the board: 3.2cm x 1.4cm

Board Schematic



  1. The module does not vibrate, vibrate switch is closed conduction state, the output output low, the green indicator light comes ON.
  2. Vibration state, vibration switch instantly disconnect the output output high, the green light is not on;
  3. The output is directly connected to the microcontroller to detect high and low, thereby detecting the vibration environment, play an alarm role

SW-420 Vibration Sensor Arduino Interface

Many Applications can created by measuring Vibration level, but sensing vibration accurately is a difficult job. This article describes about vibration sensor SW-420 and Arduino interface then it may help you to design effort less vibration measurement.
The vibration sensor SW-420 Comes with breakout board that includes comparator LM 393 and Adjustable on board potentiometer for sensitivity threshold selection, and signal indication LED.
This sensor module produce logic states depends on vibration and external force applied on it. When there is no vibration this module gives logic LOW output. When it feels vibration then output of this module goes to logic HIGH. The working bias of this circuit is between 3.3V to 5V DC.

Arduino Hookup with SW-420

Connect Vcc pin of sensor board to 5V pin of Arduino board, connect Gnd pin to Gnd pin of Arduino, Connect DO output signal pin of sensor board to Arduino digital pin D3. Do some calibration and adjust the sensitivity threshold, then upload the following sketch to Arduino board.

Arduino Code for Logic State Output from sensor module, here onboard LED of Arduino indicates the presence of vibration.

int vibr_pin=3;
int LED_Pin=13;
void setup() {

void loop() {
  int val;

Arduino Code for Value Reading and serial printing Vibration value, this code turns ON the onboard LED when measurement goes greater than 1000, you can adjust this threshold to your need.

int LED_Pin = 13;
int vibr_Pin =3;

void setup(){
  pinMode(LED_Pin, OUTPUT);
  pinMode(vibr_Pin, INPUT); //set vibr_Pin input for measurment
  Serial.begin(9600); //init serial 9600
 // Serial.println("----------------------Vibration demo------------------------");
void loop(){
  long measurement =TP_init();
 // Serial.print("measurment = ");
  if (measurement > 1000){
    digitalWrite(LED_Pin, HIGH);
    digitalWrite(LED_Pin, LOW); 

long TP_init(){
  long measurement=pulseIn (vibr_Pin, HIGH);  //wait for the pin to get HIGH and returns measurement
  return measurement;



Vibration Sensor SW-420 with Raspberry Pi

Basic tutorial of how to setup a SW-420 Vibration sensor with the Raspberry Pi.

Step 1: Parts

  1. RPI 3-
  2. 16GB Micro SD-
  3. jumper wire -
  4. Vibration Sensors
  5. 4 Amp Power Adapter

Step 2: SETUP

  1. Wire VCC to 5v, Ground to ground, and D0 to gpio 17
  2. Upload python script to Raspberry Pi



import RPi.GPIO as GPIO
import time

channel = 17
GPIO.setup(channel, GPIO.IN)

def callback(channel):
        if GPIO.input(channel):
                print "Movement Detected!"
                print "Movement Detected!"

GPIO.add_event_detect(channel, GPIO.BOTH, bouncetime=300)  # let us know when the pin goes HIGH or LOW
GPIO.add_event_callback(channel, callback)  # assign function to GPIO PIN, Run function on change

# infinite loop
while True:
Mrunali Bawankar

Mrunali Bawankar