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: 40
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: 14085
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.
Signature is on holiday.

User avatar
ptimlin
Posts: 87
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: 423
Joined: Sat Feb 24, 2018 4:09 am

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 607 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: 1181
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: 5893
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: 1181
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: 87
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: 423
Joined: Sat Feb 24, 2018 4:09 am

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: 3951
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: 87
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: 423
Joined: Sat Feb 24, 2018 4:09 am

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.

Return to “Automation, sensing and robotics”