interfacing a 3 pin temperature sensor (HELP!!)

hi I tried wiring up a temperature sensor I found on sparkfun but it doesn't seem to be working. those are the data sheets I keep seeing that on the drawings ground keeps changing place and so does input :|

Im a newbie to hardware... please help with both wiring and code. My current code goes as follows:

int inPin = 11;   // choose the input pin 
int val = 0;     // variable for reading the pin status

void setup() {

  pinMode(inPin, INPUT);    

void loop(){
  val = digitalRead(inPin);  // read input value
  if (val) {         // check if the input is HIGH 

and my wiring connects the first pin to ground the middle pin to port 11 in arduiino which in my code I specified as input pin and my 3rd pin is connect to the 5 V power supply

Thanks in advance


according to the data sheet, the Dallas chip you got puts out data serially: "The DS18S20 communicates over a 1-wire bus that by definition requires only one data line (and ground) for communication with a central microprocessor. "

In the code above you've started the serial port but aren't reading it. The val = digitalRead(inPin) does a straight 0/5V reading of pin 11, not a serial read. Serial reads, in any case, are generally made on the RX (Pin 0).

If you want to read the serial data, see the serial_read examples that come with the Arduino. Unless there is some code kicking around somewhere that you can borrow from, it's probably going to be a bit of work. You'll need to go over the data sheet and figure out what commands are necessary. I am not sure if the 1-wire setup will be compatible with the Arduino. If the DS chip just sends out serial data and doesn't need to receive requests for data, it should work, but form a brief glance of the datasheet, it looks like it needs to talk back and forth on that one wire with the Arduino... Whoa, I feel a headache coming on. You might want to get some Tylenol with your next 1-wire order. Here's a post about possibilites of interfacing to the 1-wire bus... There is also a great page on it here.

But... and it's a big 'but'...if you are new to this, you might want to try something little easier to interface, like the LM34/LM35 temp sensors, which just put out a proportional voltage for temperatures. Personally I would rather be in a cafe than reading datasheets. If this is so, then these are what you want. You just connect them to an analog in pin, ground and +5, and away you go. Many headaches avoided. See this post about the LM34 series sensors.

hope this helps


Thnx man :P that helps