Battery meter

If anyone want to make a battery meter, I think that the circuit should be a voltage divider (R1=R2 it's easy) from battery+ to GND and a software voltmeter. This is what I made.

void chargeControl(void) {
  batteryVoltage = (map(analogRead(batteryPin), 0, 1023, 0, 3300))- 30; //mV on the divider
  batteryVoltage = batteryVoltage * 2;                                  //mV on Battery
  batteryState = map(batteryVoltage , 3200, 4250, 0, 100);              //% of charge
  batteryVoltage = (batteryVoltage / 1000);                             //V on battery
}

I've noticed that it's not so precise, so I've made a -30mV operation.
Hope it will help you.