DS18B20

Hi all

In advance I would like to that you for any advice you may give me.

I am working with a dev board made by our college, at the moment I am trying to program the temp sensor using the DallasTemperature library and the OneWire library. I seem to be getting feed back to the serial monitor but the temperature seems a little out of whack. I know it is cold in Ireland but -127 is a little to much. I am guessing that in my inexperience I am doing something wrong.

#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>

//Data wire is plugged into pin 0 on the AITduino
#define ONE_WIRE_BUS 0

//Setup a oneWire instance to communicate with any OneWire device (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
LiquidCrystal lcd(14, 12, 2, 4, 7, 8);

DallasTemperature sensors(&oneWire);

void setup() 
{
  lcd.begin(16, 1);  
  Serial.begin(9600);//Start serial port 
  Serial.println("Dallas Temperature IC Control library Demo");
  
  sensors.begin();//Start up the library
}

void loop() 
{  
  temp();//Test temperature sensor
}


void temp()
{
  Serial.print("Requseting Temperature ...");
  sensors.requestTemperatures();
  Serial.println("DONE");
    
  Serial.print("Temperature for device is: ");
  Serial.println(sensors.getTempCByIndex(0));
  delay(5000);
    
}

After reviewing my post I found that I missed the question. With the reading I am getting serial monitor of -127 is this an error message or have I done something wrong in my program ?

-127 is an error message for DEVICE DISCONNECTED. It means the device could not be read. It's usually do to a bad connection or inadequate pullup.

//Data wire is plugged into pin 0 on the AITduino
#define ONE_WIRE_BUS 0

Is there anything else, on Pin 0 of that board, like Serial?

cattledog: -127 is an error message for DEVICE DISCONNECTED. It means the device could not be read. It's usually do to a bad connection or inadequate pullup.

//Data wire is plugged into pin 0 on the AITduino
#define ONE_WIRE_BUS 0

Is there anything else, on Pin 0 of that board, like Serial?

Nothing that I can fined on the schematics. I have moved the temp sensor to pin 7 and now getting right reading. Thanks a million for the input.

killerspec: Nothing that I can fined on the schematics.

You just weren't looking hard enough. The serial monitor shares Pin 0.

Hi, Yes I can agree never put anything on pins 0-1 as these are used for all serial connections including programming.. Unless of course you really don't need them and use a programmer? I think?

Regards

Mel.