// 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 for Device 1 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
On this sitehttp://www.hobbytronics.co.uk/ds18b20-arduino I found some instructions on how to use this sensor with arduino.
When I was uploaded sketch and click on serial monitor I got the 0 for temperature value.
In which direction I have to go to solve this problem?
In attachment you can see the way of connecting my sensor to arduino.
It looks to me like you have your wires around the wrong way
You should have the resistor (start with 4k7, but have a 2k2 ready) between the data pin (looks like the yellow cable) in your setup and the +ve (5v) - if i am following what you have done it looks like you have it between gnd and the data pin
Also post your sketch so we know what you are using
Pull the orange cable out of the negative rail and plug it into the positive rail. I submit you will be well-advised to use the programmes in the Hacktronics tutorial
Thank you very much, Craig also said useful suggestion and now my temperature sensor is operational.
More acceptable skatch for me is this one from link: http://www.hobbytronics.co.uk/ds18b20-arduino.
Thank you both for your help for my first arduino project. Next step is put all these measurements to Nokia 5100 display which is compatible with arduino
I find the Nokia display with white background light excellent but they mostly come with a blue light, which is useless and you might as well leave it disconnected.
When I ordered some parts for beginning with arduino I wasn't know so much details about displays and this one with blue background seemed cool and price also was OK, very cheap. I was tried with connected and disconnected light and concluded that is so difficult to read from display when light is off. If I successful complete mentioned next step with arduino, maybe I will order new display.