
In Stock
Price: KSH 300.00
DS18B20 Temperature Sensor
The DS18B20 is a popular digital temperature sensor that uses a 1-wire interface to communicate with microcontrollers like Arduino and Raspberry Pi. It provides precise temperature measurements, ranging from -55°C to +125°C, with a resolution of 9 to 12 bits. This sensor is widely used in applications that require accurate and reliable temperature readings, such as weather stations, home automation, and industrial monitoring systems.
Specifications
- Operating Temperature Range: -55°C to +125°C
- Accuracy: ±0.5°C (from -10°C to +85°C)
- Resolution: 9 to 12 bits (configurable)
- Communication Protocol: 1-Wire
- Supply Voltage: 3.0V to 5.5V
- Output Type: Digital
- Size: TO-92 Package
Pinout
The DS18B20 sensor has three pins for connection:
- Pin 1: Ground (GND)
- Pin 2: Data (DQ) - This is the 1-Wire communication pin
- Pin 3: Power (VCC) - This pin is used to supply power to the sensor (3.0V to 5.5V)
Applications
The DS18B20 is ideal for various temperature-sensing applications:
- Weather Stations: Monitor outdoor and indoor temperature.
- Home Automation: Control heating, ventilation, and air conditioning (HVAC) systems based on temperature.
- Industrial Monitoring: Track temperatures of machines or environments in factories or data centers.
- Battery-Powered Devices: The low power consumption makes it perfect for battery-operated systems.
Key Features
- High Precision: Measures temperature with an accuracy of ±0.5°C between -10°C and +85°C.
- 1-Wire Interface: Allows multiple DS18B20 sensors to be connected on the same data line, making it easy to expand systems.
- Wide Voltage Range: Can operate with a voltage supply of 3.0V to 5.5V.
- Compact Size: The TO-92 package makes it easy to integrate into space-constrained projects.
- Programmable Resolution: You can configure the sensor to return a resolution of 9 to 12 bits.
Wiring Diagram
The DS18B20 uses the 1-wire protocol, allowing multiple sensors to be connected to a single data line. Below is a simple wiring diagram for connecting the DS18B20 to an Arduino:
+----------------------+ | DS18B20 Sensor | | (TO-92 Package) | +----------------------+ | Pin 1: GND | | Pin 2: DQ (Data) | | Pin 3: VCC | +----------------------+ +--------------------+ +------------+ | Arduino Board | | 4.7kΩ Resistor | +--------------------+ +------------+ | GND |-------------------> GND | DQ |-------------------> Pin 2 (Digital Pin) | VCC |-------------------> VCC (3.0V to 5.5V) +--------------------+ +------------+
Sample Code (Arduino)
// Include the necessary library #include#include // Define the pin where the DS18B20 is connected #define ONE_WIRE_BUS 2 // Setup the OneWire and DallasTemperature instances OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); void setup() { Serial.begin(9600); sensors.begin(); // Start the sensor } void loop() { sensors.requestTemperatures(); // Request temperature reading Serial.print("Temperature: "); Serial.print(sensors.getTempCByIndex(0)); // Get temperature of the first sensor Serial.println(" C"); delay(1000); // Delay for 1 second }
Installation Tips
- Use a 4.7kΩ pull-up resistor between the data pin and VCC for stable operation.
- Ensure that the sensor is properly powered, especially if using a low voltage power supply.
- If connecting multiple DS18B20 sensors, use the 1-Wire bus to communicate with each sensor individually.