DS18B20 Temp Sensor - Working Intermittently & Not Reliable - Took Scope Readings & Could Use Advice

Thread Starter

Mahonroy

Joined Oct 21, 2014
406
Hey guys,
I am using a Particle Photon (microcontroller w/ cloud connectivity) to communicate with a DS18B20 temperature sensor via the 1-wire bus. Below is how I have it wired up:
ds18b20_question0.jpg

From the research I have done, it seems to be preferred that you use 5 volts to power the sensor, then a pullup to 3.3 volts (assuming a 3.3 volt microcontroller). This allows for more reliable data transmission with longer cables. I am using stereo audio jacks for the connectors, and because of this I am using a 220 ohm resistor for protection against momentary shorts while inserting the plug. Here is what the sensor looks like:
ds18b20_question6.jpg

I am pulling sensor data from the sensor approximately every 4 seconds, and I get a LOT of errors throughout the day. There are periods of times where it can go several minutes before getting an error free value. Similarly, it can also go several hours and not have any errors, so its very intermittent. The errors range from "no sensors found" to CRC errors.

I wanted to point out that I have had these intermittent errors even with the wires soldered directly to the board, so because of this I do not believe the problem to be the audio jack. I have also tried multiple sensor combinations with multiple boards and I experience the same thing, so I can only assume its my design.

In an effort to try and diagnose the problem, I busted out the Rigol DS2202a oscilloscope to try and take some readings. I am very new to using oscilloscopes so bare with me.

I first took a look at the data line right next to the microcontroller, and this is what I see:
ds18b20_question1.jpg ds18b20_question2.jpg ds18b20_question3.jpg

So I am thinking this should be acceptable? I don't see rounded off raising edges, but I do notice the falling edge can sometimes droop/spike about 80mV below 0 volts... which I don't think would be a big deal? I also don't see too much noise here.

I then took a look at the 5V power at the jack:
ds18b20_question4.jpg

I noticed that every time the microcontroller would pull data from the sensor, that I would see this voltage drop/spike. It looked pretty significant since it drops down to 3.5 volts momentarily. I put a 0.1uF ceramic capacitor at this location (between 5v power and ground) and it now is flat:
ds18b20_question5.jpg

This alone did not fix the problem, I still noticed it was intermittent. I am now trying to replace the 4.7K pullup resistor to a 2.2K pullup to see if that helps, but it feels like I am missing something?

What do you guys think might be the problem? Thanks and any help is greatly appreciated!
 

David Fowler

Joined Feb 11, 2016
25
I've done exactly what you're doing with the sensor and the jack and haven't come across any problems at all. I can't remember exactly how I put this together so will have to dig out my design when I get home and let you know. :) The only obvious difference is that I'm using a 5v micro controller but I can't see that should be the cause of your issues...
 

twohats

Joined Oct 28, 2015
447
The voltage could be your problem, I use Picaxe, nothing as technical as your project.
No problems with five volts.
What does the data sheet say?
Could you use five volts for your temp. sensor and three point three volts for the brain?
 

Thread Starter

Mahonroy

Joined Oct 21, 2014
406
I've done exactly what you're doing with the sensor and the jack and haven't come across any problems at all. I can't remember exactly how I put this together so will have to dig out my design when I get home and let you know. :) The only obvious difference is that I'm using a 5v micro controller but I can't see that should be the cause of your issues...
Yeah I would definitely be interested, I still can't figure this thing out.

The voltage could be your problem, I use Picaxe, nothing as technical as your project.
No problems with five volts.
What does the data sheet say?
Could you use five volts for your temp. sensor and three point three volts for the brain?
I looked through the datasheet, and I don't see any problems with this. Valid voltages are between 3.0 and 5.5.
 

Thread Starter

Mahonroy

Joined Oct 21, 2014
406
Here is a better view of what the data line looks like right up next to the microcontroller (rising and falling edge):

Note this is 500 nanoseconds window.
ds18b20_question7.jpg

Note this is 200 nanoseconds window.
ds18b20_question8.jpg

Is this acceptable for the data line by the way? I'm still trying to troubleshoot this and am running out of ideas.

If the data line looks good, does that mean it has to be a power problem then?
 
Top