1. CLICK HERE TO DOWNLOAD OneWire Library.
2. In your Arduino software: Click “Sketch”, then “Include Library”, then “Add .Zip Library….”. Select the OneWire zip file in your download folder.
3. CLICK HERE TO DOWNLOAD Arduino-Temperature-Control-Library-master
4. In your Arduino software: Click “Sketch”, then “Include Library”, then “Add .Zip Library….”. Select the Arduino-Temperature-Control-Library-master zip file in your download folder.
#include <OneWire.h> // First we include the libraries
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2 // Data wire is plugged into pin 2 on the Arduino
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices
DallasTemperature sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature.
void setup(void)
{
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
sensors.begin();
}
void loop(void)
{
Serial.print(" Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperature readings
Serial.println("DONE");
float tempF=sensors.getTempCByIndex(0)*1.8+32;
Serial.print("Temperature is: ");
Serial.println(tempF);
delay(1000);
}