4LULZ
Posts: 26
Joined: Sat May 07, 2016 1:30 am

Weird readings from DS18B20 temp sensor

Tue Jul 05, 2016 12:22 am

Hi Peeps,

I picked up a couple of waterproof DS18B20 temp sensors from ebay and hooked one up last week to a Pi that logs the temperature in 5 minute intervals also logging temps which are above / below a specific threshold.

Since last week the sensor looks to have been working normally in that the logged temperature matches the thermostat on our heater, but yesterday there was a ~2 hour window where the sensor logged abnormally high temperatures (85C) which couldn't have been accurate. I was at home during the period when these temps were logged, the Pi and sensor were on a desk roughly 1m away from me so I can verify that the temp didn't go above 23C and it's not close to any heat source.

After the system logged an 85C reading, it self corrected after 2 seconds logging a temperature in the 'normal' range (22 - 23C) - this happened seemingly at random on 4 separate occasions last night but has not occurred again since.

Wondering if anyone's seen similar behavior with these sensors or can provide feedback on what might be causing it to log such high readings?

asandford
Posts: 1998
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: Weird readings from DS18B20 temp sensor

Tue Jul 05, 2016 12:53 am

I've had a few DHT sensors monitoring my greenhouse for almost 2 years now, and every one has had a 'funny five minutes' where it goes off the scale for a couple of readings and then returns to normal - they are cheap and I don't expect faultless operation.

A couple of ways to mitigate this are:
Have a few sensors within a small area and take a quorum of the results.
Have a 'rolling average' that tends to smoothe out major blips.

I opted for the latter as it worked better for me.

DirkS
Posts: 10363
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Weird readings from DS18B20 temp sensor

Tue Jul 05, 2016 1:04 am

If the DS18B20 reads 85C it means that there is some sort of communication problem.
(try googling for 'ds18b20 85')
IIRC one strategy is to discard the 85C reading and just try again after a few seconds.

asandford
Posts: 1998
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: Weird readings from DS18B20 temp sensor

Tue Jul 05, 2016 1:10 am

DirkS wrote:If the DS18B20 reads 85C it means that there is some sort of communication problem.
(try googling for 'ds18b20 85')
IIRC one strategy is to discard the 85C reading and just try again after a few seconds.
The part can read up to 125C, so 85C should be a valid reading, not an error condition ( ~0.5C accuracy only to 85C).

DirkS
Posts: 10363
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Weird readings from DS18B20 temp sensor

Tue Jul 05, 2016 1:25 am

asandford wrote:
DirkS wrote:If the DS18B20 reads 85C it means that there is some sort of communication problem.
(try googling for 'ds18b20 85')
IIRC one strategy is to discard the 85C reading and just try again after a few seconds.
The part can read up to 125C, so 85C should be a valid reading, not an error condition ( ~0.5C accuracy only to 85C).
Ok, it's not an error. it's the power on reset value (see same PDF)
*The power-on reset value of the temperature register is +85°C.

asandford
Posts: 1998
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: Weird readings from DS18B20 temp sensor

Tue Jul 05, 2016 1:40 am

DirkS wrote: Ok, it's not an error. it's the power on reset value (see same PDF)
*The power-on reset value of the temperature register is +85°C.
Only read the "front page", I've used these to measure 0C and 100C for calibration. Weird to make a valid reading within tolerance a power on reset reset value.

4LULZ
Posts: 26
Joined: Sat May 07, 2016 1:30 am

Re: Weird readings from DS18B20 temp sensor

Tue Jul 05, 2016 2:00 am

Hope this isn't a silly question since someone was kind enough to link that pdf, but what's causing the power on reset?

The only reference I can find is where the module is running on parasite power, but that's not the case here, all 3 pins are connected (incl pullup resistor between 3.3v and data pin) and I've tested the output of the 3.3v pin and it's spot on...

The only thing I can think at this stage is that I'm using a USB hub to power the pi it rather than a dedicated 5v / 2.2A adapter, but the USB ports on the hub are supposedly rated at 2.2A as well - it was one of the reasons I bought it.

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

Re: Weird readings from DS18B20 temp sensor

Tue Jul 05, 2016 4:17 am

4LULZ wrote:The only thing I can think at this stage is that I'm using a USB hub to power the pi it rather than a dedicated 5v / 2.2A adapter, but the USB ports on the hub are supposedly rated at 2.2A as well - it was one of the reasons I bought it.
Does the red PWR LED go out at any point while the Pi is running (I'm assuming it's a B+ or later model)? That would indicate insufficient power - although the sensor takes very little and even if the 5V supply to the Pi drops, it should still generate a good 3V3 level.

Otherwise, triple check the wiring to the sensor, especially the 3V3 line. A bad connection is the only time I've seen 85 is when a sensor had a bad power connection.

4LULZ
Posts: 26
Joined: Sat May 07, 2016 1:30 am

Re: Weird readings from DS18B20 temp sensor

Tue Jul 05, 2016 5:05 am

rpdom wrote:Does the red PWR LED go out at any point while the Pi is running (I'm assuming it's a B+ or later model)? That would indicate insufficient power - although the sensor takes very little and even if the 5V supply to the Pi drops, it should still generate a good 3V3 level.
It's a Raspberry Pi 3 just to get that out of the way :)

When I've been sitting next to the Pi I've never seen the red light anything other than solid but I am out of the house for a significant proportion of the day so can't confirm during those hours, at least not in any meaningful way. I'll re-check all the connections from the sensor first, maybe go back to a breadboard to eliminate any dodgy connections on my part.

DirkS
Posts: 10363
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Weird readings from DS18B20 temp sensor

Tue Jul 05, 2016 10:33 am

See viewtopic.php?f=63&t=147781&start=50#p972790
AIUI you can see if under-voltage has occurred since last boot

shivajatla
Posts: 1
Joined: Thu Jul 07, 2016 6:32 pm

Re: Weird readings from DS18B20 temp sensor

Thu Jul 07, 2016 7:01 pm

I am a new bee to PI. I want to try connecting a temperature sensor to monitor my room temp and display in a display. Can any one help me in providing the wiring diagram and working code to get the ADC values?

Return to “Interfacing (DSI, CSI, I2C, etc.)”