Weird things with serial port - standalone atmega 328p

Hi!

I'm preparing mini meteo station with bmp180 baro module.
I started with Atmega328p ( running in internal 8MHz oscilator) and BMP180 sensor. I connected this test circut it to Arduino Board via UART to get some readings and check everything. For testing I uploaded Afraduit BMP library example.
But when I opened my Serial port terminal in Arduino IDE and I saw only a trash like this :

P����dY� 15r�� meW��5
%�s��� X��a��e B��c]+ѕdJ�9N�� PXC!U�l
�tZW���=���.2Nj�tY��H
�Te[�rXW�� =��.&RC
!%���u���99M&��5
P��t]V�= 15r�� mYW�sC!%��s]�
сseX���lBcak�lXW�� =��5���

Circut is running at 3.3V from switching power supply and I added necessary capacitors to atmega power pins.
( 2 x100nF and one 4.7uF capacitor).
But when I accidenatally decrase voltage to 2.6V I saw this :

TempY��ure = 20.LR5
Pre���� = 99532 Pa
P���Ց��= 150.36 metY��H%����ɕ�at sealeve B���ulated) = 9NM&��
Real altZW��= 165.21 meter�H�H�TemperXW���= 20.10 *C
%������ = 995&��5
Altitude = 150.19 meters

Message contains some trash but some parts are correct.
When I drop voltage to 2.4 V trash disappered :

Temperature = 20.00 *C
Pressure = 99525 Pa
Altitude = 150.61 meters
Pressure at sealevel (calculated) = 99532 Pa
Real altitude = 164.53 meters

My question is : What is happening? And how I can fix it ?
I can understand glitches in transmittion when voltage is lower than it has to be, but why It works only when voltage is to low ?

Perhaps the internal oscillator is too far out of spec at the higher voltage. That would make the UART data into the trash. Try it at a low Baud rate (e.g. 9600 or 1200) and see if it works.

It didn't work.
I lowered baud rate even to 300 and I'm still getting trash in voltage higher than 2.4 V.
I also checked it without baro module and I got the same trash.

I burned arduino uno boot loader and put microcontroler into arduino uno board. It works. But when I burned boot loader for internal 8 MHz oscilator, it stoped working.

But I also tested pure C UART code ( I compiled it with gcc-avr command line ) and it works even in 5V without any errors. So this is probably a problem with Arduino IDE not with microcontroler.

You can "tune" the internal ocsillator with the OSCCAL register.
Be aware - without calibration your clock could be easily 20% off, bad for your UART's baudrate.

If voltage and temperatur are more or less constant you can get pretty good results by tuning the internal oscillator. I have done it often, most with attinys but also with atmegas if necessary. It works pretty well.

Search for "OSCCAL tuning" or something like this.
A startingpoint may be this: Calibrating the internal oscillator (on an ATMega8) - Microcontrollers - Arduino Forum

I will better use external 8MHz oscilator, my circut will work outside so temperature won't be stable.

Now I'm wondering which fuse setting I need to run my atmega on external 8MHz oscilator.

I'm using Engbedded AVR fuse calculator : AVR® Fuse Calculator – The Engbedded Blog

It look's very complicated. In clock options I can see many 8 MHz External oscilator settings. Which one I need to use ?

To use an external crystal is a good idea.
I would use an crystal (2 legs) and 2 ceramic capacitors about 18 picofarad
and one oft the

Ext. Crystal/Resonator High Frequ.

fuse settings (bottom of list of the fuse calculator in your link).

My favorite would be Low Fuse: 0xFF
(By the way: this is also the low fuse setting used with Arduino UNO)