wgfaes
Posts: 4
Joined: Wed May 15, 2019 8:01 am

DS18B20: Influence of supply voltage on temperature

Wed May 15, 2019 8:19 am

Hello,

I am currently configuring a setup where I measure different temperatures with a raspberry pi 3 B+ with a several DS18B20 sensors.
At first, I used 3.3V as Vdd, with a 4K7 resistor between Vdd and data-line.
Since the cables can become quite long (up to 10m), I am considering of supplying the sensors with 5V (and the same resistor between Vdd and data). According to https://www.raspberrypi.org/forums/view ... hp?t=30359 discussion, this should not be a problem.

When testing the different supply voltage, no problems occur (I can still measure temperature with my python script).
However, the temperature I measure seems dependent on the chosen supply voltage.
In my case, with 3.3V Vdd, the measured temperature is 21.25°C.When I switch it to 5V (2 seconds later), it gives 22.312°C.
And when I switch it back to 3.3V, I immediatly get the original 21.25°C again.

Can anyone please explain me what causes this and which temperature is most correct?


Thanks in advance,

Willem

BespokeTech
Posts: 71
Joined: Thu Apr 04, 2019 8:14 pm

Re: DS18B20: Influence of supply voltage on temperature

Wed May 15, 2019 10:31 am

I would go with 5v myself. To test the accuracy I would use a separate calibrated temperature probe to compare the results. But it depends on what you are trying to achieve and to what accuracy you are trying to measure.

User avatar
rpdom
Posts: 14756
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: DS18B20: Influence of supply voltage on temperature

Wed May 15, 2019 12:15 pm

wgfaes wrote:
Wed May 15, 2019 8:19 am
I am considering of supplying the sensors with 5V (and the same resistor between Vdd and data).
I assume you mean the resistor is still between Vdd 3.3V and data, otherwise you will end up with a dead Pi.

User avatar
ptimlin
Posts: 88
Joined: Tue Jan 08, 2019 7:44 pm

Re: DS18B20: Influence of supply voltage on temperature

Wed May 15, 2019 5:37 pm

To confirm, you are running a three wire system where three separate wires run out to the sensor?
And as rpdom asked, the pull up should remain between 3.3V and your GPIO line regardless if you power the sensor from 3.3V or 5V.
Also is the pull up resistor next to the Pi or next to the sensor? I believe you want the pull up close to the Pi and not the sensors.

But to answer your question, I am not sure why the change in Vdd to the sensor would change the temperature reading.

pfletch101
Posts: 481
Joined: Sat Feb 24, 2018 4:09 am
Location: Illinois, USA

Re: DS18B20: Influence of supply voltage on temperature

Wed May 15, 2019 7:16 pm

ptimlin wrote:
Wed May 15, 2019 5:37 pm
But to answer your question, I am not sure why the change in Vdd to the sensor would change the temperature reading.
Could it be something as simple as heating due to increased power dissipation in the sensor at the higher supply voltage?

wgfaes
Posts: 4
Joined: Wed May 15, 2019 8:01 am

Re: DS18B20: Influence of supply voltage on temperature

Wed May 15, 2019 9:08 pm

Hello all,

Thank you for the quick replies.

To answer rpdom's question:
rpdom wrote:
Wed May 15, 2019 12:15 pm
wgfaes wrote:
Wed May 15, 2019 8:19 am
I am considering of supplying the sensors with 5V (and the same resistor between Vdd and data).
I assume you mean the resistor is still between Vdd 3.3V and data, otherwise you will end up with a dead Pi.
Yes, I did connect the 4K7 resistor between the 5V and the 3.3V. If I interpret your answer correctly, I'm lucky my Pi is not broken? I did something like in the picture I added (the website google links to no longer exists). The resistor was placed closer to the Pi than to the sensor.
rpi.jpg
rpi.jpg (11.5 KiB) Viewed 1374 times

pfletch101 suggested that it could be by interal heating of the sensor due to the higher power. I doubt this is the case, because when I bring it back to 3.3V, the temperature reading drops immediately with 1 degree.

To summarize, I think I am somewhat confused with the whole concept of pull-up resistors. (I also think I might have mixed up Vdd and Vcc?).
It is still not clear to me if and how it is possible to use a 5V supply with the DS18B20 (to overcome the voltage drop over longer wires) and still be able to connect it to the GPIO.


Thanks again,

Willem

