List All Products

Advanced Search

Lost Password?
Forgot your username?
No account yet? Register

View Cart/Checkout
Your Cart is currently empty.

Newest Products!

Current Sensor 30 Amp
Current Sensor 30 Amp

Arduino Pro
Arduino Pro

Seeeduino Mega
Seeeduino Mega

Arduino 1-Wire Tutorial


This tutorial has been updated to use version 1.0+ of the Arduino software, and compatible libraries.  Please download the latest version of the Arduino software at this URL: 


This is a new version of our 1-Wire digital temperature sensor tutorial, now with more temperature sensing!

This tutorial will show you how to connect many DS18B20, "1-Wire" temperature sensors to your Arduino board, using only 1 digital IO pin/one cable.


Software code used in this tutorial can be downloaded here:


Arduino ds18b20 Temperature Sensor Sketch 

OneWire Arduino Library

DallasTemperature Arduino Library 



Hardware used in this tutorial:


- DS18B20 Digital Temperature Sensor

- 4.7k Ohm (or so) pullup resistor

- Solderless breadboard

- Some wire jumpers

- Arduino board (Uno, Mega, Duemilanove, etc.)






If this is your first Arduino project, first go through our “Arduino: Getting Started” tutorial.



Use your solderless breadboard to make the connections.  All of the DS18B20 temperature sensors can be connected to the same IO pin:

arduino ds18b20 connection


* You only need one 4.7k pullup resistor for all 1-Wire devices connected to Arduino pin 3

** See the DS18B20 datasheet for the pin diagram, and be very careful. Wiring this part backwards will fry it! You have been warned...




Arduino ds18b20 Temperature Sensor Sketch 

OneWire Arduino Library

DallasTemperature Arduino Library 


Unzip the OneWire and DallasTemperature archives and copy them into your Arduino libraries folder.


For Windows users:


My Documents -> Arduino -> libraries


Mac users:

<home directory> -> Documents -> Arduino -> Libraries


Linux users:

 <home directory>/sketchbook/libraries


Then restart the Arduino software.


Download the Arduino ds18b20 Temperature Sensor Sketch and unzip the folder.

You will now have a folder called “arduino_ds18b20_temperature_sensor”

Load the example program by clicking File->Sketchbook->Open

Navigate to the "arduino_ds18b20_temperature_sensor" folder and select the "arduino_ds18b20_temperature_sensor.pde” file.


Now you need to identify your individual DS18B20 sensors by their serial numbers.  Luckily we have provided a tutorial for you here.


After you include the addresses of your sensors in the sketch, transfer the program to your Arduino by clicking the “Upload to I/O board” button. After uploading, open the Arduino serial monitor by clicking Tools->Serial Monitor.


You should see something like:


arduino ds18b20 temperature sensor


Here is the code:


//  This Arduino sketch reads DS18B20 "1-Wire" digital
//  temperature sensors.
//  Copyright (c) 2010 Mark McComb, hacktronics LLC
//  License: (Go crazy)
//  Tutorial:

#include <OneWire.h>
#include <DallasTemperature.h>

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

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// Assign the unique addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:

DeviceAddress insideThermometer = { 0x28, 0x94, 0xE2, 0xDF, 0x02, 0x00, 0x00, 0xFE };
DeviceAddress outsideThermometer = { 0x28, 0x6B, 0xDF, 0xDF, 0x02, 0x00, 0x00, 0xC0 };
DeviceAddress dogHouseThermometer = { 0x28, 0x59, 0xBE, 0xDF, 0x02, 0x00, 0x00, 0x9F };

void setup(void)
  // start serial port
  // Start up the library
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(insideThermometer, 10);
  sensors.setResolution(outsideThermometer, 10);
  sensors.setResolution(dogHouseThermometer, 10);

void printTemperature(DeviceAddress deviceAddress)
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");
    Serial.print(" F: ");

void loop(void)
  Serial.print("Getting temperatures...\n\r");
  Serial.print("Inside temperature is: ");
  Serial.print("Outside temperature is: ");
  Serial.print("Dog House temperature is: ");


Happy hacking.

Email feedback on this tutorial to This e-mail address is being protected from spambots. You need JavaScript enabled to view it