Piezoelectric Sensor

Z2M Part: EMS-00022-A / EDT-00003-A

Detect vibration or knock using piezoelectric sensor.

Circuit Diagram
Circuit diagram for Piezoelectric Sensor
Wire Connections & Pin Configuration

Wire Color Connections:

Yellow → Analog Pin A0 to Piezo positive (code uses A0)
Black → GND to Piezo negative

Pin Configuration:

Arduino Digital Pin 2 → Piezoelectric sensor positive
Arduino GND → Piezoelectric sensor negative
Arduino Code
Edit
int piezo_out = A0;   // Piezo sensor connected to analog pin A0
int led_out = 13;     // LED connected to pin 13
int threshold = 100;  // Threshold for vibration detection

void setup() {
  pinMode(led_out, OUTPUT);  // Set LED as output
  Serial.begin(9600);        // Initialize Serial Monitor
}

void loop() {
  int value = analogRead(piezo_out);  // Read analog value from piezo sensor
  Serial.println(value);              // Print sensor value to Serial Monitor

  if (value >= threshold) {           // If vibration exceeds threshold
    digitalWrite(led_out, HIGH);      // Turn ON LED
  } else {
    digitalWrite(led_out, LOW);       // Turn OFF LED
  }

  delay(100); // Short delay for stability
}

Instruction Details

Wiring: Connect piezoelectric sensor positive to Analog Pin A0, negative to GND.
Library: Not required (built-in).
Upload Code: Tools → Board → Arduino Uno. Tools → Port → select your COM port. Click Upload button.
View Output: Onboard LED (Pin 13) turns ON when vibration exceeds threshold. Open Serial Monitor at 9600 baud to see analog values. Tap sensor to test.

How to Use

  1. Connect the required components as per the Pin Configuration above
  2. Open Arduino IDE and create a new sketch
  3. Copy and paste the code above
  4. Select your Arduino board and COM port from Tools menu
  5. Click the Upload button to upload the code to your Arduino
  6. Open Serial Monitor (if applicable) to see the output

Components Required

  • Arduino Uno
  • Piezoelectric Sensor Module
  • Breadboard
  • Jumper Wires

Category: Sensors