Measuring energy from piezo sensor

This is for a middle school sciece fair. With a Arduino Leonardo, where can I find an example of code that tells the Arduino to sample the voltage/current every 1 second and display the data on a laptop. I do not need the data to be displayed in a spreadsheet, just displayed so I can record the numbers manually that I observe.

In the circuit do I have to have a 1 megohm resistor to limit voltage to protect the board? Wouldn't that defeat the purpose of reading the actual voltage that the sheet can make?

Thank you for your help.

logicdog2:
In the circuit do I have to have a 1 megohm resistor to limit voltage to protect the board? Wouldn't that defeat the purpose of reading the actual voltage that the sheet can make?

The voltage that a piezo disc sensor can generate could be tens or even hundreds of volts.
Fortunately they can't produce enough current to damage the Arduino pin.
The moment the voltage gets over 5.5volt or below 0.5volt, pin protection diodes dump the voltage to supply or ground.
A piezo is basically a capacitor. Any voltage on the cap stays there.
A 1megohm bleed resistor makes sure the pin stays at ground potential.
The resistor also damps the spikes, so a small tap doesn't produce the max A/D value of 1023.
Enter "knock sensor" in the search box on top of this page.
Leo..

Thank you Whandall. So apparently I need the Potentiometer to enable the Arduino to print the data. Curious... what would happen without the Potentiometer? What kind of reading would you get?

Also, your link states that a "steady stream of data" could be seen. Would this refresh so fast that I woun't be able to id the numbers? Do you know of a code example to tell the Arduino to sample data every second to slow down the stream?

Thank you

The voltage on the piezo will leak away very fast, so you have to read the analogue pin many times per second.
Print to serial monitor only if the value crosses a threshold.
Leo..

Wawa:
The moment the voltage gets over 5.5volt or below 0.5volt, pin protection diodes dump the voltage to supply or ground.

Leo, I just reviewed the "knock" topics. This question is because I am a beginner at circuits : Will adding a megohm resistor "tone-down" the voltage? Will the board's built-in protection dump the voltage before I can get accurate read? I need a set-up that reads true voltage generated.

Thanks

Thank you Whandall. So apparently I need the Potentiometer to enable the Arduino to print the data. Curious... what would happen without the Potentiometer? What kind of reading would you get?

You don't need a pot. The pot is used in the example to give you an adjustable voltage to read.

The Piezo goes in the circuit in place of the pot (with a connection to ground and analog-in only).

In the circuit do I have to have a 1 megohm resistor to limit voltage to protect the board? Wouldn't that defeat the purpose of reading the actual voltage that the sheet can make?

The resistor will reduce the signal level proportionally so you can still get a variable analog voltage.

The voltage you get from the Piezo depends on the particular piezo, the load resistance, the amount of vibration (or sound), and the frequency of the sound/vibration. These are all unknowns except the resistor, so you may have to experiment with different resistor values (or use a high-resistance pot in parallel with the Piezo).

Even if the signal is not too strong, you do need a resistor to "pull-down" the analog input to ground reference and to make sure the analog input is zero when there's no signal from the Piezo.

To read voltages that are higher than Arduino's supply, you need to add a voltage divider.

With a 10megohm resistor from piezo to analogue pin, and 1megohm from analogue pin to ground, you can measure upto 55 volt. That will "load" the piezo 11x less.
Problem is that the Arduino is not accurate/fast with these high value resistors.
The datasheet recommends <=10kohm.

Mains hum will also become a problem with these high values.

Another problem is the pulse direction.
Arduino can only detect positive pulses.
Your piezo might output positive or negative pulses when tapped.
This depends how the ceramic part was glued onto the copper disc in the factory. So a 50/50 chance.
There will always be a secondary return pulse, but with a lower voltage.

If you have access to a scope, connect the piezo to it, and all will be revealed.
Leo..

Learned a lot. Thank you. Best way to start is to order supplies and attack this project one problem at a time. Too bad no one makes a kit for this.

No kit needed.
All you need is a piezo buzzer. The 1" flat type.
With a red and black wire coming out.
Google "piezo buzzer" images.

Not the tall type with a + and a - printed on the side.
They are mechanical buzzers.

You can crack it open to remove the disc.

Add a few resistors and a breadboard.
Leo..

Do someone have an idea how can i avoid misleading readings of the negative peaks from the piezo buzzer?
Since the analog read read only positive I get zero for a negative peak which I also need to detect ..
can someone help please?

The idea of a 10meg/1meg pot divider is ok - but to make it more workable I'd use a 10meg/100k divider driving a JFET
(eg E111) gate as a voltage follower with a 10k source load. There will be a dc offset, but you can deal with that in software... and it allows you to observe negative as well as positive excursions.....

adjust the 100k for best use of the 5v dynamic range.

regards

Allan

Should have enclosed this

sorry

regards

Allan

piezo.pdf (17.8 KB)