Go Down

Topic: Temp measurement and display (Read 979 times) previous topic - next topic

dtokez

hi all, just messing around and getting used to the arduino.

I've hooked up a 10k thermistor and got it working using a tutorial to feedback data over serial. I have added too the code to display on my lcd screen. It works but when the temp goes below 10 degrees the display moves the digit over so for example 9 degrees reads 90. It does not display like this on the serial monitor however, but I used the same code to get the data over the display?
Hope that makes sense!

Code: [Select]
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);




#include <math.h>

double Thermister(int RawADC) {
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15;            // Convert Kelvin to Celcius

return Temp;
}

void setup() {
lcd.begin(16, 2);
delay(100);
Serial.begin(115200);
}





void loop() {
 
      lcd.setCursor(0,0);
lcd.print(int(Thermister(analogRead(0))));
 
  lcd.setCursor(2,0);
  lcd.print((char)223);
 
 
    lcd.setCursor(3,0);
    lcd.print ("c");



Serial.println(int(Thermister(analogRead(0))));  // display Fahrenheit
delay(1000);
}



dtokez

right, if i reset the board when the temp is below 10 degrees the lcd displays fine, so I guess when it goes below 10 I need to clear the display or something?

EmilyJane


right, if i reset the board when the temp is below 10 degrees the lcd displays fine, so I guess when it goes below 10 I need to clear the display or something?


You need to clear out, write spaces, where your temperature goes before you write a new value.

dtokez

#3
Aug 15, 2011, 01:03 am Last Edit: Aug 15, 2011, 01:14 am by dtokez Reason: 1
hey, thanks that works great. I'm still really new to the arduino but learning little bits here and there especially thanks to people like yourself :)

would it be complicated to have the degrees c symbol move to the left by one space when the temperature reading is in single figures?

Edit...

tried putting in if/else statements. It does compile and run but when the temp is <10 i get two degrees symbols for example 2°°C?

is it ignoring the if/else and just running both?

Code: [Select]
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);




#include <math.h>

double Thermister(int RawADC) {
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15;            // Convert Kelvin to Celcius

return Temp;
}

void setup() {
lcd.begin(16, 2);
delay(100);
Serial.begin(115200);
   pinMode(13, OUTPUT);     
}





void loop() {
    lcd.clear();
 
      lcd.setCursor(0,0);
lcd.print(int(Thermister(analogRead(0))));


if (int(Thermister(analogRead(0)))  <= 10)
{
  lcd.setCursor(1,0);
  lcd.print((char)223);
 
 
    lcd.setCursor(2,0);
    lcd.print ("c");  // action A
}
else if (int(Thermister(analogRead(0)))  >= 10)
{
  lcd.setCursor(2,0);
  lcd.print((char)223);
 
 
    lcd.setCursor(3,0);
    lcd.print ("c");  // action B
}


 
  lcd.setCursor(2,0);
  lcd.print((char)223);
 
 
    lcd.setCursor(3,0);
    lcd.print ("c");



Serial.println(int(Thermister(analogRead(0))));  // display Fahrenheit


   digitalWrite(13, HIGH);   // set the LED on
  delay(2);              // wait for a second
  digitalWrite(13, LOW);    // set the LED off
  delay(10000);              // wait for a second

}



EmilyJane

Instead of explicitly moving the cursor to the third column you could just print the degrees symbol and "c" immediately after the temperature. If you don't explicitly move it, it prints in the next available space.

Code: [Select]
void loop() {
 
      lcd.setCursor(0,0);
lcd.print(int(Thermister(analogRead(0))));
 
// lcd.setCursor(2,0);
  lcd.print((char)223);
 
 
//    lcd.setCursor(3,0);
    lcd.print ("c");

Go Up