HI there,
Just starting out with the Aduino. Have a basic understanding of C++, and have connected some of the basic senors and things to the pins, but still a noob. Anyways, I have one of these DS18B20 temp sensors, and I have downloaded and installed the One-wire library and the Dallas Instruments library required to get it up and running. I found some code online, which compiled and uploaded fine to the Arduino Uno R3 I am using. In the serial monitor, the feedback, however, is a repetitive:
20:39:03.690 -> Temperature is: -127.00 Requesting temperatures...DONE
20:39:05.453 -> Temperature is: -127.00 Requesting temperatures...DONE
20:39:07.217 -> Temperature is: -127.00 Requesting temperatures...DONE
20:39:08.948 -> Temperature is: -127.00 Requesting temperatures...DONE
It keeps sending the exact same data, weather I dunk the sensor in a hot cup of coffee or an ice-cold cup of kool-aid. I have the data line leading to pin 2, the ground to ground, and the vcc running to the 5v pin. I have about 20 of these sensors, maybe this one's faulty....?
Here i a pic, and the code I am using:
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
void setup(void)
{
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
}
void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
Serial.print(" Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println("DONE");
Serial.print("Temperature is: ");
Serial.print(sensors.getTempCByIndex(0)); // Why "byIndex"?
// You can have more than one IC on the same bus.
// 0 refers to the first IC on the wire
delay(1000);
}