Connect with us

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

Discussion in 'Sensors and Actuators' started by Mahonroy, Jul 11, 2016.

Scroll to continue with content
  1. Mahonroy

    Mahonroy

    61
    2
    Oct 21, 2014
    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!
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    11,449
    2,629
    Nov 17, 2011
    The capacotor won't be much help at the jack. put it right next to the sensor's GND and Vcc pins.
    Unfortunately this means that you'll have to disassemble the armature, add the capacitor, then seal the sensor with shrink tube again and re-connect the jack. Therefore I think this is the last option to test.

    The datasheet recommeds 4.7 kΩ. 2.2 kΩ may be too much of a load for the DS18B20.

    Other than that, check the timing of your software routines. make sure the timing requirements of teh DS18B20 are strictly met.

    By the way: your scope photos are rather fuzzy. use a tripod next time or better yet, use teh hardcopy function of the scope - most digital ones do have that option.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-