I am reading the voltage from a voltage divider network. Measuring the voltage at the analog input pin (A1) with a DMM, the voltage is a constant 3.49 volts. Voltage on the 5 volt pin is 4.92 volts and is constant also. However, when I print out an analog read of that pin, the value fluctuates wildly between 723 to 728. The voltages are measured directly at the pins of the Arduino and are rock-solid.
I swapped out the nano every, and still get the same results.
Ah yes, Electronics 101. I put a scope on the supply, and yes, quite noisy. The first thing I need to do is fix that. The supply rails should be solid.
"& Guessing" ... I guess R1/R2 value(s) are greater than 10K, which is beyond the maximum recommended ADC input impedance for the ATmega4809. In this case, adding a capacitor would help.
Anyways, I wouldn't expect miracles with the Nano Every's ADC, it lacks hardware noise filtering. The filtering on the ATmega4809 Curiosity Nano is quite good. It looks like this ...
You hit the nail on the head regarding the input impedance, as I observed that if I used a 10k pot on the input, there was virtually NO fluctuation on analogRead().
I am reading a 100k NTC thermistor, so I am locked in on the impedance of that network. I assume they use hi Z thermistors to reduce self-heating. I could use op-amp buffers to drop the impedance seen by the nano. As long as I stay away from the rails it should work fine.
Nonetheless it was good to look at it with a scope and clean up the noise. Some tidying up of wires (twisting a bundle together) and a few decoupling capacitors and things are already looking a lot better (+- 1 count fluctuation) even without buffering. I am extending an existing circuit board so the nano resides about 8 inches away, connected via a bundle of wires (which are now twisted together.) Just getting off the breadboard on to a circuit board will probably help as well.
The Every might not have other Aref voltages, which makes it in theory unsuitable for voltage measurements. And most of us have zero experience with these relative new boards.
But OP might be measuring a thermistor ratio , not a voltage, judging by his sketch (thermHot).
OP can try powering the Every externally (V-in), with a 9volt battery, and see if that solves the problem. Not much hope there, because the Every has a switching (buck) power supply for V-in, which can add more noise.
Leo..
@KevinJones, then you are not reading a voltage, but a "ratiometric" signal as Wawa wrote. The default 5V is perfect for that. I don't understand the documentation of analogReference(), perhaps you have to set "VDD" for the analog reference.
Getting a few samples and calculating the average is a common practice to read a temperature with a NTC, even with the hardware filter.
You can take the value of a number of analogRead(). There is no need to put a delay() between the reads. It will reduce the high frequency electronic noise.
@Wawa, I did not look very good. The "Arduino megaAVR Boards" is also for the Nano Every. But then it says that DEFAULT is the built-in 0.55V reference which is indeed defined in Arduino.h and not changed in its variant section.
I have a Nano Every, but I guess that I never used its analog input.
Calculations of expected analogRead() based on the voltage at the 5V pin as a reference seem to indicate it is indeed using the 5V rail as the reference.
It seems it is somewhat a matter of semantics and how you choose to do the computation. It is indeed a voltage divider, and the change in resistance of the thermistor over temperature results in a change in voltage across the thermistor (in my application.) As long as you know the values that change and what information they are reflecting (eg, NTC curve) and what computation you need to do to get the end result you're looking for for your algorithm. It is somewhat analogous to measuring "current" by measuring the voltage drop across a resistor of known value. Am I wrong?