Piezo disc giving unstable/unreliable readings, keeps rising

My project involves a "pad", which when hit by the user, will activate an LED.

I purchased these: https://www.amazon.co.uk/gp/product/B081JNCYGL/ref=ppx_yo_dt_b_asin_title_o01_s01?ie=UTF8&psc=1

Connected as follows:

  • to 5V on Arduino
  • to GND
  • S to Analog pin

However when I serial print the Analog reading from the piezo disc, it is not stable. The value is constantly rising and rising even when I'm not touching it. When I hit it, it spikes to 1023 then goes to 0, then after a second it starts climbing again.

I have it taped to the desk. When I take away the tape and let the disc "float", the rate at which the value increases is even faster.

I've tried connecting the module to 3.3V and it slowed down the increase but it's still happening. I've also tried disconnecting the + all together but the problem persists, albeit slower.

Have tried searching online and can't find anything surprisingly because this seems like a very basic problem

const int piezoPin = A15;

void setup() {
pinMode(piezoPin, INPUT);
Serial.begin(9600);
}

void loop() {

int value = analogRead(piezoPin);
Serial.println(value);
}

With NO schematic, the problem is hard to determine. But, do you have a high value resistor directly ACROSS the piezo to discharge the voltage being produced?

Have you tried different modules?

This should work without the module:

Put a 1:1 voltage divider from Vcc to Gnd to the analog input for a stable offset in the ADC mid range. Add the piezo from the analog pin to Gnd.

It is acting as a capacitor. Try loading (across the 2 leads) with a 10K thru 100K resistor (or higher, depends on piezo.)

How to Build a Piezo Knock Sensor Circuit (learningaboutelectronics.com)

The schematic in that page is rather poor.
It misses out a series resistor in the LED to limit the current, 220R to 510R will do.

Also you need a diode cathode to input and anode to ground to prevent negative voltages from the sensor damaging the Arduino.

When I made piezo disks (bare disks, cheap in bulk) into buttons my #1 concern was to burn a pin on piezo voltage.

You can wire a piezo to 2 opto-isolaters so press triggers one and release triggers the other and no pull-down on those wires. The pins are always reading, every time about 50k reads per second --- AVR digital pin drains 1 microamp per read.
Smack, the pin goes high and count the reads till it's low. A soft touch might read 30 and a full strike with a screwdriver handle read over 3000. The scale is ignored, the numbers are only roughly proportional, an about how hard indicator.

One thing I learned, diodes flatten piezo spikes. Leds and BJT's are diodes.

Did you notice this review?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.