I am making a device that measures temperature and vibrations and records the values onto an SD card. It will be a standalone device.

The hardware used: - Arduino Uno - PCF8523 RTC clock - MAX3186 + PT100 RTD temperature sensor - Adafruit data logger shield - Typical bare piezo sensor

For the vibrations, a piezo sensor is used. Because it can produce a signal in two directions, I decided to use a voltage divider to offset the signal from GND. Two 5.1K resistors are connected from the piezo negative terminal to 5V and GND. A 1M resistor is placed in parallel with the piezo sensor. The positive terminal is connector to analog input 0.

Piezo circuit

The sensor is read 100 times per data point, the maximum and minimum values are stored and the final value is set to be the difference between the two (two times the amplitude).


9V wall adapter

When the system is powered via a laptop USB port, the resting value has a jitter of a few bits. When a 9V wall adapter powers the arduino, the jitter is +/- 30 bits. Any small vibrations disappear in the noise.

USB with piezo

USB with piezo

9V with piezo

9V with piezo

9V without piezo

9V without piezo

I would like some help to find the best way forward.

edit 29-10 17:53 Added better plots

edit 30-10 17:53 Added plots for 2.5V and 3.3V lines

  • Have you got an osci to check if the 5 V from Arduino Vcc is smooth or "rippled"? Did you use the AVRef Voltage reference? This should be stable. How long are your wires? Can you shorten them for the sensor and the resistors to make the antenna minimal? A schematic and a photo of you setup would be helpful. ;-) Oct 29, 2019 at 16:55
  • @PeterPaulKiefer Sorry I don't have a oscilloscoop to check. I'm using the default analogread, I haven't changed the reference settings. Wire to piezo is roughly 75 cm and shielded, shield is not connected to GND at the moment. Strange thing is that the whole set-up is exactly the same for both plots but when powering the arduino with 9V I get the huge jitter issue. I've added a schematic for the piezo. Oct 29, 2019 at 17:12

2 Answers 2


The 9V wall adapter is in most cases a switched power regulator with a high frequency. That's like a radio transmitter direct beside the wire. So there is nothing mystical, when the smooth USB Voltage does not show problems but the "radio transmitter" does.

There are two ways the power supply can impact: over radio wave or as ripples over the regulated Voltage of your Arduino.

I asked myself, which one it is (or even both)? If you use the extra regulated analog voltage reference (AREF) as the +5V on your Voltage divider, it would be more likely that the problem comes through the air. Then it would help if you activate the shield of the wire by connecting it to GND.

If a rippled supply voltage is the problem, you have to smooth it. Perhaps with a low pass filter (a big Elko between Vcc and GND).

Perhaps you have a solenoid iron core. Then you can wrap the wire to the piezo sensor a few times around it (near the A0 Pin). This technique is often used in computer power supplies to prevent the switching frequencies from escaping to the public power lines.

  • To be clear, I'm using the regular 5V Vcc for the voltage divider. Is there a better, regulated voltage I can use on the board? I was under the impression that the Aref pin can only be used to supply an external reference. Can I use that pin to get a regulated 5V as well or have I misunderstood? How about using the 3.3V? Oct 29, 2019 at 20:00
  • From my measurements, I know that the regular Vcc is poorly stabilized. If the power supply has ripples, often I found attenuated ripples in the Vcc also. The VREF is a special pin that be programmed to provide a reference voltage for the ADCs. see arduino.cc/reference/en/language/functions/analog-io/… . What I meant was connecting the VCC to VREF and set the analog reference to EXTERNAL. Than the voltage reference and the VCC have ripples. Because the digital value is obtained by comparing both voltages the error might be cleared. But it is just an idea. ;-) Oct 30, 2019 at 9:26
  • You can also build a external stabilized voltage add it to VREF and set the reference voltage to EXTERNAL. And you have to use this Voltage for your piezo reference. But it's only needed if the problem is caused by ripples on VCC. If the problem is cause by EMI you must try to filter the piezo voltage before it reaches the A0 input. I'm busy this morning, so I add just two comments. In the evening I'll edit my answer to order the information. My English is not very well, so I might be fairly unclear. ;-) Oct 30, 2019 at 9:35
  • Peter, not a problem, you have been very helpful so far! I now get what you mean with supplying Vref with Vcc. I did some tests on the voltages, I connected 5V to A1 and 3.3V to A2 and did the same measurements. I took 100 samples and show twice the amplitude (difference between min and max values). USB imgur.com/rmhgnRB 9V imgur.com/MQEMvc9. I think a potential solution might be to use the 3.3V from the datalogging shield as it looks to be very stable! Although strangely, the 5V plots don't show a huge difference between the two power sources... Oct 30, 2019 at 11:35
  • 1
    Here are some plots of the 2.5V line with and without piezo. USB with piezo: imgur.com/mIbWWd4. 9V with piezo: imgur.com/JoxX7BS. 9V without piezo: imgur.com/buD1Fc0. Strange... Oct 30, 2019 at 13:20

In addition to what Peter Paul Kiefer suggests, you will also want to place an RC low-pass filter, between the piezo transducer, and the analog input.

You mention that you'll be sampling this value 100 times per second. So the cutoff frequency, for the filter, should be set to 50 Hz (the Nyquist frequency).

  • 1
    I don't think the OP takes samles with 100 Hz. He only said that he takes 100 Samples to choose the maximum and minimum values from it. I believe he take it at the highest rate that's possible. I thought about low pass filters too, but as he used the piezo for shock detection I expect a part of the frequency spectrum (of the piezo pulses) in the same range as the EMI. So it's definitely worth a try, but I don't expect good results. Oct 31, 2019 at 8:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.