DS18B20 gives me only one negative value in every temperature . That value is not even close.It is -127 celcius. I also added 4.7K pullup resistor

type or paste code here

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

// GPIO where the DS18B20 is connected to
const int oneWireBus = 4;     

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(oneWireBus);

// Pass our oneWire reference to Dallas Temperature sensor 
DallasTemperature sensors(&oneWire);

void setup() {
  // Start the Serial Monitor
  Serial.begin(115200);
  // Start the DS18B20 sensor
  sensors.begin();
}

void loop() {
  sensors.requestTemperatures(); 
  float temperatureC = sensors.getTempCByIndex(0);
  float temperatureF = sensors.getTempFByIndex(0);
  Serial.print(temperatureC);
  Serial.println("ºC");
  Serial.print(temperatureF);
  Serial.println("ºF");
  delay(500);
}
![20230410_221944|690x310](upload://u9d7YKQ8wJ9GLK1Ro5B28yqvxKM.jpeg)

Never use screenshots as replacements of the source code.
Please read the forum guidelines to see how to properly ask a question and some good information on making a good post. You will get faster and better help if you post all your code as requested by the forum guidelines.

2 Likes

-127 means no connection. Slack wiring. If it gets seriously hot, you have wired it wrong way round. It can survive this. Your code has nothing to do with the problem, and is probably fine.

1 Like

Always show us a good schematic of your proposed circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.

In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.

Use the < CODE / > icon from the ‘posting menu’ to attach the copied sketch.

1 Like

Thank you very much for the info. This is my first post.

But there's nothing much with the wiring. Ground,VCC and another signal transmitiing wire. One 4.7k pull up resistor between the Vcc wire and signal wire... that's all. I also watched several demos

Thank you for the valuable idea.now i showed them as much as i can.

It looks like you made a mistake by marking topic as solved. Please mark it only after you really solved your problem.

Okay.. i got it.. i am new to this platform .. sorry

That's true but meaningless. This is a matter of quality, not quantity, and doesn't alter the fact that you are being told that the sensor is not connected. -127 is not a temperature reading, as you imply, it is an error message and a very clear one. The sensor only works down to -25.

The above presupposes that the sensor is kosher and I submit that the only other option is that it is a fake or a dud. I have never heard of a DS18B20 in a sealed tube being a fake but, if it looks like a transistor, it could actually be a transistor. There have been fakes that have, on close inspection, been found to be actually marked as a transistor.

I guess the strict interpretation of "-127" is
"No DS18B20 connected"

They actually work down to -55°C,.

If you take them below -55°C, or above +125°C, then they will also display the same ' -127' as an error message. Clearly in this case it is the 'not connected' that is being indicated.

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