How to Wire a Piezo as an Impact Sensor

Beginner here, seeking advice on understanding the very different schematics I'm finding about wiring a piezo as a vibration sensor.

In the Arduino program, there's a 'Knock' program (Examples 06->Sensors) that instructs wiring the positive terminal of the piezo to A0 and the negative through a 1M Ohm resistor to ground, like in the Tutorial book. That's in series, yes?
Screen Shot 2021-09-02 at 11.59.49 AM

But other projects instruct wiring the resistor in between both leads of the piezo (in parallel, yes?), like at this site
http://www.learningaboutelectronics.com/Articles/Piezo-knock-sensor-circuit.php
Screen Shot 2021-09-02 at 12.19.54 PM

While others suggest adding diodes as well (and 470k Ohm resistor instead?):
https://hackaday.io/project/8478-star-wars-nerf-targets
Screen Shot 2021-09-02 at 12.22.21 PM

and
https://www.defproc.co.uk/analysis/sensing-nerf-darts/

I think I understand that last schematic, but I don't know how to gauge its value compared to the other designs, and I'm left with these questions:

  • Is it better here to use the 1M Ohm resistor in series (to ground) or parallel, and why?
  • What's the function of the diodes, and why use both Zener and Shottky?
  • Are the diodes an improvement here or unnecessary? All 3 or just 2?

In case it helps, here's the big picture: I'm aiming to make a target sensor that can tell when hit by a nerf dart, and using the approach discussed in this Forum thread:

https://forum.arduino.cc/t/impact-sensor-piezo-knocksensor-or-vibration-sensor-feasible/117100

All this is new to me, but I think I can work out the code if I have a sensible wiring plan. Does that last one look good? Something else?

The circuits will all work. Most people are happy with the results of using a ~1 Meg resistor in parallel with the piezo sensor.

It is conceivable that a very high impact could generate a large enough signal to damage the Arduino, and if you are worried about that, put a 10K resistor between the piezo/resistor and the input pin, to limit the current through the input protection diodes.

Great, thank you. I'm still curious about the differences: what's the result of wiring the resistor in series with the piezo, like in the Tutorial?

And if all these approaches will work, will I miss much by skipping the diodes? It's certainly easier to connect it with just the resistor.

Ah, I would not have expected that. In the other forum thread, which I linked above, they mention that the piezo input is capped at 1024, but it sounds like that's the max recorded value, and it has nothing to do with limiting the actual current created. Is that right?

An unloaded piezo can generate high voltages (100 V or more) on impact but at very low current. The actual current and voltage depends on the size of the piezo sensor and the impact.

The second circuit you posted is a parallel circuit, and is what most people use.

Arduino inputs are limited to about 5.5V and -0.5V by internal diodes, which can be destroyed by excessive current flow. Hence the suggestion for the additional series resistor (10K to 100K).

Capture

1 Like

I personally would choose the 2nd circuit (with the 470k ohms). The 470k could go to 1 meg if you are not getting a consistent signal. But you should add a 10k in series with the input to the Arduino.

Piezo sensors can generate very high voltages when not loaded (as jremington mentioned). Albeit at low currents. It also generates a AC voltage (more like ringing).

The first circuit relies on the "protection" diodes built into the processor. They are there to try and protect the processor but shouldn't be used unless you have a clear understanding of the current going through these diodes.
In addition, If there is an ESD discharge into the piezo or its wires, the processor will most likely fail.

In the 2nd circuit, the diode clips the reverse voltage. and the zener limits the voltage to 6 volts or so. 5.1 volt zeners so not clip the input to 5.1 volts, you have to look at the curves for a typical zener to understand.

Note: I tend to be conservative, partly because I hate things to fail.

1 Like

Incidentally, the first circuit (if series) provides no discharge path for the piezo (which is a capacitor) except through the input protection diodes.

It is not a good design.

1 Like

