Reports.DallasSemiconductorDS18B20DigitalThermometer History

Hide minor edits - Show changes to output

Deleted lines 0-3:
[[ http://deadlylittlepills.com/michael/spring2008.php?page=ds18b20 | Original Posting ]]

----
Added line 21:
* Waterproof version available
Added lines 26-33:
!! Sources

The DS18B20 is available from [[http://www.sparkfun.com/products/245 | Sparkfun]], [[https://www.adafruit.com/products/374 | Adafruit]], among others.

The Waterproof DS18B20 is available from [[http://www.sparkfun.com/products/11050 | Sparkfun]] and [[https://www.adafruit.com/products/381 | Adafruit]].

The High Temperature Waterproof DS18B20 is available from [[https://www.adafruit.com/products/642 | Adafruit]].
Changed lines 36-43 from:
The actual part looks like this:

http://deadlylittlepills.com/michael/spring2008/ds18b20/images/thepart.png"The Part"

And the pin configuration looks like this
:

http://deadlylittlepills.com/michael/spring2008/ds18b20/images/pinassignment.png"Pin Configuration"
to:
The DS18B20 is available in three packages, TO-92, SO, and μSOP.

Pin Outs (from datasheet)
:

http://itp.nyu.edu/physcomp/sensors/uploads/DS18B20Pinout.png
Changed lines 44-47 from:
The following image describes a basic setup in schamatic form. Please note: the capacitor in the schematic as well as the wire linking VCC to GND actually both occur inside the IC and do not need to be setup. You will see this in the next picture.

http://deadlylittlepills.com/michael/spring2008/ds18b20/images/schematic.png"Schematic"
to:
Below is the schematic from the datasheet for wiring the DS18B20 in both parasite power mode and with an external supply.

http://itp.nyu.edu/physcomp/sensors/uploads/DS18B20Schematic.png
Changed lines 50-53 from:
This image is of a very simple circuit using the DS18B20 in parasite power mode with an Arduino microcontroller. Notice that we're only using digital pin 10 to communicate with this chip. Also, note the 4k7ohm pull-up resistor on the dataline. This is what allows us to communicate in both directions on a single wire.

http:
//deadlylittlepills.com/michael/spring2008/ds18b20/images/circuit.png"The Circuit"
to:
This image is of a simple circuit using an externally powered DS18B20 with an Arduino microcontroller (Source: [[http://bildr.org/2011/07/ds18b20-arduino/]]).

http://itp
.nyu.edu/physcomp/sensors/uploads/DS18S20Circuit.png
Changed lines 56-57 from:
The Dallas Temperature Control Library provides an easy-to-use interface for the DS18B20. The library is currently at version 3.7.2 and can be downloaded from [[http://milesburton.com/Dallas_Temperature_Control_Library]].
to:
The Dallas Temperature Control Library provides an easy-to-use interface for the DS18B20. The library is currently at version 3.7.2 and can be downloaded from [[http://milesburton.com/Dallas_Temperature_Control_Library]]. The library also requires the OneWire library: [[http://www.pjrc.com/teensy/td_libs_OneWire.html]]
Changed lines 60-68 from:
The library provides a variety of functions, including searching for sensors attached to a data line, retrieving their address, setting their resolution and retrieving data in either Celsius or Fahrenheit.
to:
The library provides a variety of functions, including searching for sensors attached to a data line, retrieving their address, setting their resolution and retrieving data in either Celsius or Fahrenheit.

!! References

[[http://bildr.org/2011/07/ds18b20-arduino/ | Buildr]]

!! Keywords

Temperature, Thermometer, Hot, Heat, Cold, Cool, Farenheit, Celsius, Degrees, Weather, Environment, Digital
Changed lines 24-25 from:
The datasheet and other information about this chip can be obtained here at maxim-ic.com.
to:
The datasheet and other information about this chip is linked to here: [[http://datasheets.maxim-ic.com/en/ds/DS18B20.pdf]]
Changed lines 48-94 from:
!! Library

There is an Arduino library for version 0008 of the Arduino software, however, it is also apparently compatible with versions above that. I have successfully used it with Arduino 0011. The library is downloadable from this page. Also on that page is some very helpful example code, which is programmed for another chip in the same family but can easily be modified for use with the DS18B20. Use this code as your starting point.

!! Code

There was one thing that I found to be helpful, but isn't going to be completely accurate. When you read the scratchpad on the DS18B20, the temperature reading will come out as 2 bytes (LSB first), and you'll have to turn them into an integer to make them useful.

This bit of code is helpful:

[@
int b2i(byte b[])
{
int i = 0;
i |= b[0] & 0xFF; //MSB
i <<= 8;
i |= b[1] & 0xFF; //LSB
return i;
}
@]

As is this image:

http://deadlylittlepills.com/michael/spring2008/ds18b20/images/scratchpad.png"Scratchpad"

Use the next chart to turn your integer value into a proper temperature reading in your code.

http://deadlylittlepills.com/michael/spring2008/ds18b20/images/temprelationship.png"Temp Chart"

!! Output

When you run the example code, you ought to get some output on your serial port similar to this:

http://deadlylittlepills.com/michael/spring2008/ds18b20/images/output_single.png"Output"

!! Scalability

Here's where the power of the Dallas Semiconductor 1-Wire interface comes into play. Without changing a single line of code, you can (while the code is running, even) add three more DS18B20's like this:


http://deadlylittlepills.com/michael/spring2008/ds18b20/images/threeparts.png"Scalability"

And you should start to see output like this:

http://deadlylittlepills.com/michael/spring2008/ds18b20/images/threeoutput.png"More output"

The search function in the library will perform a scan for all the parts on the bus and return each of their addresses (the 64-bit unique code) so that an arbitrary number of slave devices on the bus can be addressed programmatically.
to:
!! Library & Code Examples

The Dallas Temperature Control Library provides an easy-to-use interface for the DS18B20. The library is currently at version 3.7.2 and can be downloaded from [[http://milesburton.com/Dallas_Temperature_Control_Library]].

Included with the library are a variety of examples including code for reading a single or multiple sensors. Once you have downloaded and installed the library the examples will be available through the Arduino IDE menu via File > Examples > Dallas Temperature Control.

The library provides a variety of functions, including searching for sensors attached to a data line, retrieving their address, setting their resolution and retrieving data in either Celsius or Fahrenheit.
Added lines 46-47:
http://deadlylittlepills.com/michael/spring2008/ds18b20/images/circuit.png"The Circuit"
Changed lines 71-72 from:
Use the chart above to turn your integer value into a proper temperature reading in your code.
to:
http://deadlylittlepills.com/michael/spring2008/ds18b20/images/scratchpad.png"Scratchpad"

Use the next chart to turn your integer value into a proper temperature reading in your code.

http://deadlylittlepills.com/michael/spring2008/ds18b20/images/temprelationship.png"Temp Chart"
Added lines 81-82:
http://deadlylittlepills.com/michael/spring2008/ds18b20/images/output_single.png"Output"
Added lines 87-89:

http://deadlylittlepills.com/michael/spring2008/ds18b20/images/threeparts.png"Scalability"
Added lines 92-93:
http://deadlylittlepills.com/michael/spring2008/ds18b20/images/threeoutput.png"More output"
Added lines 34-35:
http://deadlylittlepills.com/michael/spring2008/ds18b20/images/pinassignment.png"Pin Configuration"
Added lines 40-41:
http://deadlylittlepills.com/michael/spring2008/ds18b20/images/schematic.png"Schematic"
Added lines 30-31:
http://deadlylittlepills.com/michael/spring2008/ds18b20/images/thepart.png"The Part"
Changed lines 5-6 from:
Features
to:
!! Features
Changed lines 22-23 from:
Datasheet
to:
!! Datasheet
Changed lines 26-27 from:
The Part
to:
!! The Part
Changed lines 32-33 from:
Schematic
to:
!! Schematic
Changed lines 36-37 from:
Circuit
to:
!! Circuit
Changed lines 40-41 from:
Library
to:
!! Library
Changed lines 44-45 from:
Code
to:
!! Code
Changed lines 65-66 from:
Output
to:
!! Output
Changed lines 69-70 from:
Scalability
to:
!! Scalability
Changed line 50 from:
[=
to:
[@
Changed lines 59-60 from:
=]
to:
@]
Changed lines 7-21 from:
* Unique 1-Wire (r) interface requires only one port pin for communication
* Each device has a unique 64-bit serial code stored in an onboard ROM
* Multidrop capability simplifies distributed temperature sensing applications
* Requires no external components
* Can be powered from the data line. Power supply range is 3.0V to 5.5V
* Measures temperatures from -55 degrees celsius to +125 degrees celsius (-67 F to +257 F)
* +/-0.5 degrees accuracy from -10 to +85 degrees celsius
* Thermometer resolution
is user-selectable from 9 to 12 bits
* Converts temperature to 12
-bit digital word in 750ms (max.)
* User-definable non-volatile (NV) alarm settings
* Alarm search command identifies and addresses devices whose temperature is outside of programmed limits (temperature alarm condition)
* Available in 8-pin SO (150mil), 8-pin mu-SOP, and 3-pin TO-92 packages
* Software compatible with the DS1822
* Applications include thermostatic controls, industrial systems, consumer products, thermometers, or any thermally sensitive system
to:
* Unique 1-Wire (r) interface requires only one port pin for communication
* Each device has a unique 64-bit serial code stored in an onboard ROM
* Multidrop capability simplifies distributed temperature sensing applications
* Requires no external components
* Can be powered from the data line. Power supply range is 3.0V to 5.5V
* Measures temperatures from -55 degrees celsius to +125 degrees celsius (-67 F to +257 F)
* +/-0.5 degrees accuracy from -10 to +85 degrees celsius
* Thermometer resolution is user-selectable from 9 to 12 bits
* Converts temperature
to 12-bit digital word in 750ms (max.)
* User-definable non-volatile (NV) alarm settings
* Alarm search command identifies and addresses devices whose temperature
is outside of programmed limits (temperature alarm condition)
* Available in 8-pin SO (150mil), 8
-pin mu-SOP, and 3-pin TO-92 packages
* Software compatible with the DS1822
*
Applications include thermostatic controls, industrial systems, consumer products, thermometers, or any thermally sensitive system
Changed lines 1-75 from:
[[ http://deadlylittlepills.com/michael/spring2008.php?page=ds18b20 | Original Posting ]]
to:
[[ http://deadlylittlepills.com/michael/spring2008.php?page=ds18b20 | Original Posting ]]

----

Features

* Unique 1-Wire (r) interface requires only one port pin for communication
* Each device has a unique 64-bit serial code stored in an onboard ROM
* Multidrop capability simplifies distributed temperature sensing applications
* Requires no external components
* Can be powered from the data line. Power supply range is 3.0V to 5.5V
* Measures temperatures from -55 degrees celsius to +125 degrees celsius (-67 F to +257 F)
* +/-0.5 degrees accuracy from -10 to +85 degrees celsius
* Thermometer resolution is user-selectable from 9 to 12 bits
* Converts temperature to 12-bit digital word in 750ms (max.)
* User-definable non-volatile (NV) alarm settings
* Alarm search command identifies and addresses devices whose temperature is outside of programmed limits (temperature alarm condition)
* Available in 8-pin SO (150mil), 8-pin mu-SOP, and 3-pin TO-92 packages
* Software compatible with the DS1822
* Applications include thermostatic controls, industrial systems, consumer products, thermometers, or any thermally sensitive system

Datasheet

The datasheet and other information about this chip can be obtained here at maxim-ic.com.

The Part

The actual part looks like this:

And the pin configuration looks like this:

Schematic

The following image describes a basic setup in schamatic form. Please note: the capacitor in the schematic as well as the wire linking VCC to GND actually both occur inside the IC and do not need to be setup. You will see this in the next picture.

Circuit

This image is of a very simple circuit using the DS18B20 in parasite power mode with an Arduino microcontroller. Notice that we're only using digital pin 10 to communicate with this chip. Also, note the 4k7ohm pull-up resistor on the dataline. This is what allows us to communicate in both directions on a single wire.

Library

There is an Arduino library for version 0008 of the Arduino software, however, it is also apparently compatible with versions above that. I have successfully used it with Arduino 0011. The library is downloadable from this page. Also on that page is some very helpful example code, which is programmed for another chip in the same family but can easily be modified for use with the DS18B20. Use this code as your starting point.

Code

There was one thing that I found to be helpful, but isn't going to be completely accurate. When you read the scratchpad on the DS18B20, the temperature reading will come out as 2 bytes (LSB first), and you'll have to turn them into an integer to make them useful.

This bit of code is helpful:

[=
int b2i(byte b[])
{
int i = 0;
i |= b[0] & 0xFF; //MSB
i <<= 8;
i |= b[1] & 0xFF; //LSB
return i;
}
=]

As is this image:

Use the chart above to turn your integer value into a proper temperature reading in your code.

Output

When you run the example code, you ought to get some output on your serial port similar to this:

Scalability

Here's where the power of the Dallas Semiconductor 1-Wire interface comes into play. Without changing a single line of code, you can (while the code is running, even) add three more DS18B20's like this:

And you should start to see output like this:

The search function in the library will perform a scan for all the parts on the bus and return each of their addresses (the 64-bit unique code) so that an arbitrary number of slave devices on the bus can be addressed programmatically.
Added line 1:
[[ http://deadlylittlepills.com/michael/spring2008.php?page=ds18b20 | Original Posting ]]