SW-420 Vibration Sensor Arduino Interface

Last Updated on March 16, 2024

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.

sw 420 vibration sensor

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

vibration sensor sw 420 arduino interface

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 reading


15 thoughts on “SW-420 Vibration Sensor Arduino Interface

  1. Hai
    I am using this sensor for my project and I really need to know what is the output value actually? What is the unit? What does this sensor measure?

    1. The Sensor does not measure anything in this tutorial. What serial monitor shown to us is the value of time in microseconds does the output of SW420 module becomes “HIGH”.

      1. Can you add codes on how to turn on buzzer based on how many vibration it detects (not how strong the vibration)

  2. According to arduino website it is the measurement of of time
    “Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds. Gives up and returns 0 if no pulse starts within a specified time out.

    The timing of this function has been determined empirically and will probably show errors in longer pulses. Works on pulses from 10 microseconds to 3 minutes in length.”

  3. i am looking at building a circuit for my a college module that would receive data from an accelerometer fitted to dc motor to provide vibration data

    it would then store the vibration data before transferring the data via Bluetooth to a laptop/tablet.

    This idea is based on the transfer of Health Usage Monitoring Ststem (HUMS) IN a Wildcat Helicopter. Instead of using a PCMCIA card the data would be transferred via Bluetooth

    I have a rough idea on what components would be required but have never done any coding before and am struggling massively with it

  4. Can someone please share the datasheet of this sensor or it would be even helpful if one can provide me with the circuit diagram of this sensor.

  5. Please help me…
    I am using SW420 sensor for my project and I really need to know what is the unit or numeric unit of the output of this tool?

    1. The SI unit of vibration or the vibration unit is Watts per meter square – but this sensor will give digital output.
      Single-roller type full induction trigger switch. When no vibration or tilt, the product is ON conduction state, and in the steady state, when a vibration or tilt, the switch will be rendered instantly disconnect the conductive resistance increases, generating a current pulse signal, thereby triggering circuit.

Leave a Reply

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