The KY-018 is a temperature sensor module manufactured by ESP32 with the part ID 18. It is based on the LM35 temperature sensor, which provides a linear analog output proportional to the temperature in degrees Celsius. This module is widely used in temperature monitoring and control applications due to its simplicity, accuracy, and ease of interfacing with microcontrollers.
The KY-018 module is designed for accurate and reliable temperature sensing. Below are its key technical details:
Parameter | Value |
---|---|
Manufacturer | ESP32 |
Part ID | 18 |
Sensor Type | LM35 (Analog Temperature Sensor) |
Operating Voltage | 4V to 30V |
Output Voltage Range | 0V to 1.5V (for -55°C to 150°C) |
Temperature Range | -55°C to +150°C |
Accuracy | ±0.5°C (at 25°C) |
Output Sensitivity | 10mV/°C |
Power Consumption | Low |
Dimensions | 18mm x 10mm x 8mm |
The KY-018 module has three pins for easy interfacing:
Pin | Name | Description |
---|---|---|
1 | VCC | Power supply pin (4V to 30V) |
2 | GND | Ground pin |
3 | OUT | Analog output pin that provides a voltage proportional to the temperature |
The KY-018 module is straightforward to use in a circuit. Follow the steps below to integrate it into your project:
VCC
pin to a 5V power supply (or 3.3V if supported by your microcontroller) and the GND
pin to the ground.OUT
pin to an analog input pin on your microcontroller to read the temperature as an analog voltage.Below is an example code snippet to read temperature data from the KY-018 module using an Arduino UNO:
// KY-018 Temperature Sensor Example with Arduino UNO
// Reads the analog output from the KY-018 and converts it to temperature in °C
const int sensorPin = A0; // KY-018 OUT pin connected to Arduino analog pin A0
float temperature; // Variable to store the calculated temperature
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 baud
}
void loop() {
int sensorValue = analogRead(sensorPin); // Read the analog value from the sensor
float voltage = sensorValue * (5.0 / 1023.0); // Convert ADC value to voltage
temperature = voltage * 100.0; // Convert voltage to temperature (10mV/°C)
// Print the temperature to the Serial Monitor
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
delay(1000); // Wait for 1 second before the next reading
}
No Output or Incorrect Readings
Fluctuating or Noisy Readings
VCC
and GND
pins.Output Voltage Does Not Change with Temperature
Temperature Readings Are Inaccurate
Q1: Can the KY-018 module be used with a 3.3V microcontroller like ESP32?
A1: Yes, the KY-018 can operate at 3.3V. However, ensure the output voltage range is compatible with the ADC input range of your microcontroller.
Q2: How do I measure negative temperatures with the KY-018?
A2: The LM35 sensor outputs a negative voltage for temperatures below 0°C. Use a microcontroller or circuit capable of reading negative voltages, or add a level-shifting circuit.
Q3: Can I use the KY-018 for long-term temperature monitoring?
A3: Yes, the KY-018 is suitable for long-term use. Ensure proper environmental protection if used in harsh conditions.
Q4: What is the maximum cable length for connecting the KY-018 to a microcontroller?
A4: The maximum cable length depends on the quality of the cable and the environment. For best results, keep the cable length under 1 meter and use shielded cables in noisy environments.