DS18B20 gives me only one negative value

I'm doing an Arduino project where I want to use 2 DS18B20 probes (they are the probes with the cable). If I have the opportunity I also attach the photos of the connection.
I tried to put both 10k and zero resistors on Vcc and Pin but it doesn't work anyway
I put the code below that I found on the internet to see if Arduino detects DS18B20 probes, but to me it detects nothing; there he is:


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

// Data wire is plugged into digital pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire device
OneWire oneWire(ONE_WIRE_BUS);

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

int deviceCount = 0;
float tempC;

void setup(void)
{
sensors.begin(); // Start up the library
Serial.begin(9600);

// locate devices on the bus
Serial.print("Locating devices...");
Serial.print("Found ");
deviceCount = sensors.getDeviceCount();
Serial.print(deviceCount, DEC);
Serial.println(" devices.");
Serial.println("");
}

void loop(void)
{
// Send command to all the sensors for temperature conversion
sensors.requestTemperatures();

// Display temperature from each sensor
for (int i = 0; i < deviceCount; i++)
{
Serial.print("Sensor ");
Serial.print(i+1);
Serial.print(" : ");
tempC = sensors.getTempCByIndex(i);
Serial.print(tempC);
Serial.print((char)176);//shows degrees character
Serial.print("C | ");
Serial.print(DallasTemperature::toFahrenheit(tempC));
Serial.print((char)176);//shows degrees character
Serial.println("F");
}

Serial.println("");
delay(1000);
}


It doesn't give me any loading problems, just the problem of negative values.
Thanks for your attention and have a nice day

Is it cold where you are?

What are the values?

aahahah it gets very cold, there are about -127 ° C according to my probes

Photo with schematic seems missing.

Post here raw data OneWire lib returns. Perhaps DallasTemperature lib version you use have some problem with parsing raw data or conversion. I do not use DallasTemperature lib, but parsing from raw data and it show about -5C outside and 20C inside, which is correct.

Check the datasheet of DS18B20. It is enough to use only 4.7K resistor.

Is it parasitic configuration or provides external voltage to the sensor?

Here is the picture of my scheme, but I have an Arduino nano and no resistance at the moment.
(https://4.bp.blogspot.com/-DwURqVJ-BVA/VjywpkdRBoI/AAAAAAAAEbc/NL06glbSqh0/s1600/Connections-between-Arduino-and-Multiple-DS18B20-Digital-Temperature-Sensor.jpg)
What version of library are you using?
I don't understand what you mean if it is a parasitic configuration or supplies external voltage to the sensor

I have 2 DS18B20 sensors connected as in the linked diagram and running the code from the original post. This is with a 10K external pullup on pin 2. Seems to work just fine.

Locating devices...Found 2 devices.

Sensor 1 : 85.00⸮C  |  185.00⸮F
Sensor 2 : 85.00⸮C  |  185.00⸮F

Sensor 1 : 24.81⸮C  |  76.66⸮F
Sensor 2 : 24.56⸮C  |  76.21⸮F

Sensor 1 : 24.81⸮C  |  76.66⸮F
Sensor 2 : 24.56⸮C  |  76.21⸮F

Sensor 1 : 24.81⸮C  |  76.66⸮F
Sensor 2 : 24.50⸮C  |  76.10⸮F

So, it would seem, that you have wiring problem or bad component(s).

A photo of the wiring of your setup may be helpful.

Parasitic configuration do not require external power, except that minor power received through data pin and 4.7K pull up resistor. Resistor is mandatory.

Check page 7 of the datasheet
https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf

I use only OneWire lib and manually calculate values from raw data. I may send you if you want to compare results.

groundFungus:
I have 2 DS18B20 sensors connected as in the linked diagram and running the code from the original post. This is with a 10K external pullup on pin 2. Seems to work just fine.

Locating devices...Found 2 devices.

Sensor 1 : 85.00⸮C  |  185.00⸮F
Sensor 2 : 85.00⸮C  |  185.00⸮F

Sensor 1 : 24.81⸮C  |  76.66⸮F
Sensor 2 : 24.56⸮C  |  76.21⸮F

Sensor 1 : 24.81⸮C  |  76.66⸮F
Sensor 2 : 24.56⸮C  |  76.21⸮F

Sensor 1 : 24.81⸮C  |  76.66⸮F
Sensor 2 : 24.50⸮C  |  76.10⸮F




So, it would seem, that you have wiring problem or bad component(s).

A photo of the wiring of **[u]your[/u]** setup may be helpful.

Ah OK. I will try to weld better than what I did. I will also put a 10k resistor on pin 2.
If it doesn't work, I get angry. Thanks again and good evening
The fotp weighs more than 2 M

-127C is an error value. It means the communication to the sensor was disrupted. That might be just random interference in one out of a hundred readings or it might be a wiring fault, which will make all readings errors.

1 Like

I used a 10K resistor to duplicate the setup in your original post to test that setup. I suggest that you use the recommended 4.7K resistor.

-127 means no connection. You can put that down to slack-arsed wiring (which includes the resistor). I doubt that changing the resistor from 10k to 4k7 will save you, but do it anyway, and the real problem is probably close by.

I have fixed and improved the welds, but it still doesn't work !!!!!!!!

You have said something that you didn't had a resistor?

Something is probably fried - sensor itself or the arduino pin. Try parasitic configuration and other arduino pin. If that doesn't give sense value, nothing but other parts can help.

Try as well to read raw data using OneWire lib.

The photos show a lot of other wiring. Have you tried the sensors one at a time by themselves? Can you measure the voltage that is being supplied to the sensors (at the solder joints shown)?

The pictures are a meaningless rat's nest, 99% of which is about something else, and neither show the connections that matter. You should confine yourself to the real problem of the moment, get rid of all that other stuff, and connect the sensors direct to Arduino. At least then you can prove you are OK with them. Breadboards are not famous for reliability, particularly those cheapo ones. It is most unlikey that you have done any damage to anything, and stay away from parasite power. The sensors can take a lot of abuse, trust me on this, but just check to see if they are seriously hot. If they are, disconnect power immediately, as the polarity can be wrong.

Since you have a soldering iron, you might consider making a proto shield with decent screw up terminals - after you have solved this.....