LM35 minimum temperature

hi,

I want to get the maximum and minimum temperature for a LM35 temperature sensor.
I can obtain the maximum temperature, but for some reason I have trouble getting the minimum temp. I only get a read of 0.
oh…btw…first arduino project for me.
10x guys.

the code :

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR    0x3F        
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

float temp;
float tempC = 0;
float samples[8];
float maxi = 0;
float mini = 0;
int tempPin = 0;
int ledPin = 13;
int i;

LiquidCrystal_I2C	lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()
{
  lcd.begin (20,4);                             
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);  
  lcd.setBacklight(HIGH);
  lcd.home ();                                  
  lcd.print("Parameter : "); 
  
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  temp = analogRead(tempPin);
  temp = temp * 0.48828125;
  
  if (temp>28.0) 
  {
    digitalWrite(ledPin, HIGH);
    delay(1000);
  } else {
    digitalWrite(ledPin, LOW);
  }  
  
  Serial.print("TEMPERATURE = ");
  Serial.println(temp);
  Serial.print("*C");
  Serial.println();
  delay(1000);
  
  lcd.setCursor (0,1);        
  lcd.print("Temp:");
  lcd.setCursor (6,1);
  lcd.print(temp);
  lcd.setCursor (11,1);
  lcd.print("*C");
  delay(500);
  
  // try
  
  for(i = 0;i<=7;i++)
  {                                           
  samples[i] = temp; 
  tempC = tempC + samples[i];
  delay(100);
  }
  tempC = tempC / 8.0;
  if (tempC > maxi) {maxi = tempC;}
  if (tempC < mini) {mini = tempC;}
  
  lcd.setCursor (0,2);
  lcd.print("min=");
  lcd.setCursor (4,2);
  lcd.print(mini);
  lcd.setCursor (10,2);
  lcd.print("max=");
  lcd.setCursor (15,2);
  lcd.print(maxi);
  tempC = 0;
  
  Serial.println(mini);
  Serial.println(maxi);
}

moderatore: added code tags

Perhaps:

Ample examples available via searching the forum. Also, there is a library for the LM35, although I have never used it:

mini is set to zero initially and you never see anything less. Read the temp in setup and set mini and maxi to it.

  1. mrburnette

  2. wildbill

10x so much for your help. it now works great.