Using a digital temperature sensor DS18B20

Hi. I would like to use a digital temperature sensor on Arduino Uno. I downloaded 2 files "Dallas Temperature and One wire" and added them to the Arduino library. Below is the code am using;

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

// Data wire is plugged into port 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 the device 1 (index 0) is: ");
  Serial.println(sensors.getTempCByIndex(0));  
}

When I run the code, I get the error message below;

C:\Program Files (x86)\Arduino\libraries\DallasTemperature\DallasTemperature.cpp:9:26: fatal error: WConstants.h: No such file or directory

   #include "WConstants.h"

                          ^

compilation terminated.

Error compiling.

Can someone help me resolve this.
Thanks.

Did you use the newest libraries ? If you have downloaded them from "somewhere", you better remove those.

The newest OneWire is in the Library Manager.
Or else here : OneWire Arduino Library, connecting 1-wire devices (DS18S20, etc) to Teensy

There is a Adafruit version of DallasTemperature in the Library Manager.
Or else here : MilesBurton.com

If you have the correct OneWire library, which is very likely, that response suggests the IDE cannot find it. Check that the library is in the right place, i.e. with all the other libraries, and restart the IDE so that it can find it.

Thanks a lot. It worked. I had spend 8 hours straight trying to figure out what was wrong.

Thanks a lot Nick. I worked