Analog voltage spike protection using a Piezo Pickup

I’m trying to setup a D1 mini to detect a machine when it is on. I’m using a basic Piezo disk with a rectifier circuit (4-1N4007 diodes) and a 0.22uF 50v capacitor. When the machine is ON, I’m getting a satisfactory Vout fluctuating from 0.03v to 0.06v. With the machine OFF, the voltage drops >=0.02v with the 1M resistor discharging the capacitor. This is great and suits my needs.

The problem comes into play when the door of the machine closes. I get a momentary spike upwards of 3 to 6 volts depending on how hard the door is closed. This obviously isn’t good for the D1 mini. Since the ON voltage is so low, how can I correct for this spike problem?! I’m not an electronics expert by any means.
MachineVibrationPickup|611x483

The recorded voltages while machine is running is below. The door was not opened or closed during the trial due to the spikes.

This will limit spikes to 0.6V, any diodes can be used.
Rf9af682a2edfff248923240bf6e3d500

The circuit can be simplified.
OIP.jLVKv79LvLENgriiTWet4wHaGN
plus 2 diodes A0 to ground.
Audio sig = your piezo
Arduino = D1

Firstly you only need a 10k series resistor on the analog pin to protect it.

Thanks for posting that link to the circuit - its shown that you are using a bridge
rectifier to convert ac to dc - however that isn’t going to work well as diodes drop
0.7V each or so so you’ll not see much on the output until the input is 1.4V peak-to-peak
or more.

A precision rectifier circuit using an opamp is needed for accurate results.

However perhaps you don’t need rectification at all - perhaps you just need to shift the
level to mid-rail (2.5V), and do all the processing in software.

Bias one terminal of the piezo to 2.5V using a 10k:10k resistive divider,
feed the other to the analog pin (with 10k series to protect it), and you’ll see
a full signal centred about mid-rail voltage.

However piezo’s are capacitive, so normally a high value resistor such as 1M to
10M across the piezo would be used to keep its DC zero, and for setting the
voltage gain (piezos work as current-sources, so the resistor converts this to
voltage in a controlled manner).

Having the full AC signal digitized would, for instance, allow peak voltage to be
calculated, or rms voltage, or an FFT applied to get its spectrum.

That seems to be a quiet and smooth running machine. The piezo element is giving you very little indication that it is running. So, i’m thinking there must be better way to do this. Is there a pilot light, light bulb or LED that glows when running so you can use a photo detector instead? Or maybe use a Hall effect sensor near a motor or solenoid?

diode rectifier start rectifying signals above 0.6V, so in your case they are doing nothing.
Your signal is so weak, bring piezo closer to noise source, my piezo is producing 200 mV when I attach it to battery drill

I wish there was an external indicator light. I would have preferred a photocell detector. I was going to use a hall sensor but I think my wife would freak out when she saw the power feed to her dryer cut with the hall sensor hanging off one of the leads. :wink:

OP is using a WeMos D1 mini.
A 3.3volt processor with 0-1volt A/D and a 220k:100k voltage divider attached to it.
IMHO no big worries about damaging the pin.
Could use a (Schottky) diode between A0 and 3.3volt to be on the safe side.

The 1Meg resistor does virtually nothing, because of the 320k resistor already present on the pin.
Leo…

Which would indicate you are getting a lot more before the bridge rectifier. I’d suggest you feed the piezo to a simple amplifier as shown in my tutorial here
https://forum.arduino.cc/t/using-operational-amplifiers-in-your-arduino-project/692648/11

A direct connection to the pin (no other parts) should be ok too.
Just read frequently to find the random peaks.
Software could filter that to detect vibration or not.
Leo…