Difference between revisions of "DS18B20 Temperature Sensor Module"

From Geeetech Wiki
Jump to: navigation, search
(introduction)
(how to buy)
 
(7 intermediate revisions by the same user not shown)
Line 17: Line 17:
 
==Usage==
 
==Usage==
 
[[File:DS18b20b.jpg]]
 
[[File:DS18b20b.jpg]]
[[File:DS18B20 wiring.jpg]]
+
 
 +
[[File:DS18B20 wiring.jpg|400px]]
  
 
==Document==
 
==Document==
Line 31: Line 32:
 
  }
 
  }
 
  void loop(void) {
 
  void loop(void) {
    // Ask the library whether the device is valid
 
 
     switch(tempSensor.isValid())
 
     switch(tempSensor.isValid())
 
     {
 
     {
 
         case 1:
 
         case 1:
 
             Serial.println("Invalid CRC");
 
             Serial.println("Invalid CRC");
tempSensor.reset(); // Attempts to redetect IC            return;
+
            tempSensor.reset(); // Attempts to redetect IC             
 +
        return;
 
         case 2:
 
         case 2:
 
             Serial.println("Not a valid device");
 
             Serial.println("Not a valid device");
tempSensor.reset(); // Attempts to redetect IC
+
            tempSensor.reset(); // Attempts to redetect IC
      return;
+
        return;
 
     }
 
     }
 
   Serial.print(tempSensor.getTemperature());
 
   Serial.print(tempSensor.getTemperature());
 
   Serial.print("C");
 
   Serial.print("C");
 
   Serial.println();
 
   Serial.println();
   Serial.print(DallasTemperature::toFahrenheit(tempSensor.getTemperature()));  Serial.print("F");
+
   Serial.print(DallasTemperature::toFahrenheit(tempSensor.getTemperature()));  
 +
   Serial.print("F");
 
   Serial.println();
 
   Serial.println();
}
+
}
  
==how to buy==
+
==How to buy==
 
Click here to buy [http://www.geeetech.com/arduino-digital-ds18b20-temperature-sensor-p-17.html DS18B20 Temperature Sensor Module]
 
Click here to buy [http://www.geeetech.com/arduino-digital-ds18b20-temperature-sensor-p-17.html DS18B20 Temperature Sensor Module]

Latest revision as of 10:55, 16 May 2014

introduction

DS18b10a.jpg

This breakout uses the DS18B20 1-Wire digital temperature sensor from Maxim IC. It can Reports degrees C with 9 to 12-bit precision, -55C to 125C (+/-0.5C). Each

sensor has a unique 64-Bit Serial number etched into it - allows for a huge number of sensors to be used on one data bus. This is a wonderful part that is the corner

stone of many data-logging and temperature control projects.

Features

  • 3.0-5.5V input voltage
  • Waterproof
  • -55°C to+125°C temperature range
  • ±0.5°C accuracy from -10°C to +85°C
  • 1 Wire interface

Usage

DS18b20b.jpg

DS18B20 wiring.jpg

Document

DS18b20 library

Example code

#include <DallasTemperature.h>
DallasTemperature tempSensor; // You may instantiate as many copies as you require.
void setup(void) {
 Serial.begin(9600);
 tempSensor.begin(12); // Data wire is plugged into port 12 on the Arduino
 Serial.println("Dallas Temperature IC Control Library 1.0. Miles Burton");
}
void loop(void) {
   switch(tempSensor.isValid())
   {
       case 1:
           Serial.println("Invalid CRC");
           tempSensor.reset(); // Attempts to redetect IC            
       return;
       case 2:
           Serial.println("Not a valid device");
           tempSensor.reset(); // Attempts to redetect IC
       return;
   }
 Serial.print(tempSensor.getTemperature());
 Serial.print("C");
 Serial.println();
 Serial.print(DallasTemperature::toFahrenheit(tempSensor.getTemperature()));   
 Serial.print("F");
 Serial.println();
}

How to buy

Click here to buy DS18B20 Temperature Sensor Module