Go Down

Topic: DS18B20 sensor temperature display with 9 bit precision (Read 1 time) previous topic - next topic

Saulius

Gentlemen's,
I'm developing a small project with three DS18B20 temperature sensors in 9 bit resolution mode and 16x2 LCD display. Using 'OneWire.h' + 'DallasTemperature.h' + 'LiquidCrystal.h' libraries without modification. All works fine.
The issue I have is related to the fact that I have quite limited display space to indicate temperatures (I want to display some other text also). Standard libraries by default shows temperature in format (-)XX.XX, for example 23.50 or 23.00 Celsius . Since I need only 9 bit temp resolutions it would be enough to have one digit after comma, like 23.0 or 23.5 Celsius. That would save me some space on the LCD screen.
Any ideas how to do it in elegant way?
Thank a lot!

pylon

Code: [Select]

float temperature = 4.5267;
char buffer[5];
snprintf(buffer, sizeof(buffer), "%.01f", temperature);

robtillaart

assuming lcd inherits from Print class
Code: [Select]

float temperatureC = getTempC();

lcd.print(temperature, 1); // for float the param means the # decimals
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Saulius

Thanks a lot! This is super easy way of fixing it! :)

Go Up