analogRead reads incorrect value after program starts

I am using an Arduino Nano and have noticed that after startup, analogRead() gives a wrong result at the first call. As a workaround I have called analogRead() twice in setup(), just in order to “prime” it. I also use analogReference(INTERNAL) to get the 1.1V reference.

As a workaround I have called analogRead() twice in setup(), just in order to "prime" it.

It takes time for the ADC to settle after startup. What you are doing is the usual way to make it settle.

Just call analogRead() at the beginning of setup and throw the result away.