Zeners are useless for protecting MCU inputs.
Leo..

If sitting on the pin I would agree but if used to reduce the input spike to something the following resistor can limit the current of, they can be useful. I didn't think discussing TVS would be fruit full.

Nothing to do with zener or TVS.
Remember that max pin voltage is VCC + 0.3volt (and GND - 0.3volt).
Not just "5volt".
So what use do 5volt zeners have when the Arduino is off...

Clamping diodes (Schottky) are far more useful to protect a pin than zeners.
Leo..

Hence the suggestion of another 10k in series with the input pin. I'm guessing 600µA into the off pin of an arduino will not damage anything.

For this application where the input energy is limited (and this one is) I agree schottky's will work, as long as the current in isn't enough to lift the supply.

But again there are many ways to skin a cat (fish).

This is a lot of good info. Thank you.

Ah, you've explained the criticism of that diagram in my first forum thread (resolving a library conflict between a servo and speaker).

One of the hardest parts of getting started with Arduino, for me, has been finding good models for a given project. That diagram comes from the Tutorial Book enclosed in the Arduino Starter Kit. And apparently, there are similar problems with the Alarm Clock tutorial from Elegoo. (I'm aiming to make an alarm that can be silenced with a nerf gun, combining a simple clock with input from a piezo.)

As I learn more, it'll be easier to sort out good instructions from poor ones, and even to make use of the good parts of flawed code and plans. But when you're starting out, it's sure tricky to fix the plans you're using as a guide.

I'll do that. Thanks. I wonder why none of the cited diagrams include it?

I have a 100K and a 1M - will either do for that purpose? And to improve my understanding: if I run them in series, do 4 x 100K Ohm resistors provide 400K resistance?

And can you confirm placement of that additional resistor? I'm new to reading schematics, and what I see here is ground on the right, and if diodes point against the flow of current, current must flow from the top left (#1), so that means I'd add a resistor in series above the words "Analog Input." Is that right?

Screen Shot 2021-09-02 at 12.22.21 PM

I have 5.1v Zener diode and several kinds of fast-recovery or Schottky diodes. Which are well-suited for that second diode (above the Zener in this schematic)?

As has already been pointed out, Zener diodes are not good for protecting inputs, particularly the 5.1V value chosen. Whoever designed that circuit does not understand them well.

This may help:

Capture

The 1Meg (or 10Meg) resistor could make your circuit more sensitive,
and even more sensitive (if needed) if you switch to 1.1volt Aref.

Forget about the zener, and use a second Schottky diode between pin and VCC (5volt) of the Arduino. Google "clamping diodes" (go to images) for the howto.
Leo..

If the supply could be lifted, then you still would use Schottky clamping diodes.
But you would add a TVS diode across the supply.

This is all getting theoretical.
Personally, I wouldn't bother with any diode or 10k resistor for a vibration sensor (with a 1" piezo).
The sensor on a drum kit, maybe.
Leo..

I gathered that, but what I thought - apparently incorrectly - was that they were in the circuit for another purpose. They're in the two schematics that seemed to be the most useful here, but they actually shouldn't be included?

Please know that I'm reading everything posted here, and researching as best I can afterward, but when I read something like this,

it isn't clear to my experienced eye that the zeners are a poor choice for the circuit. What I get is that "Zeners have a specialized use that you'll need to read more about later," especially since the two most thorough schematics I've found both use them.

Thanks also for the chart showing the relationship between current and voltage in a zener. It's a lot like the one I found here:

https://www.electrical4u.com/characteristics-of-zener-diode/

Screen Shot 2021-09-02 at 10.15.40 PM

What I gathered from that article is that zeners are a kind of more resilient diode, useful in a range of circumstances, including in a clamping circuit. That's not right?

I had been leaning toward that.

Or this, which makes sense. Thanks for offering it.
Capture

But now I'm trying to apply this suggestion:

I did read up on clamping diodes, but it's hard for a beginner to extrapolate from the general diagrams to a specific case. Of the various schematics I reviewed, this seemed to be closest to what we're discussing:
Rx33R
But I'm still struggling to apply it. 'Input' is my A0 pin, and ADC is the piezo? Hmm... my power is 5v, but in the first diagram (see Post #1), power comes from the 5v pin, so the A0 is used for signal? But no one here likes that setup. And I'm still lost about connecting schottkys connecting in my circuit. Could you please explain what they're linking and suggest which kind to use?

Oh, man.

No, other way round.
ADC = Analogue to Digital Converter (the analogue input of the Arduino).

Ignore the 470 ohm resistor in that diagram.
"zener or schottky" is wrong... The text should only say "schottky".

The diode to ground is already shown in the circuits you posted (D2).
That diode clamps signals lower than ground.
The diode to VCC (5volt pin on a 5volt processor) clamps signals higher than VCC.
Any small Schottky diode will do. The 1N5819 is common.

What sort of vibration do you want to measure.
Leo..

1 Like

Very good advice, the zener has no protective effect if the Arduino is powered down, the schottkys do.

For the piezo circuit I bias the thing at midrail with a divider (100k resistors are good enough for most purposes and also limit the current to what the build-in protection diodes can handle). Then add a resistor in parallel with the piezo itself to provide DC stability and define the sensitivity.

That's very helpful, Leo. Thanks for the explanation and for mentioning the 1N5819. I have one, and I see it's listed as 1A 40V. 40V sounds like a lot here, but what we're really limiting is the current?

I'm learning, but I'm still a little lost relating that schematic to my Arduino setup. For "clamping diodes," it looks like I need one schottky going to ground, and the other protecting the Arduino power against a spike if the piezo receives a big impact.

But do I need to connect to the VCC here? Since the piezo is being used as a sensor rather than a buzzer, it must need power only for its signal. It could get that from the VCC, like in the first diagram, which apparently isn't well designed, but not in the second, which goes just to A0 and GND.

This helpful schematic from jremington also made me think I would wire to A0 but not VCC. Is that so? Maybe I should have started with this and tried adding schottkys to it to see if I had it right. But if the signal wire is the same as power, then how do I place the (non-ground) shottky as a clamping diode?
Capture

Thanks, that's helpful, and now I understand Leo's comment in post #9. I won't use the piezo 'target' with the Arduino powered down, but I'd still like to build this with good practices. Are the zeners in those other plans because they'd always be used with power on? But 5.1v isn't a good choice?

I'm aiming for an Alarm Clock that can be turned off by hitting a target with a Nerf dart. For the Alarm Clock, I'm following this model
https://maker.pro/arduino/projects/arduino-alarm-clock-using-real-time-clock-lcd-screen/
and for the Nerf target, I found lots of inspiration but not a great model to follow, so I'm adapting the Knock sketch from the Arduino program (Examples->Sensors->Knock).

This is my second Arduino project. With helpful input from this forum, I finished my first, a Simon Says Lockbox,
dangerous art box2

and I figured the Alarm Clock Target was a reasonable next goal. What I thought was a project in combining two projects has turned into solving the problems of the underlying models - definitely a learning experience, but more challenging than I expected.

Thus (with additional diodes):
Piezo

1 Like

Don't forget that Schottky diodes have considerable temp dependent leakage.
I measure about 1Megohm at room temp for a 1N5819.

And a 1" piezo could produce a positive spike or a negative spike on impact, depending how the ceramic disk was dropped and glued onto the brass base.
Fortunately it will be ringing a bit.

I would go with that, but to be clear,
brass disk connected to a 100k:100k divider, 1Meg across the piezo, piezo+ directly to the pin.
No diodes, because the 50k impedance seen by piezo ground reduces fault current to a safe value.
That also eliminates any DC on the piezo.

Use code that detects peak/peak value (auto bias removal).
Leo..