Maker Pro
Maker Pro

Problem with LM35

bigone5500

Apr 9, 2014
712
Joined
Apr 9, 2014
Messages
712
I have an UNO with a temperature sketch which displays the current temp in F. I'm using an LM35CAZ. When the display reaches 87.8 degrees, it starts showing negative readings.

Any ideas?

Here's the sketch:

Code:
#include <Wire.h>                  // Include the Wire library.

#include <LiquidCrystal_I2C.h>     // Include the Liquid Crystal I2C library.

#define sensor 0                   // Define the A0 pin as “sensor”. This can be changed as needed.

int   Vin;                         // Variable to read the value from the Arduino’s pin

float Temperature;                 // Variable that receives the converted voltage value to temperature

float TF;                          // Variable to receive the converted value from  ºC to ºF

LiquidCrystal_I2C lcd(0x27, 16, 2); // Sets the I2C address of the LCD and declares 16 columns, 2 rows.

void  setup()

{

  lcd.begin();
 
  lcd.setBacklight(1);            // Turns on the backlight of the LCD. Probably not needed but here anyway.

  lcd.setCursor(2, 0);            // Sets the cursor to column 2, row 0.
 
  lcd.print("Temp: ");            //  Send the text 'Temp:' to the screen of the display.
 
  Serial.begin(9600);             // Sets the baud rate for the serial monitor.

}

void  loop()

{

  Vin = analogRead (sensor);      // Tells the Arduino to read the pin and stores the value in “Vin”.

  Temperature=(500*Vin)/1023;     // Converts the voltage value into temperature and stores it into the “Temperature”  variable  (in  ºC)

  TF = ((9*Temperature)/5)+32;    // Converts  ºC to ºF and stores the result in the variable 'TF'.

  lcd.setCursor(4, 1);            // Sets the cursor to column 4, row 1.

  lcd.print(TF);                  // Exhibits the value of the temperature on the display.
  lcd.print(" F");                // Writes “F” to indicate that it is in Fahrenheit scale.

  Serial.print(TF);               // Prints the value 'TF' to the serial monitor
  Serial.println(" F");           // Prints the 'F' designation and inserts a space after 'TF'. 'println' causes a new line carriage return.

  delay(1000);                    //  Waits for 1 second to read the pin again.

}
 

Attachments

  • Temperature_-_LM35_-_I2C_LCD.zip
    936 bytes · Views: 47
Last edited:

davenn

Moderator
Sep 5, 2009
14,267
Joined
Sep 5, 2009
Messages
14,267
@bigone5500 can you please upload the unzipped files to the forum so people can view them


Dave
 

bigone5500

Apr 9, 2014
712
Joined
Apr 9, 2014
Messages
712
@bigone5500 can you please upload the unzipped files to the forum so people can view them


Dave

I would but .ino files are not allowed. Maybe an Admin can change that?

Most current operating systems have native zip support so I didn't think it would be a problem.

I have edited the original post to include the code but the 'code' tags have caused part of the sketch to delete. Line 27 should read: lcd.print("Temp: "); // Send the text 'Temp:' to the screen of the display.
 

davenn

Moderator
Sep 5, 2009
14,267
Joined
Sep 5, 2009
Messages
14,267
Most current operating systems have native zip support so I didn't think it would be a problem.

no they don't, WinZip or WinRAR needs to be downloaded and installed, but that's not the point ;)
its better to make it as easy as possible for the reader/potential helper to view files :)

what is an .ino file ?

cheers
Dave
 

bigone5500

Apr 9, 2014
712
Joined
Apr 9, 2014
Messages
712
I can use windows vista, 7, 8, or 8.1 to unzip. Rar files are another beast though. You can create a compressed folder which results in a zip file.
 
Top