Waterproof DS18B20 Digital Temperature Sensor (SKU:DFR0198)
Waterproof DS18B20 Digital Temperature Sensor (SKU:DFR0198)
Contents
1 Introduction
1.1 Specification
2 Sensor Connection
3 Sample Code
4 Additional documentation
Introduction
This is a waterproofed version of the DS18B20 Arduino Temperature sensor. Handy for when you
need to measure something far away, or in wet conditions. While the sensor is good up to 125 the
cable is jacketed in PVC so we suggest keeping it under 100 . Because they are digital, you don't
get any signal degradation even over long distances! The DS18B20 provides 9 to 12-bit
(configurable) temperature readings over a 1-Wire interface, so that only one wire (and ground)
needs to be connected from a central microprocessor.Usable with 3.0-5.5V systems.
Because each DS18B20 contains a unique silicon serial number, multiple DS18B20s can exist on
the same 1-Wire bus. This allows for placing temperature sensors in many different places.
Applications where this feature is useful include HVAC environmental controls, sensing
temperatures inside buildings,equipment or machinery, and process monitoring and control.
Specification
Sensor Connection
This sensor requires a 4.7K Ohm resistor between the voltage and Signal pin. as seen in the picture
below. Optionally you can use a Plugable Terminal sensor adapter to help in making this connection
secure.
Sample Code
#include <OneWire.h>
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
float temperature = getTemp();
Serial.println(temperature);
float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius
byte data[12];
byte addr[8];
if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -1000;
}
if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return -1000;
}
ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end
ds.reset_search();
return TemperatureSum;
}
Additional documentation
http://www.dfrobot.com/image/data/DFR0198/DFRobot%20DFR0198.zip
https://www.dfrobot.com/wiki/index.php/Waterproof_DS18B20_Digital_Temperature_Sensor_(SKU:DFR0198) 8-15-17