It is best to remove the defect with a capacitor rather than hide it with an averaging.What is your board ? Uno or Mega?Edit : the pin which is decoupled is Aref.
float trash=analogRead(0);float realone=analogRead(0);Serial.print(realone);
Could I put this between the output of the sensor and the analog input on the board?
take 2 readings, discard the first one
Can I put this capacitor somewhere in the circuit on the breadboard
//Set analog reference to 2.56 volts internal analogReference(INTERNAL2V56);
ADC Voltage ReferenceThe reference voltage for the ADC (VREF) indicates the conversion range for the ADC. Singleended channels that exceed VREF will result in codes close to 0x3FF. V REF can be selected aseither AVCC, internal 1.1V reference, or external AREF pin.AVCC is connected to the ADC through a passive switch. The internal 1.1V reference is gener-ated from the internal bandgap reference (VBG) through an internal amplifier. In either case, theexternal AREF pin is directly connected to the ADC, and the reference voltage can be mademore immune to noise by connecting a capacitor between the AREF pin and ground. VREF can also be measured at the AREF pin with a high impedance voltmeter. Note that VREF is a highimpedance source, and only a capacitive load should be connected in a system.If the user has a fixed voltage source connected to the AREF pin, the user may not use the otherreference voltage options in the application, as they will be shorted to the external voltage. If noexternal voltage is applied to the AREF pin, the user may switch between AVCC and 1.1V as ref-erence selection. The first ADC conversion result after switching reference voltage source maybe inaccurate, and the user is advised to discard this result.
take 2 readings, discard the first oneCode: [Select]float trash=analogRead(0);float realone=analogRead(0);Serial.print(realone);there is also something in the datasheet for the atmega328p on getting better precision from the adc. and... 10.4 Adc noise reduction mode, page 39.
QuoteCan I put this capacitor somewhere in the circuit on the breadboard No.Aref is connected dirrectly to the heart of the ADC. If Aref is noisy, measurement will be noisy.The decoupling of Aref in entrance of the board does not work because after the decoupling capacitor Aref track is too long and acts as an antenna. This is a design error of UNO board and probably MegaYou must bypass the interference signals with a soldered capacitor as close as possible to the microcontroller.
I think you should use the digital DS18B20 one wire sensors.