PhatFil
Posts: 1309
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: DS18B20: Influence of supply voltage on temperature

Wed May 15, 2019 9:37 pm

Use either a voltage divider or a Logic Level Converter circuit, to drop the 5v signal to 3.3v before the pi gpio pin connection.

https://learn.sparkfun.com/tutorials/vo ... viders/all

https://www.sparkfun.com/products/12009

(sparkfun must have paid google recently.. i just linked the top of a quick search. There are other makers and suppliers..
.)


akaik vcc and vdd are synonymous and both refer to 'device power in'

another factor that can affect ds18b20 accuracy is Not allowing sufficient time between readings for the sensor to 'fully charge' iirc 750ms should be the minimum break between readings and polling a sensor more rapidly will result in doubtful wide readings.
Last edited by PhatFil on Wed May 15, 2019 11:19 pm, edited 1 time in total.

pcmanbob
Posts: 6440
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: DS18B20: Influence of supply voltage on temperature

Wed May 15, 2019 10:53 pm

If you want to power your DS18B20 from 5V then you need to keep the 3.3v connected to the data line via the 4.7K pull up resistor

like this

Image

this way its safe to use on the pi gpio.
PhatFil wrote:
Wed May 15, 2019 9:37 pm
Use either a voltage divider or a Logic Level Converter circuit, to drop the 5v signal to 3.3v before the pi gpio pin connection.
No voltage divider of level shifter required because pull up is still 3.3V
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

PhatFil
Posts: 1309
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: DS18B20: Influence of supply voltage on temperature

Wed May 15, 2019 11:21 pm

pcmanbob wrote:
Wed May 15, 2019 10:53 pm
PhatFil wrote:
Wed May 15, 2019 9:37 pm
Use either a voltage divider or a Logic Level Converter circuit, to drop the 5v signal to 3.3v before the pi gpio pin connection.
No voltage divider of level shifter required because pull up is still 3.3V
Thanks for the correction.. I edited the offending post to strike through the misinformation

wgfaes
Posts: 4
Joined: Wed May 15, 2019 8:01 am

Re: DS18B20: Influence of supply voltage on temperature

Thu May 16, 2019 9:11 am

Hello,

Thanks for the clarification. That solves the question for me.
I'm gonna test it when I get home tonight.

Willem

wgfaes
Posts: 4
Joined: Wed May 15, 2019 8:01 am

Re: DS18B20: Influence of supply voltage on temperature

Thu May 16, 2019 4:55 pm

Hello again,

I just tested the connection as suggested by pcmanbob.
The sensors works and my Pi doens't break.

However, when I switch Vcc between 3V3 and 5V, reading immediately changes with approximately 1 degree (higher on 5V).
It would surprise me if it was because of the internal heating of the sensor, since it happens every time in less then a second.

Anyhow, I can use the sensor safely on 5V and an accuracy of +-1°C is good enough, so I doesn't really matter to me (just curious).
Thanks for the input!

Willem

User avatar
ptimlin
Posts: 88
Joined: Tue Jan 08, 2019 7:44 pm

Re: DS18B20: Influence of supply voltage on temperature

Sat May 18, 2019 6:18 pm

pfletch101 wrote:
Wed May 15, 2019 7:16 pm
ptimlin wrote:
Wed May 15, 2019 5:37 pm
But to answer your question, I am not sure why the change in Vdd to the sensor would change the temperature reading.
Could it be something as simple as heating due to increased power dissipation in the sensor at the higher supply voltage?
Scrubbing the data sheet for the sensor, there is nothing to indicate (tables, graphs, etc.) that the sensor's temperature measurement would be effected by the supply voltage used. I would think if this were the case, then the datasheet would clearly indicate this.

pfletch101
Posts: 481
Joined: Sat Feb 24, 2018 4:09 am
Location: Illinois, USA

Re: DS18B20: Influence of supply voltage on temperature

Sat May 18, 2019 7:12 pm

ptimlin wrote:
Sat May 18, 2019 6:18 pm
pfletch101 wrote:
Wed May 15, 2019 7:16 pm
ptimlin wrote:
Wed May 15, 2019 5:37 pm
But to answer your question, I am not sure why the change in Vdd to the sensor would change the temperature reading.
Could it be something as simple as heating due to increased power dissipation in the sensor at the higher supply voltage?
Scrubbing the data sheet for the sensor, there is nothing to indicate (tables, graphs, etc.) that the sensor's temperature measurement would be effected by the supply voltage used. I would think if this were the case, then the datasheet would clearly indicate this.
Not necessarily! I was not suggesting that the relationship between the actual temperature of the sensor and the returned result was affected by the supply voltage - this would certainly need to be documented in the datasheet. What I was suggesting (though I didn't and don't a priori think it terribly likely) was that the almost certainly increased 'wasted' current flow with increased supply voltage through the circuitry around the sensor was heating it up, so that it was correctly reading a higher temperature.

