Beginning Arduino: Project 37 – 1-Wire Digital Temperature Sensor

July 27, 2012

So here’s another issue I found in the Beginning Arduino book I mentioned in a previous post. I was trying to work out Project 37, but I kept getting the same temperature reading over and over. After playing around with the code, I found out that the author forgot to add a simple line to the loop() function.

Add the following:

sensors.requestTemperatures();

to the Part 2 code from the book:

void loop()
{
  // print the temperatures
  Serial.print(“Inside Temp: “);
  printTemperature(insideThermometer);
  Serial.print(“Outside Temp: “);
  printTemperature(outsideThermometer);
  Serial.println();
  delay(3000);
}
The code in the book keeps getting the same temperatures from the sensors, but the sensors are never told to get new temperatures. Simple fix that will hopefully save people from tearing their hair out.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: