Do I need a resistor for this?

Hello everyone, I'm new to the board and Arduino, glad to be here :slight_smile:

I set up a thermistor based (a onewire, DS18B20 by seeed) temperature reading sketch by following these instructions, mostly: http://www.hobbytronics.co.uk/ds18b20-arduino

Here's the image of the setup:

Green is 5v, black is ground, orange is sensor. If I'm understanding the diagram right, power goes through green, then the resistor, into the thermistor.

My program works but it took some fiddling. I basically forgot the resistor entirely. It still works though. I understand that a resistor prevents your LED from burning out, can a temperature sensor burn out if the resistor is not used? Is that what the resistor here is supposed to be doing?

Thank you!

You need the pull up resistor for the chip to communicate - it pulls down against
it to talk back to you. Omit the resistor and nothing much will happen in normal mode,
but you have the sensor in parasite power mode, where the microcontroller can pull the
data line up as well as down (to provide power), but the resistor is still needed for
communication. (the microcontroller has the data line as an input when its listening
for responses, which is when the pull-up is useful)

(you should ensure the code/library talking to the sensor is driving it in parasite mode too)

The resistor is necessary to pull the data line high. This is how all Onewire devices work. It will not work without it, although I think you will not destroy anything if you omit the resistor or replace it with a jumper cable

MarkT:
You need the pull up resistor for the chip to communicate - it pulls down against
it to talk back to you. Omit the resistor and nothing much will happen in normal mode,
but you have the sensor in parasite power mode, where the microcontroller can pull the
data line up as well as down (to provide power), but the resistor is still needed for
communication. (the microcontroller has the data line as an input when its listening
for responses, which is when the pull-up is useful)

(you should ensure the code/library talking to the sensor is driving it in parasite mode too)

olf2012:
The resistor is necessary to pull the data line high. This is how all Onewire devices work. It will not work without it, although I think you will not destroy anything if you omit the resistor or replace it with a jumper cable

Thank you guys but the weird thing is that I am getting accurate temperature measurements without the resistor plugged in.

you may be lucky if you use the ATmega's internal pullup resistor, but this is not a reliable solution

olf2012:
you may be lucky if you use the ATmega's internal pullup resistor, but this is not a reliable solution

Why not? Also, my thermistor has three wires and not what internet images suggest to me is the typical two wires.

The DS18B20 has three pins: GND, VDD (power supply) and DQ (data). If you connect VDD to GND, you can use two wires from the sensor to the micro controller. The sensor will then "suck" its energy out of the data line. This is called "parasite power" in Onewire terminology. In this case the correct resistor is mandatory.
If you do provide "real" power to VDD, the data line is only transmitting data and, as I said, you may get away with an incorrect resistor value. But this is like talking over a noisy telephone line. You may understand each other but not always.

Just because something works, it's not always best practice and you should correct the error. I think olf2012's analogy of a telephone line is pretty good!

Also, what you have is not a 'thermistor' but an integrated circuit. There is a lot of smarts inside the component - it's not just a resistive element.

// Per.

Hax_Templar:
Why not? Also, my thermistor has three wires and not what internet images suggest to me is the typical two wires.

From the picture in the first post, you're actually using the two wire parasite mode. The +5 V green wire is going to the pullup resistor and is providing power through that resistor. If the sensor were remotely located, the resistor could be at the Arduino end of the network, the brown wire connection would be at the 18S20 end of the network, and only two wires would be needed to connect the endpoints. In the three wire mode the green wire would also be connected to pin 3 (row 8 on your solderless breadboard) and the brown wire between pin 1 and 3 would not be used.

"One wire" is specified to support multiple sensor devices. You might be ok with a single 18S20 and the Arduino internal pullup (~40k Ohms), but not if more devices were added. You also might have problems at temperature extremes without the 4.7k Ohm resistor even though it appears to work well enough at room temperature.