The Akafugu Blog
A while back I picked up an analog panel meter from Adafruit. It was part of a bigger order, and I added it to my cart as an afterthought: It looked cool and was analog. It’s been sitting on my shelf doing nothing since then, so I thought it was about time to try and put it to some proper use. It can measure 0-50 uA of current, and I decided to use it as a thermometer. Luckily, we never really get temperatures below freezing in Tokyo, so just using the scale from 0-50 is fine.
The ATTiny13 is another part that’s been lying around for a while without being put to any good use. It has only 1k or flash memory, so it fills up very quickly. I figured 1k ought to be enough for a simple thermometer though.
For the temperature sensor, I used the DS18B20 onewire sensor. Onewire is a complex protocol, and since this was meant to be a quick one-night project, I went looking for a library. There is a good one here, but it’s too big to fit into the ATTiny13. After scanning around a bit more, I found some much more compact code, basically an older version of the same library. After trimming this down, I was able to fit everything into 1k.
The code for “writing” the temperature to the uA meter is quite simple: Just set up PWM on a pin, and change the duty cycle to control how much current the panel sees. It’s hooked up with 5V through a 100kohm resistor, as suggested on the Adafruit product page [link].
The code is here: https://github.com/akafugu/uA-thermometer