Problem running code using Dallastemperature and OneWire

Hi Everyone,

I have an Arduino Uno board, DallasTemperature sensors, OneWire, and LCD that I am using to display the temperature at a device continuously (in 1000 ms increments, one device at a time) until the button is depressed, which increments to the next device to be read and displayed by the LCD. However, the combination of code and hardware I am using results in occasionally reading 85 C if I heat the device by hand; also, I found that when I depress the button, the loop will sometimes execute
if (digitalRead(13)==0)
multiple times. Sometimes just once, sometimes twice, sometimes 3 times. I'm not sure (other than possible hardware issues) why this is happening.

I've attached the code (temperature1_v3) and eliminated hardare issues (I believe). I've also attached previous working code (temperature1) that operated without these errors but didn't continuously read temperature from a single device (hence temperature1_v3).

Thanks for reading and the possible help!

~Seth

temperature1_v3.ino (3.74 KB)

temperature1.ino (3.79 KB)

pin 13 also has the LED connected, might be a problem cause

furthermore the use of delay() blocks the execution of the code

you might try this variation

void loop(void)
{ 
  Serial.print("Requesting temperatures...");
  sensors.requestTemperatures();
  Serial.println("DONE");
  
  for(int i=0;i<device_count;i++)
    printData(devices[i]);
    
  if (digitalRead(13)==0)
  {
     counter++;
     if (counter>=device_count) counter=0;

     lcd.clear();  
     float tempC = sensors.getTempC(devices[counter]);
     lcd.print(counter);
     lcd.print(" Temp C: ");
     lcd.print(tempC);
     delay(1000); //Do not poll too fast
  }
 
}