|
CLASS DOCUMENTS
REPORTS & ASSIGNMENTS
CLASS CONTENT
USING THIS SITE
registered authors login here You are: (logout) For more on PMWiki, see pmwiki.org |
Dallas Semiconductor DS 18 B 20 Digital ThermometerFeatures
DatasheetThe datasheet and other information about this chip can be obtained here at maxim-ic.com. The PartThe actual part looks like this: ![]() And the pin configuration looks like this: ![]() SchematicThe 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. ![]() CircuitThis 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. ![]() LibraryThere 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. CodeThere 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 next chart to turn your integer value into a proper temperature reading in your code. ![]() OutputWhen you run the example code, you ought to get some output on your serial port similar to this: ![]() ScalabilityHere'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. |