I noticed that my analogRead was showing 1023 at 4.4v and I'd like to read 1023 at 5v. After some research it appears the ADC scale is a reference to the 5v pin (which is a direct correlation to the usb power voltage or the barrel jack power voltage. Is all of that correct?
If so, I took a measurement of the Arduino 5v pin voltage value and it's at 4.4v, which would correlate with my ADC scale being skewed. Am I able to power the Arduino through the barrel jack, while still plugged into my laptop and using the serial communication? If yes, what's a safe known good power supply to purchase and do this with, to achieve a true 5v out of the 5v pin and as a reference value?
To confirm I've understood the manual correctly, I can add analogReference(EXTERNAL); to my code, give that a 5v input voltage from a phone charger without an inline resistor, connect the ground side of the phone charger cable to the Arduino GND pin and continue with my project?
I don't really understand what you mean. If you want to use an external ref voltage, you must connect this voltage to the Vref pin - and it should be independent from and more stable than your power source of the Arduino.
I would recommend to use the internal reference and adjust the measuring voltage by a voltage divider if needed.
Ok, so if that's the case I'll stick with the barrel jack if I can use that while still connected to my laptop via usb. That's a good idea ZX80, however I have a bench test rig set up and would like to verify with the full voltage range.
According to this post it is not safe to power the Arduino externally while connected via a serial cable, unless you cut the power wire in the usb cable?
To clarify for my own understanding, do you mean to use the divider from the output of the sensor since the reference is 1/2 of 5v? This way it gets 1023 at 1/2 of 5v and my sensor now has a range of 0 to 2.5v with the divider? This assumes an external power source of 5v to the sensor correct?
For example you have 4 Volts from your sensor, divided by 2 by the voltage divider.
2/2.56 = 0.78125 //proportion of maximum analog reading
0.78125*1024 = 800 //ideally analogRead = 800
800*0.005 = 4 Volts
voltage = value * (2.56/1023) * ((R1 + R2)/R2)
voltage = value * (2.56/1023) * ((10k + 10K)/10K)
voltage = value * 0.002502444 * 2
voltage = value * 0.005