Arduino Vibration Sensor SW-420 / Grove Module

Ad Code

Arduino Vibration Sensor SW-420 / Grove Module

Grove Module - Arduino Vibration Sensor Based on SW-420

The vibration sensor for Arduino or "Vibration Sensor (SW-420 v1.1)" is assembled on the basis of a spring-type vibration sensor SW-420 and a comparator LM393, this module is from the Grove System series. The Grove module was provided by Seeed Studio and can be purchased here:  Grove - Vibration Sensor (SW420) - Seeed Studio .

The principle of operation of the sensor is quite simple. At rest, the SW-420 sensor is in an open state and no current flows through it, but at the output (SIG) we have a logical unit (Vcc). Under external influence (push, impact, etc.), the spring swings and shortly closes the contacts, and at the output of the SIG pin we get a logical zero (GND). A potentiometer is installed on the board and it is possible to set the response threshold. The vibration sensor response does not depend on its location in space.

The LM393 comparator, which has two analog inputs and one digital output, compares the electrical signals received from the SW-420 and the potentiometer with each other and outputs a digital signal indicating an increase in one input signal over the other.

Arduino Vibration Sensor Based on SW-420 (Grove Module) - LM393 Comparator

Application options

The most relevant application of vibration sensors can be implemented in the field of burglar alarms for various purposes. Due to the high level of sensitivity, such devices can respond to vibrations of a wide range of intensities, capturing vibrations in all planes. Thanks to the simple connection method, vibration sensors are used to implement a wide variety of projects:

  • Security systems;
  • Alarms;
  • Electronic locks;
  • Motion detectors;
  • Anti-theft systems;
  • Seismic stations;
  • Kids toys;
  • Appliances;
  • Sports Equipment.

Module pinout

The vibration sensor module has four outputs:

3NCNot used
4SIGSignal output

Vibration Sensor SW-420 Specifications

  • Working voltage : 3.3 - 5 V;
  • Used sensor : SW-420;
  • Comparator used : LM393;
  • Sensitivity : adjustable;
  • Interface : digital;
  • Weight : 10g;
  • Dimensions : 40mm x 20mm x 7mm.

Grove module schematic diagram

Vibration sensor Arduino based on SW-420 (Grove Module) - schematic diagram

Implementation example

To work with the module, you do not need to install additional libraries. The circuit is assembled according to the figure (see below). Connect the SIG (or DO) digital pin to digital pin 2 of the Arduino. In the presence of vibrations, the signal value increases many times and when the threshold value is reached, which is set by the potentiometer, a logical zero is applied to the SIG (or DO) pin. The value is read by the function digitalRead()in a cycle loop(), after which, by calling the function digitalWrite(), the LED built into the board lights up if the read value is equal to zero.

Wiring diagram for vibration sensor to arduino

Wiring diagram of vibration sensor based on SW-420 to Arduino

ArduinoGrove - Vibration ModuleWire color
D2SIG / DOYellow

Example sketch

# define PIN_LED 13

/ *
Pin to which the vibration sensor is connected

* /

# define PIN_SENSOR 2

int alarm;

void setup () {
alarm =
0 ;
pinMode (PIN_LED, OUTPUT);


Serial.begin (
9600 );

void loop () {
/ *
Reading the value from the sensor

* /

int val = digitalRead (PIN_SENSOR);

if (val == LOW) {
/ *
Sensor triggered - turn on the LED

* /

digitalWrite (PIN_LED, HIGH);

Serial.print (alarm);

Serial.println (
"Alarm!" );
alarm ++;

else {
digitalWrite (PIN_LED, LOW);




Connecting a vibration sensor to arduino - Result

Close Menu