-
Mapping Temperatures
12/30/2014 at 23:22 • 0 commentsThe simplest color map would be a table with one entry per temperature increment available from the sensor. Given a spread of room temps from -20°C to +40°C, that's a table of longwords well under 1K even at 0.5° intervals. There's no need for that much redundancy, and it might be advisable to keep the entire memory footprint down in case there's reason to scale back to, say, a Tiny 4313 where a 1K table has a noticeable impact on space left for code. Computers are good at math, so the usual trick is a small table of inflection points and a handful of statements to interpolate between them...
// temp_to_color - convert temp x 10 to ready-to-use color value for RGB LED Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800); uint8_t cmap[] = { 0xff, 0xff, 0xff, // -9C - white 0x00, 0x00, 0xff, // 3C - blue 0xff, 0x00, 0x00, // 15C - green 0xc0, 0xff, 0x00, // 27C - orange 0x00, 0xff, 0x00, // 39C - red } uint32_t temp_to_color(int degree_tenths) { uint32_t c; uint8_t i; int floor_t; float scale; // Grab extremes (colder than -9C and warmer than 39C) and return max colors if (degree_tenths <= -90) c = strip.Color(cmap[0], cmap[1], cmap[2]); else if (degree_tenths >= 390) c = strip.Color(cmap[12], cmap[13], cmap[14]); else { i = ((degree_tenths + 90) / 120) * 3; // set floor at -9C and scale range floor_t = (i * 40) - 90; // get the bottom temp of this range scale = (degree_tenths - floor_t)/ 120.0; // calc how far along this range // get colors by interpolating this range and adding it to the base color c = strip.Color(cmap[i] + (cmap[i+3]-cmap[i])*scale, cmap[i+1] + (cmap[i+4]-cmap[i+1])*scale, cmap[i+2] + (cmap[i+5]-cmap[i+2])*scale); } return(c); }
This should take care of temps below and above what the table can handle, and gradiate the colors along the continuum. It has the additional advantage of being easier to tweak than editing a massive table.
-
Colors
12/23/2014 at 23:03 • 0 commentsThinking of the color-display aspects of the project, I think one or two selectable color ramps is enough to get started.
Really Cold -> Cold -> Comfy -> Warm -> HotWhite -> Blue -> Green -> Orange -> Red
About 12°C ought to be a good initial separation...
-9°C -> 3°C -> +15°C -> +27°C -> +39°C
-
The Libraries
12/16/2014 at 22:51 • 0 commentsEven a simple Arduino project invokes libraries. Here's what I plan to use...- Paul Stoffregen's OneWire library - for fetching data from any 1-Wire device
- Miles Burton's DallasTemperature library - for dealing with device-specific issues with the DS1820/DS1822
- Adafruit's NeoPixel library - for driving the WS2811 LED.
With the heavy lifting done by the libraries, the core code just needs to call for a temp conversion, map temp to a color, set the color, then sleep for a time and repeat endlessly. Enhancements include adding a simple button interface to mark a set-point, and perhaps to discover additional DS182x/WS2811 pairs on extension wires. -
DS1820 or DS18S20 or DS18B20 or DS1822...
12/09/2014 at 22:49 • 1 commentIt's been a while since I've picked up a 1-Wire sensor, and I come to find that the venerable DS1820 has been retired. Looks like the current recommended parts are the DS1822 for 2°C accuracy and the DS18B20 for 0.5°C accuracy (the DS18S20 is a drop-in for the original DS1820).
APPLICATION NOTE 4377 - Comparison of the DS18B20 and DS18S20 1-Wire® Digital Thermometers
With all of that, I happen to have the original DS1820 and the newer DS1822 in my parts bin, so I plan to test them both. -
Initial Design Notes
12/02/2014 at 21:19 • 0 commentsThe hardware design of the LED Thermometer is straightforward. The WS2811 LED consumes one pin, and the 18B20 consumes one pin for data. Given the nature of both the WS8211 and 18B20, it's easy to add multiple pairs of temperature sensors and display LEDs chained back to the first one, the only issue being matching up the sequence of LEDs with the random nature of 18B20 addresses on the bus, but requiring them to be added one at a time and saving the station addresses in EEPROM could simplify the expansion process.