0
\$\begingroup\$

I purchased a temperature sensor (DS18B20) for my Arduino uno. It came with a 4.7K resistor. Throughout the tutorials and data sheet I don't see this being used with the temperature sensor. Should I be using this resistor as well?

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Which sensor? Links? \$\endgroup\$
    – Oli Glaser
    Jul 28 '12 at 2:30
  • \$\begingroup\$ It's this one \$\endgroup\$
    – Thong Eric
    Jul 30 '12 at 3:18
  • \$\begingroup\$ @Eric - Next time please provide as much information when you post the question. Then I don't have to spend my time writing answers which, despite being correct, are irrelevant. \$\endgroup\$
    – stevenvh
    Jul 30 '12 at 13:27
6
\$\begingroup\$

You should give more information if you want us to help you properly. You're looking at the parts, we can't see them. You talk about a datasheet, then give us a link to it!

If the temperature sensor has two wires it's probably an NTC thermistor (Negative Temperature Coefficient). That's a resistor whose resistance varies with temperature. You use the other resistor to make a resistor divider:

enter image description here

Connect Vin to the Arduino's 5 V supply. Vout goes to one of the Arduino's analog inputs. As the resistance of the NTC varies Vout will vary as well. For a low NTC resistance the output voltage will move towards Vin, if the NTC's resistance increases the output voltage will decrease.

edit (after you specified the sensor)
Well, that was for an NTC sensor. The DS18B20 you seem to have is an IC which interfaces serially with the Arduino:

enter image description here

Connect VDD to the Arduino's +5 V supply, and the resistor between the 1-wire bus and +5 V (that's the VPU). These are the connections:

enter image description here

Like Oli says it's a bit more complex to use than the NTC I mentioned, and the Arduino Playground page he mentions may help you to get started.

\$\endgroup\$
1
\$\begingroup\$

Okay, the part you have is the DS18B20, which is a digital temperature sensor.
It would have been very useful to have included this information in your original question ;-)
Try and get used to giving all the part numbers/links, and drawing a schematic if relevant.

It uses one-wire interface, which is a communication system designed by Dallas (now Maxim).
The 4.7k resistor is for the 1-wire bus pullup, since it is open drain. This is also mentioned in the description on the product page you linked to ;-)
This means your Arduino pin needs to be set to open drain also.

1-wire can be a bit tricky to get started with, certainly more complex than the passive thermistor described in Steven's answer. However all the relevant info is provided in the datasheet, and there are a few code examples floating around on the web (I probably have some of mine here, if I can find it later I will post a snippet if necessary)
I have used this part a couple of times, and I recall the required timings can be quite tight on a small micro.
I just had a quick look and found this 1-wire library for Arduino, so it looks like you may be saved the effort of writing your own.

If you do have to for whatever reason, read the 1-wire signalling information very carefully, starting on page 15 of the datasheet. Every command starts with a 480us reset pulse from the master (Arduino), to which the sensor "replies" with a presence pulse:

DS18B20 Init

This is a good place to start - write a simple routine that sends the pulse, then turns on an LED if it detects the presence pulse. Or even better, if you have a scope it will come in very handy, you can check the timings are correct easily. Or use the library...

Read the datasheet and try the library or write some code, if you have problems ask again. These are great little sensors.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.