Hi everyone, I am begginer using arduino, and I am trying to find out the output voltage that comes from an electromagnetic sensor. It is meant to work giving values between 0 and 2.5 depending on how the magnetic field changes. When measuring the output with the ARDUINO UNO board I commonly receive a lot of noise in the signal, sometimes a low frequency (around 4Hz) frequency how is shown in the image 1 and another times with this type of noise in the second image (plotted with matlab) that I cannot figure out where it comes from. I don't know if this is quite common sometimes or related with the sampling rate...
Do you have any idea of where this signal comes from? Any suggestions to stabilize the signal?
Circuit assembly and the code used is also attached. Thanks in advance!
With your code, the sample rate is unpredictable, because printing takes time, depending on the number of characters that are actually printed.
This line is not useful, and the comment is wrong. If you want a stable sample rate, you need to use millis() or micros() (see the Blink Without Delay tutorials).
delay(100); // delay in between reads for stability