DS18B20 Temperature Sensor
1.01€
100 or more 0.69€
1000 or more 0.50€
- Stock:
- Product Code: SNA007.DS18B20
- Weight: 0.30
DS18B20 Temperature Sensor
The DS18B20 is a digital temperature sensor that provides 9 to 12-bit (configurable) temperature readings over a 1-Wire interface. Here’s detailed information about the DS18B20 sensor:
Features:
- Temperature Range:
- Operating: -55°C to +125°C
- Accuracy:
- ±0.5°C from -10°C to +85°C
- Resolution:
- Configurable from 9 to 12 bits, with the default being 12 bits.
- Interface:
- Uses a 1-Wire interface, which allows multiple sensors to be connected on the same data line.
- Unique 64-Bit Serial Code:
- Each DS18B20 has a unique 64-bit serial code, allowing multiple sensors to be connected and identified on the same 1-Wire bus.
- Power Supply:
- Can be powered by an external power supply (3.0V to 5.5V) or parasitically from the data line.
- Alarm Functionality:
- Programmable alarm triggers for upper and lower temperature limits.
Applications:
- Temperature Measurement: Ideal for monitoring temperatures in a wide range of applications, including HVAC systems, environmental monitoring, and food processing.
- Industrial Automation: Used for precise temperature control in industrial processes.
- Consumer Electronics: Incorporated into home automation systems for climate control.
- Data Logging: Suitable for temperature data logging applications.
Example Circuit:
Here's how you might connect a DS18B20 sensor to an Arduino:
- VDD: Connect to 3.3V or 5V (depending on your Arduino model).
- GND: Connect to ground.
- DQ (Data Line): Connect to a digital pin on the Arduino (e.g., D2) with a 4.7k ohm pull-up resistor between DQ and VDD.
Arduino Sample Code:
You need to install the "OneWire" and "DallasTemperature" libraries in the Arduino IDE to interface with the DS18B20 sensor.
#include
#include
// Data wire is connected to Arduino pin 2
#define ONE_WIRE_BUS 2
// 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);
void setup() {
Serial.begin(9600);
sensors.begin();
}
void loop() {
sensors.requestTemperatures(); // Send the command to get temperatures
// Print the temperature in Celsius
Serial.print("Temperature: ");
Serial.print(sensors.getTempCByIndex(0)); // We only have one sensor, so we use index 0
Serial.println(" °C");
delay(1000); // Wait for a second before taking another reading
}
Explanation:
- Libraries: Include the OneWire and DallasTemperature libraries to communicate with the DS18B20 sensor.
- Pin Definition: Define the digital pin (D2) connected to the DS18B20 data line.
- Setup: Initialize serial communication and the DallasTemperature library.
- Loop: Request temperature readings from the sensor and print the temperature in Celsius to the Serial Monitor every second.
This example demonstrates how to interface the DS18B20 sensor with an Arduino for accurate temperature measurement. Adjust the code and wiring as needed based on your specific setup and requirements.