Piezoelectric Sensor Interfacing with Arduino

Posted on

Piezoelectric Sensor Interfacing with ArduinoA Piezoelectric sensor is used to measure the changes in parameters like pressure, temperature, acceleration, and force, by converting them into the electrical charge. This sensor works on the principle of the piezoelectric effect.

Piezo Sensor

Interfacing of Piezoelectric sensor with Arduino

Interfacing piezoelectric sensor with Arduino board is simple and easy. Before we know the interfacing process let us know what is the piezoelectric effect?

The effect in which mechanical energy is converted to the electrical form with applied pressure is called the piezoelectric effect. When a pressure is applied to a polarized crystal, the mechanical deformation created results in an electric charge.

Piezoelectric Sensor
Piezoelectric Sensor

Conversely, when a voltage is applied across the piezoelectric crystal, then the pressure will be created on the atoms of crystal creating deformation.

Piezoelectric sensor Circuit

A piezoelectric sensor circuit is designed using a piezo sensor, capacitor, two NPN transistors four resistors and a speaker. When a piezo sensor is subjected to a pressure due to the sound in the vicinity, the sensor generates electrical signals. The output of the piezo sensor is supplied to the transistors T1 and T2, which are in Darlington combination. It has a very high current.

piezo electric sensor circuit

If the piezo sensor receives an audio signal, it produces the voltage difference in the opposite faces. The Signal is filtered using a capacitor C1 of 0.1µF. The transistor T1 of the Darlington pair amplifies the input signal and the output appears at the resistor R2. The output of the first transistor T1 is given to the base of the second transistor T2 after the signal is filtered by the capacitor4 C2.

Further, the output of the transistor T1 is amplified by the transistor T2 at resistor R4. The R3 resistor is used for necessary biasing of the T2 transistor. The output of the second transistor T2 is filtered using the capacitor C3 and the output is connected to speakers.

 

READ : What is The Difference Between RISC and CISC Architecture

 

Interfacing Piezo knock sensor with Arduino

A piezo knock sensor produces the voltage when it is subjected to any physical stress. This sensor is used to develop a circuit which responds to the knock and turns ON or OFF a load.

READ  What is The Difference Between RISC and CISC Architecture

For this circuit, we will connect the knock sensor and an LED to an Arduino microcontroller. When the sensor receives a knock, the Arduino board will turn ON the LED for programmed timed and then turns OFF.

A piezo sensor is a polarized component with positive and negative terminals. The red wire is the positive terminal and the black wire is the negative terminal. The positive terminal is connected to the analog pin A0 of the Arduino board while the negative terminal is grounded at the GND terminal of Arduino.

Interfacing Arduino with Piezoelectric sensor

Schematic Diagram

The above circuit is represented in the schematic circuit diagram.

Circuit diagram of Arduino and piezoelectric sensor

The positive lead of the sensor is connected to the pin A0 of the Arduino board and the negative terminal is grounded. A resistor of 1MΩ is connected between the two leads. The anode of the LED is connected to the pin 13 and cathode to GND of the Arduino board. Pin 13 has an inbuilt resistance of 220Ω. A program code is used to drive the load connected to the Arduino.

Code

The following code is used to turn the LED ON for 5 seconds when the piezo sensor detects the knock.

const int sensorPin=0;
const int ledPin= 13;
const int threshold= 100;

void setup()
{
pinMode(ledPin, OUTPUT);
}

void loop()
{
int val= analogRead(sensorPin);
if (val >= threshold)
{
digitalWrite(ledPin, HIGH);
delay(5000);
digitalWrite(ledPin, LOW);
}
else
digitalWrite(ledPin, LOW);
}

The first block of the code initializes all the values used in the program. Analog pin A0 of Arduino is initialized as sensor pin, to 0 and the digital pin 13 is initialized as led pin, to 13. The external environment around the sensor creates some vibration. A threshold of 100 is created to overcome the triggering of sensor for small vibrations. Hence the circuit gets triggered when it gets vibration which are above the threshold value. The second block is for LED to make it as an output pin.

In the third block, we declare an integer as ‘val’ which reads the value obtained from the piezo sensor. If the input value is above the threshold, then the LED turns ON and if the value is below the threshold, the LED is OFF. The delay of 5000µs will hold the LED ON and then turns OFF.

READ  How to Interface an LED With 8051 Microcontroller

Advantages

  • The piezoelectric material offers a very high response that parameters changing at high speed can be sensed easily.
  • They can detect the events of microseconds and also give linear outputs.
  • Piezoelectric transducers are small in size and have a rugged construction.
  • They offer high output that can be measured in electronic circuits.
  • They are self-generative and no use of an external source.

Disadvantages

  • The output obtained from piezoelectric transducers is low.
  • The piezoelectric crystals have a high impedance. Hence, they can be connected amplifier auxiliary circuits.
  • It is difficult to give the desired shape to the crystal with sufficient strength.
  • The output may vary depending on the change in temperature of the crystal.

Applications

  • The piezoelectric sensors are used to measure the fast-changing parameters.
  • They can be used to study high-speed phenomena like explosions and blast waves.
  • They are used in seismograph.
  • The piezoelectric sensors are used along with the strain gauges to measure force, stress, vibration, etc.
  • Automotive companies detect detonations in the engine blocks using piezoelectric sensors.
  • They are also used in medical treatment, sonochemistry and industrial processing equipment.

In this article, we have discussed How to interface piezoelectric sensor with Arduino board and its applications. I hope by reading this article you have gained some basic information on the piezoelectric sensor working.If you have any queries about this article or about the electrical projects for engineering students, please feel free to comment in the below section.

Source : https://www.elprocus.com/

Incoming search terms:

  • take input from piezoelectric sensor in arduino