DS18B20 - temperature sensor code Help Request

  1. As suggested, I changed the variable names as suggested temp0 and temp1.

2.Also, added the else statement to isolate each condition.
This has cleared up the LED blinking problem - on Temp0 -GREAT

  1. PROBLEM:

When Temp0 > 29 LED0 turns on steady (GOOD) but LCD flashes between the word "Temp0" and "Alarm0" - Not Good!

How do I correct Flashing LCD problem? Suggestions ?

When Temp1 > 25 LED1 turns on steady (GOOD) and "Alarm1" is displayed steady - no flashing - Good!
This is how Temp0 should work

LATEST CODE BELOW:

#include <OneWire.h>

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

LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27  16/2
// LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27  20/


// pin connected to sensor
int tempPin = 2;
// define the onewire obj needed for connecting to onewire components
OneWire oneWire(tempPin);
// define dallas obj, makes it easier to read temp
DallasTemperature tempSens(&oneWire);

DeviceAddress insideThermometer = { 
  0x28, 0x25, 0x33, 0xDC, 0x03, 0x00, 0x00, 0x7E };
DeviceAddress outsideThermometer = { 
  0x28, 0x67, 0x3D, 0xDC, 0x03, 0x00, 0x00, 0xC7 };


void setup() {
  // set up the serial console
  Serial.begin(9600);
  pinMode(7, OUTPUT); //pin selected to control OVER TEMP LED red temp0  
  pinMode(8, OUTPUT); //pin selected to control OVER TEMP LED green temp1

  // digitalWrite(7, LOW);


  lcd.init(); // initialize the lcd
  lcd.backlight();
  //lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.
  lcd.clear(); // start with a blank screen



  // initialise the temp sensor

    tempSens.begin();
  // set the resolution to 10 bit (good enough?)
  tempSens.setResolution(insideThermometer, 10);
  tempSens.setResolution(outsideThermometer, 10);

}

void loop() {
  // get the current temperature

  tempSens.requestTemperatures();

  // get the temperature in centigrade
  // index 0 as multiple temp sensors can be connected on same bus

    float temp0 = tempSens.getTempCByIndex(0);

  Serial.print("TEMP0 = ");
  Serial.print(temp0);
  lcd.setCursor(0,0);
  lcd.print("TEMP0 = ");
  lcd.print(temp0);
  delay(200);

  float temp1 = tempSens.getTempCByIndex(1);
  lcd.setCursor(0,1);
  lcd.print("TEMP1 = ");
  lcd.print(temp1);
  Serial.print("TEMP1= ");
  Serial.print(temp1);
  //delay(200);

  if  (temp0  > 29) //sensor0 temp0
  {
    lcd.setCursor(0,0);
    Serial.println("Alarm0= ");
    lcd.print("Alarm0= ");
    lcd.setCursor(8,0);
    Serial.println(temp0);
    lcd.print(temp0);
    digitalWrite(7,HIGH); //LED0 /FAN0
  }
else 
  {
    digitalWrite(7,LOW);
   
  }


  if  (temp1  > 25) //sensor 1 temp1
  {
    lcd.setCursor(0,1);
    Serial.println("Alarm1= ");
    lcd.print("Alarm1= ");
    lcd.setCursor(8,1);
    Serial.println(temp1);
    lcd.print(temp1);
    digitalWrite(8,HIGH); //LED1 /FAN1
  }
  else 
  {
    
    digitalWrite(8,LOW);
  }









}