DS18B20 only reading -127 Celsius and -196.6 Fahrenheit

I followed this tutorial DS18B20 Temperature Sensor Arduino Tutorial (4 Examples)

I wired it exactly how they showed and used their exact code(below). I thought maybe it was just a bad connection but i've done just about everything I can to make sure the connections are solid.

Any idea why it's doing this?

Code:

/* DS18B20 1-Wire digital temperature sensor with Arduino example code. More info: https://www.makerguides.com */

// Include the required Arduino libraries:
#include <OneWire.h>
#include <DallasTemperature.h>

// Define to which pin of the Arduino the 1-Wire bus is connected:
#define ONE_WIRE_BUS 2

// Create a new instance of the oneWire class to communicate with any OneWire device:
OneWire oneWire(ONE_WIRE_BUS);

// Pass the oneWire reference to DallasTemperature library:
DallasTemperature sensors(&oneWire);

void setup() {
  // Begin serial communication at a baud rate of 9600:
  Serial.begin(9600);
  // Start up the library:
  sensors.begin();
}

void loop() {
  // Send the command for all devices on the bus to perform a temperature conversion:
  sensors.requestTemperatures();

  // Fetch the temperature in degrees Celsius for device index:
  float tempC = sensors.getTempCByIndex(0); // the index 0 refers to the first device
  // Fetch the temperature in degrees Fahrenheit for device index:
  float tempF = sensors.getTempFByIndex(0);

  // Print the temperature in Celsius in the Serial Monitor:
  Serial.print("Temperature: ");
  Serial.print(tempC);
  Serial.print(" \xC2\xB0"); // shows degree symbol
  Serial.print("C  |  ");

  // Print the temperature in Fahrenheit
  Serial.print(tempF);
  Serial.print(" \xC2\xB0"); // shows degree symbol
  Serial.println("F");

  // Wait 1 second:
  delay(1000);
}

Post clear photos showing your wiring, please.

Good job on properly posting the code in your first post. So many new members do not bother to read the guidelines and we have to waste our time trying to get them to follow the rules.

You are right, it is telling you exactly that, and you are not doing enough to make the DS18B20 connections solid.
This may actually be because your DS18B20 is a fake. There are a lot of them about.
If the sensor is in a waterproof can, I imagine it is kosher.

You were correct, I tinned the wires and now it works. Thank you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.