Vibrations can be an indicator that trouble is coming. It can be your machine going haywire, a gear on a robot missing teeth, or worse, a looming earthquake! In this vibration sensor tutorial, we will look at how to detect vibrations using specially designed sensors and an Arduino microcontroller.
There are two widely available vibration sensors in the market: SW-420 and 801S. I will discuss both of them here. Jump to SW-420 to skip my 801S discussion that follows.
801S Vibration Sensor
The 801S shock and vibration sensor, by itself, changes its resistance when subjected to vibrations. The resistance changes are so extreme that the 801S is like a switch. The datasheet claims that this gold plated device can withstand 60 million shocks. As with most resistance-varying devices, the 801S is connected in a voltage divider circuit to get a voltage output.
You can purchase standalone 801S sensors but I would recommend acquiring the breakout board shown:
This board contains an LM393 op-amp IC (as a comparator) and a trimmer to adjust the sensitivity. The three pins are DOUT, + and -. The board accepts 5V power source and should be connected to the + and – pins. The DOUT pin produces a TTL signal that corresponds to the vibration on the 801S.
Sadly, the datasheet of the 801S doesn’t contain enough information especially on the sensor’s transfer function. The transfer function could have helped us determine how much force is needed for the sensor to trigger. Furthermore, this could have lead us to display the amount of vibration on the serial monitor or LCD.
What we can do is create an Arduino sketch based on whatever value the board is spewing when vibration is applied. We can then use this value as a limiting factor and then create a task whenever this factor is reached.
For example, my 801S board gives pulses every time I shake it. It’s hard to determine if the intensity of the shaking has any effect. What I know is that the board is giving a signal for every shake.
Here’s my wiring diagram followed by the sketch:
int 801S = 3; void setup(){ Serial.begin(9600); } void loop(){ Int value = pulseIn (801S, HIGH); delay(50); Serial.println(value); if (value > 1000){ Serial.println(“The Titans are coming!”); } else{ digitalWrite(“Tranquility is here”); } }
Here, the serial monitor displays “The Titans are coming!” when I shake the board. Otherwise, “Tranquility is here” is displayed.
SW-420 Vibration Sensor
The SW-420 is another vibration switch that opens when vibration is detected and closes when there is no vibration. You may also buy standalone SW-420 devices but you’ll save time if you purchase this breakout board instead:
The breakout board contains an LM393 op-amp IC but it is used as a comparator and not an amplifier. Basically, the D0 pin goes high when there is vibration and goes low when there isn’t. You can adjust the sensitivity of the sensor by turning the trimmer on the board.
The board comes with two LEDs: one for power indication and one tied directly to D0. When the D0 pin is high, the D0 LED turns off and vice versa. Yeah, it’s the opposite of what we would like the LED to do.
My SW-420 breakout board gives a high pulse every time I give it a shake. I could use the pulse width to indicate that there is vibration going on. Here’s my wiring diagram and Arduino sketch:
int SW420 = 3; void setup(){ pinMode(SW420, INPUT); Serial.begin(9600); } void loop(){ delay(10); long pulseWidth = pulseIn (SW420, HIGH);; delay(50); Serial.println(measurement); if (pulseWidth > 1000){ Serial.println(“The Titans are coming!”); } else{ digitalWrite(“Tranquility is here”); } }
I wrote the same messages when vibrations are detected similar to the 801S sketch.
DFRobot’s Vibration Sensor
DFRobot also has their own vibration sensor which is similar to the SW420 type:
I believe the advantage of this vibration sensor from DFRobot is the on-board connector and the convenience of the mounting holes.
801S vs. SW420
Assuming you don’t have any of these two yet, which vibration sensor should you get? The answer would depend on the intended project. But first, I would not recommend these sensors for detecting ground movement. There’s another sensor for that.
Speaking from experience, I find that the 801S is more sensitive to small movements compared to the SW420. But ultimately both can be used only as a vibration switch as there is no way you can measure the amount of vibration with any of these two devices.
I need to trigger output at vibration value if it is more than normal value.How to do programme please guide.( With 801 S vibration sensor.
As far as I know, the vibration sensor only produces two types of output: one when there is vibration and another when there is no vibration. I suggest you use another sensor that provides analog value that corresponds to vibration strength.
Hello, I am looking at acquiring Vibration data from a Equipment. I am a newbie for electronics, I would like to know which sensor would help me acquire vibration data in a regular interval.