A piezoelectric sensor converts mechanical energy to electrical energy through the piezoelectric effect. When a mechanical force or vibration is applied to the sensor, it causes the material within the sensor to generate an electric charge. This electric charge is then collected and can be used as an electrical signal to measure or detect the mechanical force or vibration applied to the sensor.