User avatar
bensimmo
Posts: 4127
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: DS18B20: Influence of supply voltage on temperature

Sat May 18, 2019 7:32 pm

What is the supply voltage (on both) after the cable drop?

It needs over 3.0V iirc (check spec and up to 5.5V) on the Vdd
And, but please do check, something like at minimum of 0.3V difference for the pulse?
I doubt it would return a result of it wasn't, you'd just get ghost sensors?

5.0V is not 'must have' voltage.

Even drift at the highest voltage was less than the error I'm the reading over a of thousands hours.

The question is, does anyone else see this?

As a side, I run mine of 3V3, through some strip board and use the long waterproof sensors.

User avatar
ptimlin
Posts: 88
Joined: Tue Jan 08, 2019 7:44 pm

Re: DS18B20: Influence of supply voltage on temperature

Mon May 20, 2019 7:08 pm

pfletch101 wrote:
Sat May 18, 2019 7:12 pm
that the almost certainly increased 'wasted' current flow with increased supply voltage through the circuitry around the sensor was heating it up, so that it was correctly reading a higher temperature.
I still don't think so. These sensors have been around for decades, long before Raspberry Pis existed and also very popular with previous hobbyist micro-controllers and boards (Microchip PIC, Atmel AVRs, and a slew of others) so they have been very well used in the field for a longgggg time. I would think that if running these at different voltages within the supply specification caused an actual temperature change in the sensor it would be well documented. But searching back when this was first posted here, I could not find any references to temperature reading being affected by different supply voltages.

pfletch101
Posts: 481
Joined: Sat Feb 24, 2018 4:09 am
Location: Illinois, USA

Re: DS18B20: Influence of supply voltage on temperature

Mon May 20, 2019 7:25 pm

ptimlin wrote:
Mon May 20, 2019 7:08 pm
pfletch101 wrote:
Sat May 18, 2019 7:12 pm
that the almost certainly increased 'wasted' current flow with increased supply voltage through the circuitry around the sensor was heating it up, so that it was correctly reading a higher temperature.
I still don't think so. These sensors have been around for decades, long before Raspberry Pis existed and also very popular with previous hobbyist micro-controllers and boards (Microchip PIC, Atmel AVRs, and a slew of others) so they have been very well used in the field for a longgggg time. I would think that if running these at different voltages within the supply specification caused an actual temperature change in the sensor it would be well documented. But searching back when this was first posted here, I could not find any references to temperature reading being affected by different supply voltages.
I didn't say it was likely, and it is probably ruled out by the speed of response to the voltage change, and I also don't want to beat a dead horse, but people mostly use a single supply voltage, rather than switching voltages. The observed difference was small enough that it might be written off to device variation if you didn't actually record the measurements at two different supply voltages.

Electronique
Posts: 3
Joined: Tue Jun 25, 2019 6:52 pm

Re: DS18B20: Influence of supply voltage on temperature

Tue Jun 25, 2019 7:13 pm

I have the same problem. I have 2 much older DS18B20 devices and these operate totally independently of the supply voltage. But the most recent batch of 5 devices I bought all exhibit an immediate change to a higher reading when supplied from 5v compared with the reading at 3v3.
I originally noticed it when moving the devices from a pi at 3v3 to an arduino at 5v. I can get an acceptable reading on the arduino by putting 3 diodes in series in the supply to the DS18B20 to drop the volts to about 3v3.

According to the data sheet this should not happen. There is also a very good graph in an FAQ on the Maxim (Dallas) website that shows the device is supposed to be very tight on the temperature being independent of supply voltage. Logically this has to be true to achieve the claimed 0.5degC accuracy across the main temperature range.

I suspect that my new devices are counterfeit but can't find any info on case markings or valid serial numbers etc.

By the way the sensor measures the temperature of the 0v leg so it entirely plausible that a higher supply causes a greater current and therefore heating of the 0v leg but this has almost negligible effect on my original devices.

