In this text, we will be exploring how to set up a Vibration Sensor With Raspberry Pi Tutorial. This is a simple project that can be used to detect any sort of vibration and movement. The vibration sensor we will be using is the SW-420 vibration sensor. This sensor will be able to detect any vibrations and movement within a certain range. We will be using the GPIO pins on the Raspberry Pi to connect the sensor.
Thank You, PCBWay:
This project is successfully completed because of the support and help from PCBWay. Guys if you have a PCB project, please see their website and get exciting bargains and coupons. PCBway is the best prototype PCB company offering great PCB boards at lower prices If you sign-up using this link you will get beginner and sign-up coupon rewards. https://www.pcbway.com/?from=diyp
- RPI 4
- Jumper cable
- Vibration Sensors:
What is a Vibration Sensor?
A vibration sensor is a device that measures and monitors vibrations. Vibrations are produced by mechanical and electrical equipment. Vibration sensors are used in a variety of industries, including manufacturing, automotive, aerospace, and mining. Vibration sensors can be Fixed or Portable and can be used to monitor vibrations in both machinery and buildings.
An SW-420 vibration sensor module is a small, self-contained device that is used to measure levels of acceleration, vibration, or both. and Comparator LM393 is used to sense vibrations. The SW-420 is designed to be mounted on a machine or structure, and it uses an accelerometer to measure vibrations. The module also has a built-in amplifier and filter, which helps to reduce noise and improve the accuracy of the measurements.
SW-420 vibration sensor pinout
The Vcc pin powers the module, typically with +5V
Power Supply Ground
Digital Out Pin for Digital Output.
Vibration Sensor Features & Specifications
- Operating Voltage: 3.3V to 5V DC
- Operating Current: 15mA
- Using SW-420 normally closed type vibration sensor
- LEDs indicating output and power
- LM393 based design
- Easy to use with Microcontrollers with normal Digital/Analog IC
- Small, cheap, and easily available
Applications of Vibration Sensor Module
- Shocks triggering
- Robbery alarm
- Smart car
- Earthquake alarm
- Bike alarm
What is Raspberry Pi?
Raspberry Pi is a credit card-sized computer that plugs into your TV and a keyboard. It is a capable little device that enables people of all ages to explore computing and to learn how to program in languages like Scratch and Python. Raspberry Pi has been used all over the world to help people learn to code, build websites, create art and even power robots and industrial control systems.
How to Use a Vibration Sensor With Raspberry Pi
Raspberry Pi with vibration sensor connection, The sensor has three pins that need to be connected to the following GPIO pins on the Raspberry Pi:
There are many different types of vibration sensors, but the most common type is the piezoelectric sensor. A piezoelectric sensor is a sensor that uses a piezoelectric material to detect vibrations. The piezoelectric material is a material that produces a voltage when it is vibrated. The piezoelectric sensor is connected to a circuit that amplifies the voltage and the signal is sent to the raspberry pi.
- Pin 1 (Data) to GPIO 17
- Pin 2 (Gnd) to GPIO 3 (Gnd)
- Pin 3 (Vcc) to GPIO 2 (5V power)
Programming Vibration Sensor With Raspberry Pi
Once the sensor is connected then you can now use the Python code below to read data from the sensor.
import RPi.GPIO as GPIO
channel = 17
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
vibration sensor with Raspberry Pi is a great way to monitor vibrations in your home or office. By using a simple circuit, you can easily measure vibrations in your environment.