user88944: 
I want to read my lithium battery voltage.

I WANT TO CREATE A FUNCTION TO READ MY 3.7~4.2V,1200mAH BATTERY VOLTAGE THROUGH A MICROCONTROLLER (ARDUINO OR ATTINY44).

THEN I WANT TO CALL THE CREATED BATTERY FUNCTION IN THE FORMULA TO READ PRECISE SENSOR VALUE
 int voltage = ((CALLING BATTERY FUNCTION) * (READ SENSOR VALUE)) / 1023;


I AM USING INTERNAL REFERENCE VOLTAGE 1.1V.
NOTE: I want the whole system to run on lithium battery ( I am just creating a prototype on Arduino, if it works, ill be editing the code for my attiny44 using 8mhz external crystal).
 void setup(){
   Serial.begin (115200);
 }

 void loop() {  
   //REFS1 AND REFS0 to 1 1 -> internal 1.1V refference
   ADMUX |= B11000000;   
   //We read A1 (MUX0)
   ADMUX |= B00000001;       
   // Start AD conversion
   ADCSRA |= B11000000;
   // Detect end-of-conversion
   while (bit_is_set(ADCSRA,ADSC));
   float val = ADCL | (ADCH << 8);
   val = val * 5.7; //Multiply by the inverse of the divider
   Serial.println(val);
 }



This code is working but it is reading from analog Pin. Is there any possibility to do it without using AnalogPin because I dont have any spare pin on my attiny.

user7859: 
I want the whole system to run on lithium battery

If you power the Arduino from the battery, then you can indirectly read the battery voltage by reading the internal voltage reference. This requires no pins - just connect the battery across the Arduino ground and the 5V pin. Here is more explanation on why this works...
https://wp.josh.com/2014/11/06/battery-fuel-guage-with-zero-parts-and-zero-pins-on-avr/
Note: Do not connect more than 5 volts or less than 0 volts to the 5V Arduino pin. This pin is connected directly to the AVR without any overvoltage or reverse polarity protection. Your  3.7~4.2V battery should be fine.

88944: <p><a href="https://i.stack.imgur.com/bu89s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bu89s.png" alt="enter image description here" /></a></p>
<p>I want to read my lithium battery voltage.</p>
<ol>
<li><p>I WANT TO CREATE A FUNCTION TO READ MY 3.7~4.2V,1200mAH BATTERY VOLTAGE THROUGH A MICROCONTROLLER (ARDUINO OR ATTINY44).</p>
</li>
<li><p>THEN I WANT TO CALL THE CREATED BATTERY FUNCTION IN THE FORMULA TO READ PRECISE SENSOR VALUE</p>
<pre><code> int voltage = ((CALLING BATTERY FUNCTION) * (READ SENSOR VALUE)) / 1023;
</code></pre>
</li>
<li><p>I AM USING INTERNAL REFERENCE VOLTAGE 1.1V.
NOTE: I want the whole system to run on lithium battery ( I am just creating a prototype on Arduino, if it works, ill be editing the code for my attiny44 using 8mhz external crystal).</p>
<pre><code> void setup(){
   Serial.begin (115200);
 }

 void loop() {  
   //REFS1 AND REFS0 to 1 1 -&gt; internal 1.1V refference
   ADMUX |= B11000000;   
   //We read A1 (MUX0)
   ADMUX |= B00000001;       
   // Start AD conversion
   ADCSRA |= B11000000;
   // Detect end-of-conversion
   while (bit_is_set(ADCSRA,ADSC));
   float val = ADCL | (ADCH &lt;&lt; 8);
   val = val * 5.7; //Multiply by the inverse of the divider
   Serial.println(val);
 }
</code></pre>
</li>
</ol>
<p><strong>This code is working but it is reading from analog Pin. Is there any possibility to do it without using AnalogPin because I dont have any spare pin on my attiny.</strong></p>
 7859: <blockquote>
<p>I want the whole system to run on lithium battery</p>
</blockquote>
<p>If you power the Arduino from the battery, then you can indirectly read the battery voltage by reading the internal voltage reference. This requires no pins - just connect the battery across the Arduino ground and the 5V pin. Here is more explanation on why this works...</p>
<p><a href="https://wp.josh.com/2014/11/06/battery-fuel-guage-with-zero-parts-and-zero-pins-on-avr/" rel="nofollow noreferrer">https://wp.josh.com/2014/11/06/battery-fuel-guage-with-zero-parts-and-zero-pins-on-avr/</a></p>
<p>Note: Do not connect more than 5 volts or less than 0 volts to the <code>5V</code> Arduino pin. This pin is connected directly to the AVR without any overvoltage or reverse polarity protection. Your  3.7~4.2V battery should be fine.</p>
