ATMega328p in cold temperatures

I was testing my custom board based on ATMega328p running at 8 Mhz. It has on board temperature/humidity sensor so I put it the freezer for half an hour. After I took it out and hooked up to FTDI serial to USB converter I observed some really strange behavior. All serial output was jumbled, like it was communicating at wrong baud.
I was still able to upload sketches to it tho...
Perhaps it condensation issue, but is it possible that cold affected AVR chip somehow? Any ideas? I'm just curious :slight_smile:
Oh and after it warmed up a bit, it started to work fine.

Could be condensation or also could be your clock source is not rated to give you 8MHz at that temperature. You would have to read the data sheet for your crystal or resonator. Or while it is producing bad output, go ahead and measure the clock frequency, and then you'll know what's going on. There is a fuse setting which will output the clock on one of the Arduino pins, and you can read the frequency with another Arduino running a sketch Nick Gammon has on his web site, google "gammon frequency counter".

The internal 8 MHz clock is quite temperature sensitive.
See Figure 30-320 in the “big” ATMega328p data sheet (attached).

I would also guess condensation shorting things that shouldn’t have been.

I do use internal osc and running chip at 3.3V... This is intersting, I now see a reason for external oscillator :slight_smile:

As long as you don't need a perfect clock speed it will probably work OK(i guess you have a non cable way to get the readings to where they are supposed to go or logging them on something?), I have a attiny13A outside now in -20C, transmitting the temperature and humidity from a dht22 with a nrf24l01. And if that chip can handle it i cant imagine newer chips are less capable to handle the cold then the old t13.

bratan:
I do use internal osc and running chip at 3.3V... This is intersting, I now see a reason for external oscillator :slight_smile:

Have you determined that it's the problem?

I've run a number of temperature range tests (from freezer at -20°C to hot air at +50°C), with a 328p and the internal 8MHz, using serial output at 9600 baud without issues. The only times I've seen problems with these tests were when condensation temporarily shorted out some of the external components (e.g. sensor or LCD), but never the 328p itself.

Even if the oscillator frequency is the problem in your case, if you calibrate it in the first place the temperature change wouldn't push you over the edge.

I'll do more experimentation. I communicate to all my ATMega at 115200 baud...

swe-dude:
As long as you don't need a perfect clock speed it will probably work OK(i guess you have a non cable way to get the readings to where they are supposed to go or logging them on something?), I have a attiny13A outside now in -20C, transmitting the temperature and humidity from a dht22 with a nrf24l01. And if that chip can handle it i cant imagine newer chips are less capable to handle the cold then the old t13.

Yeah I use RFM69W transceiver and TH02 sensor to send data every 15 minutes. It's normally powered by 3V CR2032 battery, which actually lasted me from May 12th, 2015 to January 04, 2016. But in cold weather it dies in less than a month obviously :frowning:

nice battery life there. One thing have you added a big cap? the cr2032 cant handle much current before the voltage drops. I'm using a 680Uf 4v electrolyte with that i get OK transmissions down to 1.6v might help you too getting thru the cold time.

swe-dude:
nice battery life there. One thing have you added a big cap? the cr2032 cant handle much current before the voltage drops. I'm using a 680Uf 4v electrolyte with that i get OK transmissions down to 1.6v might help you too getting thru the cold time.

Wow I haven't thought about that! That's a great idea!
BTW what about current leakage? At for example UWT0G681MNL1GS has leakage of 27.2uA... Wouldn't that drain 220mAh battery in about 200 days?

bratan:
I communicate to all my ATMega at 115200 baud...

That makes it more likely that it could be the problem. At 8MHz/115Kbaud the UART error is -3.5% (as opposed to 0.2% at 9600). A colder oscillator is a slower oscillator. Running off of a nominal 3V battery when the oscillator is targeted to be default calibrated at 3.3V makes it even slower. And if it happened to be calibrated a bit slow to begin with it could all add up.

You have the option of recalibrating the oscillator to run a few percent faster.

bratan:
It's normally powered by 3V CR2032 battery, which actually lasted me from May 12th, 2015 to January 04, 2016. But in cold weather it dies in less than a month obviously :frowning:

That wasn't obvious to me. I was under the (apparently incorrect) impression that CR2032 batteries did reasonably well in the cold. The graphs I've seen suggested that to me anyway.

jboyton:
That wasn't obvious to me. I was under the (apparently incorrect) impression that CR2032 batteries did reasonably well in the cold. The graphs I've seen suggested that to me anyway.

That's what I thought too... And these are fresh Sony branded batteries...
Take a look at these graphs for past two days. I replaced battery on Jan 5th (around 4 PM) and it was at about 3.1V. Now it's at 2.77V...

What current is it drawing when active/inactive and what is the duty cycle?

Are the voltage measurements taken when the device is active?

What voltage do you see with a fresh battery maintained at 5°C for 48 hours of operation?