Hello. I have a simple circuit to obtain value from a piezo vibration sensor. The foundation code is the "knock" code except is tweaked to print values. I have added a map segment to start the value when the sensor is at rest at "0" then go up to 100 when vibrating.
I had tested and it was working fine, however, when the project was set-up again, the values now are a bit erratic and mostly start from 15-20.
I read about the "Calibration" code and "Smoothing" code that takes an average from erratic sensors. Is a piezo considered to be an erratic sensor?
Is there a better was to get an accurate reading? Ultimately, I wanted to convert the analog values that I obtain into voltage via a mathematical formula. Any suggestions on the conversion?
Yes, the conversion part clicked. Thank you! I still have a bit of disconnect on the mapping aspect. So if I have mapped from 0-100 that is not correct to obtain real values that I can convert to a voltage read. Hmm...so if I map to the parameters of the Arduino... 0-5 and 0-1023...that would work? I'm still not understanding how to map yet.
logicdog2:
Hello. I have a simple circuit to obtain value from a piezo vibration sensor.
A bare piezo or some opamp circuit.
A piezo outputs an AC signal.
If you sample that, you will get random values.
Is the piezo ground referred, or connected to a mid-voltage.
Which "knock code" are you using.
Get a proper A/D reading before you think of mapping.
Leo..
Delta_G -thank you for your patience to post the floating point number formula. I think I saw it somewhere attached to a digital multimeter tutorial.
Leo, thank you for helping me yet again. Ok, the "knock" code is off the EXAMPLES/SENSORS/KNOCK category within the Arduino software. Sorry, I don't understand the question if the piezo is ground referred. I am a newby at Arduino, coding, and circuitry....but I have learned so much from the forum.
The sensor is connected to the breadboard with a 1 mohm resistor connected to A0 pin on the Arduino with a jumper between the GND pin and the breadboard. ( I use to call it a breadbox just a month ago...see? progress!)
The project was to see what voltage the piezo produces on a moving vehicle at different speeds. The sensor is flexible so the wind would have an effect on the sensor waggling ...and so would the vibrations of the road.
It was suppose to be a simple experiment and now I am unable to fix the code to get readings. The experiment was set-up at home and worked correctly, and once it got set-up on the vehicle, the readings started from 15-20 instead of 0. I need to know how to fix the code that when the sensor is at rest, the value is 0 again.