OneWire DS18b20, how to wire to Fez panda 2?

I just got my sensors in and I am all excited to try them out and then I realized “I don’t know enough about electronics to understand the jargon!”

Going from this (GHI Electronics – Where Hardware Meets Software) I know I need a 1k (ohm?) resistor (which I have).

but then reading this

[quote]The bus master needs an open drain pin with a pull up resistor. Do nto worry about this as GHI take care fo the “open drain” configuration on any of the processor pins. All you need to do is add a pull up resistor, a 1K reistor is recommended.[/quote] I realize I don’t know what “Open Drain” means, nor what “Pull Up resistor” actually means. So I found this (nekhbet.ro) (for arduino) article which has a nice schematic. This schematic appears to have (what I am only guessing at) an “open drain” which apparently I do not need to setup.

So, do i just stick my resistor on DI9 and hook that to Pin2 or Pin3 (of the DS18B20), then hook Pin 1 (P1, on the DS18b20) to ground. What do i do with the 3rd pin?

No need for third pin. These amazing sensors work with power coming from data pin!

so, pin1 = ground, pin2 = resistor then Digital pin on panda?

If that is what the sensor data sheet says. I do not remember the pinout :slight_smile:

There’s two ways to do it. You can do it in parasitic mode, where the data pin actually powers the device, or you can do it in “normal” mode where the device has a separate power supply.

How you wire it depends on which mode you’re using, and the code is different, because in parasitic mode you have to hold the bus high while it’s doing the temperature conversion (to keep the power on).

Decide which mode you’ll use, and wire it up according to the datasheet. It gives sample schematics for each configuration. For my projects, I’ve always used powered mode, because it’s simpler (and faster).

So I don’t have any constraints on space so I believe I want to do the “normal” powering of the sensor. Reading the document for it (http://datasheets.maxim-ic.com/en/ds/DS18B20.pdf) and looking at figure 5, I am fairly confident that what I was doing last night was just wrong (hopefully I didn’t damage anything).

(Just for FYI I had Pin.DI28 hooked up to 1K Resistor, which was then hooked up to the DQ pin on the sensor. I had ground on the board hooked to ground on the sensor. This didn’t work.)

So I think, and PLEASE correct me where I am wrong, that I need hook
[ulist]Ground to ground
5v from board to Vdd on the sensor
DQ directly up to Pin.DI28.
[/ulist]
[ol]How do I know how much voltage the chip uses?
How do I hook up that resistor?
Do i need a different resistor?[/ol]

You’re most of the way there. DQ goes to your digital pin (Di28 is great, as is any other pin, OneWire functions on any digital pin). Ground goes to ground, Vdd can be either 3.3v or 5v (or anything in between… OneWire devices are quite flexible. The only thing you’re missing is a pullup resistor between Di28 and Vdd. It should be a 4.7k resistor. You can see this in figure 5 between the MCU pin and Vpu, which is the same as Vdd.

Ok, that diagram has the 4.7k resistor going to Vpu (which you say is the same as Vdd) which means that the resistor will be bridging my datawire and my 5v wire? (I don’t understand why I would be doing this, other than it says to).

also with that how does this (from the tutorials page) [quote]The bus master needs an open drain pin with a pull up resistor. Do nto worry about this as GHI take care fo the “open drain” configuration on any of the processor pins. All you need to do is add a pull up resistor, a 1K reistor is recommended.[/quote] affect the wiring?

(sorry if I am asking to many questions, I don’t want to break anything, and I also want to understand a little bit more than is needed)

Right. The pullup resistor makes sure that the 1-Wire bus wire is always logic “high” unless the MCU really, definitely wants it logic “low”.

The actual physical pins on the microcontroller can be configured as open-drain (as opposed to push-pull, the “normal” configuration), and the GHI OneWire library is doing this configuration for you automatically. For a description of open-drain and push-pull, see this: question: push-pull or open-drain mode | Forum for Electronics

I don’t know why the tutorial recommends a 1K pullup resistor. All the information I’ve seen recommends 4.7K, and that’s what I’ve successfully used before.

Sweet! Thanks for that info and the link to the explantion of push-pull/open-drain. That cleared up a lot of confusion for me.

So, the resistor is “pulling up” the current on the dataline. So, i guess if I had 10 more sensors connected I do not need to add more resistors as the data line is already pulled high.

Ill give this correct setup a shot when I get home tonight.

Thanks for your help godefroi.

Hooked everything up the way you described and it all works! And on the very first try too!

thanks for you help.

No problem, glad I could help.