Unlike the TMP36, which is an analogue sensor, the DS18B20 is a digital device. It looks like a transisor with three legs, a positive, a sensor and a ground connection. Each device has a unique address, so that a number of devices can be connected in parallel with each device able to be read simply by using the correct address. The only other component required is a 4k7 resistor connected between the +ve and the sensor output (for multiple DS18B20’s only the one resistor is required).
Much of the information available on the Internet is quite old and some of the sketches will not compile on the latest IDE. The best library to use seems to be OneWire and it can be downloaded from here. I installed the library in the usual way, restarted the IDE and loaded the sketch from the Examples. It worked perfectly first time and an example of the output is shown below.
The address is shown on the first line, 28 identifies this sensor as a DS18B20 and the next six Hex numbers are the address. The temperature is reported as thousands of a degree, but as the accuracy is only +/- 0.5 degrees even reporting the temperature to two decimal places is a bit over the top.
I made one small change to the example sketch, my sensor came on a small circuit board that has a resistor connected between the +ve and sensor output. I added the following code to the top of the sketch before the ‘void (setup)’ loop.
This assumes that the sensor output is connected to pin 10 and powers the DS18B20 by providing Gnd at pin 9 and 5 volts at pin 11. The image at the top of this post shows how it looks.