Introduction
The DS18B20 is a 1-Wire digital temperature sensor from Maxim IC. It reports the temperature in degrees Celsius with 9 to 12-bit precision, with a range from -55 to 125 (+/-0.5). Each temperature sensor has a unique 64-Bit serial number etched into the silicon which allows for a huge number of sensors to be used on one data bus with the probability of 9,223,372,036,854,775,807 to 1 that any two will clash!
Features
- Unique 1-Wire interface that requires only one port pin for communication.
- Each device has a unique 64-bit serial code stored in an onboard ROM, as mentioned above.
- Requires no external components.
- Can be powered from it’s data line.
- Power supply range is from 3.0V to 5.5V.
- Measures temperatures from –55°C to +125°C (–67°F to +257°F) with ±0.5°C accuracy from –10°C to +85°C.
- Thermometer resolution is user-selectable from 9 to 12 bits.
- Converts temperature to 12-bit digital word in a maximum time of 750ms.
- Alarm search command which allows it to identify and addresses devices whose temperature is outside of programmed limits (temperature alarm condition).
- Applications include thermostatic controls, industrial systems, consumer products, thermometers, or any thermally sensitive system.
What you need to make a working thermometer
To construct an electronic thermometer you will need the following:
- A microcontroller. (In this instance an Arduino or Atmega328p)
- A DS18B20 sensor and a 4.7k resistor.
- Breadboard.
- Jumper leads.
Libraries
You will need to download and install 2 libraries for this exercise. If you are using the arduino then this should be fairly straight forward and can be acheived by following the menus within the IDE. The two libraries that you will need are:
- 1-wire bus
- Dallas Temperature
Build the simple circuit
To read the data from DS18B20 in the serial monitor of the Arduino IDE, build the circuit in the above schematic.
Connect the sensor pins to the Arduino in the following order: pin 1 to GND; pin 2 to any digital pin (pin 2 in this case); pin 3 to +5V or +3.3V. Connect the pull-up resistor between the Vcc supply and the data wire.
Code
1 | // First we include the libraries |
Place the above code into the IDE and upload via the arduino uploader. If everything is okay you should see the temperature being measured and showed in the serial monitor of the IDE.