A temperature sensor is a device that measures temperature and converts it into a signal which can be read by an observer or by an instrument. These sensors are widely used in various applications, including environmental monitoring, industrial processes, and consumer electronics. They provide accurate and reliable temperature readings, making them essential components in many systems.
Parameter | Value |
---|---|
Operating Voltage | 3.3V to 5V |
Operating Current | 10 µA to 1 mA |
Temperature Range | -55°C to +150°C |
Accuracy | ±0.5°C (at 25°C) |
Output Type | Analog or Digital |
Response Time | < 1 second |
Pin No. | Pin Name | Description |
---|---|---|
1 | Vcc | Power supply (3.3V to 5V) |
2 | Vout | Analog output voltage proportional |
to temperature | ||
3 | GND | Ground |
Pin No. | Pin Name | Description |
---|---|---|
1 | GND | Ground |
2 | DQ | Data input/output |
3 | Vcc | Power supply (3.3V to 5V) |
const int sensorPin = A0; // Analog input pin connected to the sensor
void setup() {
Serial.begin(9600); // Initialize serial communication
}
void loop() {
int sensorValue = analogRead(sensorPin); // Read the analog value
float voltage = sensorValue * (5.0 / 1023.0); // Convert to voltage
float temperatureC = voltage * 100.0; // Convert voltage to temperature
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.println(" °C");
delay(1000); // Wait for 1 second before next reading
}
#include <OneWire.h>
#include <DallasTemperature.h>
const int oneWireBus = 2; // Digital pin connected to the sensor
OneWire oneWire(oneWireBus);
DallasTemperature sensors(&oneWire);
void setup() {
Serial.begin(9600); // Initialize serial communication
sensors.begin(); // Start the DS18B20 sensor
}
void loop() {
sensors.requestTemperatures(); // Send command to get temperatures
float temperatureC = sensors.getTempCByIndex(0); // Read temperature
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.println(" °C");
delay(1000); // Wait for 1 second before next reading
}
No Output or Incorrect Readings:
Fluctuating Readings:
Sensor Not Detected (Digital Sensors):
By following this documentation, users can effectively integrate and utilize temperature sensors in their projects, ensuring accurate and reliable temperature measurements.