LIR2450 has a voltage output from 4.2 to 2.75V,
ATMEGA328P will operate from 2.7 to 5.5V so you don't need to waste energy running a voltage regulator.
so to measure voltage you need to compare the supply voltage with a known voltage.
you can use the internal 1.1V reference.
So use a 4:1 divider from a GPIO pin to ground and set the GPIO high and measure ...
The problem is that the ADC input works best with impedances below 10k which reads in the datasheet.
The divider has an impedance much greater than that, above 500k.
It has no chance to charge the internal ADC sampling capacitance in the given sampling time.
If you don't plan to sample very often, put something like a 100nF capacitor at the ADC input pin.
Thank you all for helping me! I do have the TQFP package. However I found the problem which was actually stupid. The outputs where listed:
But I seemed to only have listed 4 outputs out of 5. One of the outputs I forgot. So after seeing ...
The package type of ATmega328-AU is Plastic Thin Quad Flat Package (TQFP). The pin configuration is different from the 28 SPDIP package types. On 28 SPDIP package, pins 9 and 10 are crystal input. In this case, you could not be used like Arduino Pin.
On Atmega328-AU is different, you can use Pin 9 like Arduino Pin 5.
Your test code can be like this: