As you can know, the signal is not always constant as shown in one of the photos. The signal is received by a pin A4 (Analog Pin) on Arduino Mega.
My goal here is to get rid of the unstable-messy signal wave and to smooth it out using a capacitor.
Does anyone have any ideas on how to wire a capacitor to smooth out the messy signal? And also, what type of capacitor should I use?
If someone could paste the diagram on how to wire a capacitor and also show an electrical calculation with a detailed explanation, that would be very helpful.
I assume that the picture is a screen shot from the serial plotter? As far as one can see the value is varying by +/-1 LSB and occasionally by an extra LSB. This isn't really significant and could easily be conversion errors in the ADC. You could try just connecting say a 1 microfarad capacitor from the analogue input pin to ground. The type isn't really significant, whatever you have to hand. It might make a difference. I don't think a diagram is needed and calculation is superfluous - just try it and see.
For future reference you can copy and paste jpg and png images straight into your post from your PC - generally we prefer not to have to click on links.
Just zeroing the LSB will not fix all of what @alexuas calls noise.
When the signal is near a point where a transition in the reported value, (analogRead() & 0x3fe, or whatever number of bits are ignored), that value will change back and forth. Without user action.
If you want stable readings, check this recent thread:
It looks like noise from a switching power supply of some type, I am assuming your PC. Check your Aref voltage, I suspect it also has the noise. A shielded wire would not hurt a thing.
Because you havent posted your code I can only guess what the numbers on the signal wave mean.
[quote="alexuas, post:1, topic:1066174"]
The signal is received by a pin A4 (Analog Pin) on Arduino Mega.
[/quote] but what are you using as your reference?
Its entirely normal to get adc readings that differ by +/- 1 or 2 LSB.
Even if the input voltage is exteremely precise and stable.
A capacitor wont help
You need to address this issue in software: Firstly by taking a set of readings and averaging them, as explained in this link; and secondly by ignoring any change that is less than a threshold value.