MAS3:
Hi.I have no idea what 'nan' is.
I do not see any serial communication in your sketch.
But opening the serial monitor, causes a reset.
Perhaps your screen needs some extra time to reset after power on.
So try to have a larger delay() in line 18, and if that doesn't help, put in some extra delays in other lines, just to test.
thanks for reply, I tried your suggestion, but it didnt help. if i do not have serial monitor open loop function doesnt work. if I have serial monitor open the OLED updates, if i close serial monitor window the text on doest updates from the loop function.
why is loop function dependent on serial monitor window being open ?