Accuracy on AnalogRead using Internal reference

Hi all,

I am having difficulty with accuracy and have come up with the idea of measuring a known voltage and then finding out what multiply ratio is required. I would then like to store this in flash as a cal constant.
Then I would call this number as my multiply ratio.
I many lumps from banging my head against a wall I thought I would get help.

Does anyone have any tips or code on doing this ?

MainInput = analogRead(0); // Read Analog input 0, Main battery
  MainVolts = (MainInput * 17.7) / 1024; // convert raw data to voltage

Well the code you have can't work, because the analog input can only read between 0 and 5 volts

Well the code you have can't work, because the analog input can only read between 0 and 5 volts

Whether the snippet will work, or not, is not related to the ability of the Arduino to handle voltages in some given range.

The voltage that is to be measured my well be in the allowable range. Or not, but that has nothing to do with how the code will be executed.

But that snippet does look odd with those magic numbers which suggest that the reference value is supposed to be 17.7 volts.