For info: If I short out some of my series diodes these are the instant results:

Code: Select all

Diodes  Volts@Sensor  Temperature degC
0            5.0                      22.94
1            4.5                      22.69
2            3.9                      22.25
3            3.3                      21.44

Brandon92
Posts: 773
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: DS18B20: Influence of supply voltage on temperature

Mon Jul 01, 2019 5:47 pm

If the parts are fake this could indeed be a problem.

Maybe it is something like this:
  • Your start up the DS18B20 at 5V
  • The DS18B20 goes on, and set some (internal) registers correct according to the power supply voltage. (self calibration at start up?). And the DS18B20 assume that that voltage stays the same. And does not change that "reference".
  • You change the supply voltage of the DS18B20, but it will think it is still connected to 5V
  • The reading are not what you would expect.

Electronique
Posts: 3
Joined: Tue Jun 25, 2019 6:52 pm

Re: DS18B20: Influence of supply voltage on temperature

Mon Jul 01, 2019 6:13 pm

Nope. Like I said, the same device gives different readings when moved between Pi and Arduino. In this situation the supply voltage is either 3v3 or 5v0 from power up. All five new devices behave this way but the original older two devices can be happily moved between Pi and Arduino and still read correctly. Also the original two work correctly while dynamically changing their supply while they are already operating.

User avatar
omegaman477
Posts: 148
Joined: Tue Feb 28, 2017 1:13 pm
Location: Sydney, Australia

Re: DS18B20: Influence of supply voltage on temperature

Wed Jul 03, 2019 2:15 pm

All temperature sensing projects, I MEAN ALL, should be calibrated against a reliable standard or reference.

Direct read digital sensors have lead the world into a false sense of accuracy. An DS18xxx sensor can be up to +/- 2ºC incorrect on OFFSET.

Regardless of what the sensor tells you, calibrate it at 0C and 100C, and use this calibration offset for all data points.

Most sensors are relatively linear (that is if they they are 4C out at the lower limit they are 4C out at the top). So you need to only correct OFFSET, not SPAN.

Calibrate people, calibrate. Don't be so lazy.

Back in the old days (sigh you remark) you HAD to calibrate. Nothing has changed.
..the only thing worse than a stupid question is a question not asked.

User avatar
IOTON
Posts: 73
Joined: Tue Jul 02, 2019 1:00 pm
Contact: Website

Re: DS18B20: Influence of supply voltage on temperature

Thu Jul 04, 2019 2:38 am

omegaman477 wrote:
Wed Jul 03, 2019 2:15 pm
All temperature sensing projects, I MEAN ALL, should be calibrated against a reliable standard or reference.

Direct read digital sensors have lead the world into a false sense of accuracy. An DS18xxx sensor can be up to +/- 2ºC incorrect on OFFSET.

Regardless of what the sensor tells you, calibrate it at 0C and 100C, and use this calibration offset for all data points.

Most sensors are relatively linear (that is if they they are 4C out at the lower limit they are 4C out at the top). So you need to only correct OFFSET, not SPAN.

Calibrate people, calibrate. Don't be so lazy.

Back in the old days (sigh you remark) you HAD to calibrate. Nothing has changed.

ds18b20 is a quite accurate device, it has only 0.5% temp. error in -30 - +85 temp. range, and 0.2% temp drift.
https://static.chipdip.ru/lib/246/DOC004246203.pdf
page 2

a don't think you can find some more precise in your home to calibrate it.

User avatar
IOTON
Posts: 73
Joined: Tue Jul 02, 2019 1:00 pm
Contact: Website

Re: DS18B20: Influence of supply voltage on temperature

Thu Jul 04, 2019 7:05 am

wgfaes wrote:
Wed May 15, 2019 8:19 am

In my case, with 3.3V Vdd, the measured temperature is 21.25°C.When I switch it to 5V (2 seconds later), it gives 22.312°C.
And when I switch it back to 3.3V, I immediatly get the original 21.25°C again.
Seems like you soldered pullup straight on ds18b20 pins, so you have a small heater near the temperature sensor.

Enough space between the resistor and IC must solve this problem.

Rarely I saw broken sensors with out of spec current consumption. You will need to measure current and compare with specs.

Also, you don't need to power it from 5v, it has no benefits at all.
If you really want 5v data transmission line you will need to use a galvanic isolator (opto or transformer like ADUM from Analog Devices)

Return to “Automation, sensing and robotics”