Description
The DS18B20 Digital Temperature Sensor Module utilizes the popular 1-Wire DS18B20 temperature measurement IC.
PACKAGE INCLUDES:
- DS18B20 Digital Temperature Sensor Module
KEY FEATURES OF DS18B20 DIGITAL TEMPERATURE SENSOR MODULE:
- -55°C to +85°C temperature measurement range with good accuracy
- 1-wire interface to save on MCU pins
- LED to indicate module communications
- 3.3 and 5V compatible
Communication with the DS18B20 is via the 1-Wire serial interface. There is an LED on the module that flashes when the sensor is communicating with an MCU.
The communication protocol can look daunting when looking at the datasheet, but fortunately most poplar microcontrollers like Arduino have software libraries that make using these devices very straightforward and easy to do.
There are some options which can be programmed when using the device such as choosing between number of bits of resolution vs conversion time, but those can be ignored for establishing basic operation.
Hookup is straightforward. Just supply power, ground and connect the 1-Wire bus pin to a digital pin on the microcontroller. The part is compatible with 3.3 or 5V power.
Module Connections
There is a 3-pin header on the assembly. There are a couple of different labeling schemes used on these modules as the baseboard is used for several different modules.
1 x 3 Header
- ‘-‘ or ‘G’ = Ground
- Center Pin or ‘R‘ = Vcc (3.3 – 5V)
- ‘S’ or ‘Y’ = 1-wire bus. Connects to digital pin on MCU
OUR EVALUATION RESULTS:
This is a basic module that can be used in a number of different applications where temperature measurement is useful such as determining when a cooling fan should be turned on.
We also offer the DS18B20 device in a number of other packages including as a bare IC for designing your own circuits, a waterproof version and others.
The software below implements basic communications with the sensor using the 1-Wire bus protocol and provides a read-out of the sensor output. We use pin 4 in the example, but this can be reassigned to any digital pin.
The program uses the OneWire and DallasTemperature libraries that can be installed from the IDE Library Manger.
This shows an example output from the program.
DS18B20 Digital Temperature Sensor Module Example Program
/* DS18B20 Digital Temperature Sensor Test Basic code to establish communication with the DS18B20 and retrieve temperature measurement data. Requires OneWire and DallasTemperature Libraries */ #include <OneWire.h> #include <DallasTemperature.h> const int ONE_WIRE_BUS = 4; // Define a pin for communicating to the DS18B20 device via the oneWire bus. OneWire oneWireLocal(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with the DS18B20 device DallasTemperature sensorsLocal(&oneWireLocal); // Pass this oneWire reference to DallasTemperature float tempLocal = 0.0; // Variable for holding the temperature returned from the sensor //=============================================================================== // Initialization //=============================================================================== void setup() { Serial.begin (9600); // Set output window comm rate sensorsLocal.begin(); } //=============================================================================== // Main //=============================================================================== void loop() { CheckTemps(); // Call the routine that actually does the work Serial.print("Current Temp: "); // Printout the results Serial.println(tempLocal); delay(1000); } //=============================================================================== // Subroutines //=============================================================================== void CheckTemps() { sensorsLocal.requestTemperatures(); // Send command to get temperature from the DS18B20 // The sensor will return reading from previous request unless a delay is used to give it time to // complete the reading request. If polling every second like we are doing here, the delay can be ignored. delay(100); tempLocal = sensorsLocal.getTempCByIndex(0); // There can be more than one device on this same bus // so we need to use the first index of (0) }
BEFORE THEY ARE SHIPPED, THESE MODULES ARE:
- Inspected
- Basic operation verified
- Packaged in a resealable ESD bag for protection and easy storage.
Notes:
- This module is the same or similar to the KY-001.
- If you experience any communication issues, try adding a 4.7K ohm pull-up resistor on the ‘S’ pin.
Technical Specifications
Communication Interface | 1-Wire | |
Input | Logic High | > 2.2V |
Logic Low | < 0.8V | |
Supply Voltage | Maximum | 5.5V |
Minimum | 3V | |
Temperature | Maximum Range | -55°C to +85°C |
Accuracy (-10°C to 85°C) | +/- 0.5°C | |
Package | SS Encapsulated TO-92 | |
Dimensions | L x W (PCB) | 20 x 15mm (0.8 x 0.6″) |
Datasheet | DS18B20 |