
Reference: RBD-2838
Banner
Module utilizes the popular 1-Wire DS18B20 temperature measurement IC.
(edit with the Customer Reassurance module)
(edit with the Customer Reassurance module)
(edit with the Customer Reassurance module)
The DS18B20 Digital Temperature Sensor Module utilizes the popular 1-Wire DS18B20 temperature measurement IC.
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.
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
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 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) }
Specific References
Your review appreciation cannot be sent
Report comment
Report sent
Your report cannot be sent
Write your review
Review sent
Your review cannot be sent
Reference: RBD-2838
Reference: RBD-0666
Reference: RBD-2918
Reference: RBD-2806
Reference: RBD-2745
Reference: RBD-1942
Reference: RBD-0695
Reference: RBD-2341
Reference: RBD-0687
Reference: RBD-0354
Reference: RBD-0169
Reference: RBD-2329
Reference: RBD-1858
Reference: RBD-1931
Reference: RBD-1367
Reference: RBD-1203
Module utilizes the popular 1-Wire DS18B20 temperature measurement IC.
check_circle
check_circle