Using an mbed and piezo disc to determine frequency

audiombedpiezosampling

I am attempting to determine the frequency of an instrument from its vibration using a piezo disc and an mbed LCP1768.

I attempted this with a raspberry pi but couldn't get the sample frequency high enough to get accurate readings.
I've now moved onto using an mbed which gives much higher conversion rates using less parts.

The piezo is stuck to my guitar using blue-tac and I play an E note (82Hz).

The schematic shows the set up I have. The code that runs just reads the input every millisecond and writes the values to a text file.
Then I get the text file and put the values into excel and generate a graph.

schematic

simulate this circuit – Schematic created using CircuitLab

I would expect to see a very flat line where the DC offset is, before the guitar is played then a wave like format for the rest centered around the offset but I get a fluctuating offset to start with with values ranging from 1.52 and 1.48, which then jumps up to 1.65 between the first 163-358 samples and then back down again.
enter image description here
Can anyone explain how I can reduce the noise of the DC offset to get a more accurate signal?

Thank you.

Best Answer

You could try something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

The two resistors give you the offset at about half the supply voltage. The capacitor gives a low pass filter at about 1/3 Hz. R4 helps prevent damage to the op-amp from shocking the piezo. R3 provides a DC path for U1 bias current. U1 should be a low bias current type that will work on the provided single low supply voltage, it cannot be a TL081.