One Wire Digital Temperature Sensor

4 years ago 3567
  • Description
  • Documents
  • BOM
  • Attachments
  • Members
  • Comments


Arduino drives A single wire digital temperature sensor

DS18B20 fromMaxim (formerly Dallas) is a great chip to measure temperature in your project. Fortunately, the Dallas emperature library which makes use of the sensor is easy to Arduino.

In the latest version of the library can be found here

We used version 3.6.0 for this tutorial which can also be downloaded in last

Drag and drop the DallasTemperture folder into my arduino/libraries folder

The DS18B20 can be powered by 5.5V to 3.0V, so you can simply connect the GND pin to the 0V and VDD pins for the +5V from the Arduino. However, DS18B20 can also be extracted from the data line, which means that we only need two wires to connect their power. Which makes it very suitable for use as an external sensor.

Arduino is received from the DQ pin to pin 2 on the board (which can be any Arduino digital pin) Pull it up to 5V a 10k ohm on pull resistor, which is required in the DQ pin Here is our sensor installed on the bread board One Wire Digital Temperature Sensor

Next, add the following sketch and upload it to your Arduino mega 2560. The use of the Dallas temperature library makes it easy to get the temperature.


// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

void setup(void)
  // start serial port
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library

void loop(void)

  Serial.print(" Requesting temperatures...");

  Serial.print("Temperature for Device 1 is: ");

When you have uploaded the sketch, click on the Serial Monitor and you should see output like the following. The temperature is in degrees C

One Wire Digital Temperature Sensor - DS18B20


One Wire Digital Temperature Sensor


ID Name Designator Footprint Quantity
1 Arduino MEGA 2560 U1 DIP 1
2 DS18B20 U2 DS18B20_SOIC 1
3 10k R1 R3 1


Filename Download


The owner does not allow comments in this project now

Comments (0)

如果需要转移工程请在个人中心 - 工程 - 工程高级设置 - 下载工程,下载后在 打开保存即可。
有问题联系QQ 3001956291 不再提醒
svg-battery svg-battery-wifi svg-books svg-more svg-paste svg-pencil svg-plant svg-ruler svg-share svg-user svg-logo-cn svg-double-arrow
We use cookies to offer you a better experience. Detailed information on the use of cookies on this website is provided in our Privacy Policy. By using this site, you consent to the use of our cookies.