ATTiny13a tempurature monitoring without additional components.

The AVR temperature and band gap references are very precise/stable, but not very accurate. You need to calibrate them for each chip to get accurate readings. The performance of the RC oscillators on the chips will be far worse, particularly between chips with different date codes.

I’ve received a few PMs about this, so I thought I’d update this thread.

Texaspro is right about the variations between the chips. For accurate control one would have to calibrate each chip, and probably in each light for accuracy. But what Texaspro didn’t mention is that the very same applies for the turbo timeout because the same oscillators are used for Turbo timeout measuring. The differences between chips are just as apparent when timing the Turbo timeout. The times vary between chips and also how hot the chip is has a direct affect on how long the turbo timeout lasts.

As turbo timeouts are to protect against heat, the variations in chips and temperatures will have a direct affect on how long the turbo lasts and essentially how hot the light gets. So if one is happy with the current inaccurate turbo timing one could also be happy with inaccurate temperature control. However, for mass-production having an inaccurate turbo timeout is much preferred because you can just reset it again if it stops to early, instead of being forced to wait until the chip thinks it’s cool enough.

I’ll be implementing temperature control in some of my “high end” lights after calibrating them individually, but for the every day use light it’s not worth the effort.

Given that output will drop from high when Vb is below Vf wouldn’t it be safe to ignore the low end of the input voltage spectrum so instead of 4.2V-2.9V just consider 4.2V-3.6V or so.

The turbo timeout variations are not much of a problem… a 10% difference in timeout time is not that important and are only dependent upon a single oscillator. Errors become much more important when you are trying to measure temperature via subtle differences in the rates of two different oscillators.

I had also tried a bit; measured the cpu cycles per watchdog cycles at 2 temperatures and different voltages. The results were quite different from what I expected from the data sheet graphs, the influence of the temperature was about half of what I had calculated from those, while the influence of the supply voltage was much higher than what the graphs indicated. Especially the latter is quite unpleasant. My personal conclusion: not worth pursuing.

Oops, yeah, your right about that.

I just started with practical tests and didn’t compare with the datasheets. Using a zener solves the supply voltage issue, and it does appear to work quite well once calibrated, but it is a hassle to calibrate.

I guess it would be easier to just use an external component. It was fun enough to try without though.