Go Down

Topic: Problem running code using Dallastemperature and OneWire (Read 220 times) previous topic - next topic

some1_tbd

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

robtillaart

#1
Jul 17, 2015, 08:38 pm Last Edit: Jul 17, 2015, 08:45 pm by robtillaart
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
Code: [Select]
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
  }
 
}

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up