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 :
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 :
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.