12volt LiFePO4 battery and buck converter

Understood, I was using it to control the voltage to see the response on the serial monitor as it was all I had available but was able to get my hands on a power supply. I was able to adapt code from this post : 12V battery meter with Arduino MEGA - #19 by septillion and produced the following sketch which "works" though the voltage displayed on the serial monitor is not the same as displayed on the power supply.

for example, when power supply voltage is 10.51, serial monitor displays 10505 mV corresponding with 0%, any lower than 10505 mV and the serial monitor reads 62%. same with the max voltage, when I set the power supply to 13.44, serial monitor reads 13426 and prints it as 100%.

Any feedback and suggestions would be appreciated

#define readPin A0
const unsigned long BatR1R2[] = {5000, 2930}; // resistor values
const unsigned long RefVolt = 4940;        // voltage divider output at A0
const unsigned long BatRsVal = 1024;
const unsigned long Ratio = ((BatR1R2[0] + BatR1R2 [1]) * RefVolt) / BatR1R2[1];
const unsigned long BatVoltMax = 13400; // fully charged LifePO4 battery
const unsigned long BatVoltMin = 10500; //approximate fully discharged voltage
const unsigned int NrSamples = 1000; // not sure what this does
float counts = 0;


void setup()
{
  Serial.begin( 9600);
}

void loop()
{
  delay(5);
  unsigned int adcValue = averageRead( readPin);
  analogReference(DEFAULT);
  unsigned int BatVoltage = adcValue * Ratio / BatRsVal;

  Serial.print("Batery voltage [mV]: ");
  Serial.println(BatVoltage);
  byte percent = 100 * (BatVoltage - BatVoltMin) / (BatVoltMax - BatVoltMin);
  Serial.print("Battery level [%]: ");
  Serial.println(percent);

  delay(5000);
}

// --------------------------------------------
// averageRead()
// --------------------------------------------
// By using 'float' numbers for the average,
// it is possible to get more bits than
// the 10 or 12 bits that is returned by analogRead().
//
// The total of the samples is not done with float, because
// then bits could get lost.
// Only at the end, the floating point calculation is done.
//
// When the voltage is calculated, use 1024, not 1023.
// The "half a bit" is explained here: https://www.gammon.com.au/adc


//const int nSamples = 1000;   // Usually from 5 to 10000

unsigned int averageRead( byte pin)
{
  unsigned long total = 0;

  for ( int i = 0; i < NrSamples; i++)
  {
    total += analogRead( pin);
  }

  total += NrSamples / 2;   // add half a bit

  return ( total / NrSamples);
}