The KY-028 is a temperature sensor module that utilizes the LM35 temperature sensor to measure ambient temperature. It provides both analog and digital outputs, making it versatile for a wide range of applications. The analog output corresponds to the temperature in a linear fashion, while the digital output can be used for threshold-based temperature detection. This module is commonly used in temperature monitoring systems, home automation, weather stations, and educational projects.
The KY-028 module has 4 pins. The table below describes each pin:
Pin Name | Description |
---|---|
VCC | Power supply pin (3.3V to 5V DC) |
GND | Ground connection |
DO | Digital output pin (HIGH or LOW based on the threshold set by the potentiometer) |
AO | Analog output pin (provides a voltage proportional to the measured temperature) |
VCC
pin to a 3.3V or 5V power source and the GND
pin to ground.AO
pin to an analog input pin of your microcontroller to measure the temperature.DO
pin to a digital input pin of your microcontroller to detect when the temperature crosses the threshold set by the potentiometer.Below is an example of how to use the KY-028 module with an Arduino UNO to read both analog and digital outputs:
// KY-028 Temperature Sensor Example with Arduino UNO
// Define pin connections
const int analogPin = A0; // Connect AO pin to A0 on Arduino
const int digitalPin = 2; // Connect DO pin to digital pin 2 on Arduino
const int ledPin = 13; // Built-in LED for threshold indication
void setup() {
Serial.begin(9600); // Initialize serial communication
pinMode(digitalPin, INPUT); // Set digital pin as input
pinMode(ledPin, OUTPUT); // Set LED pin as output
}
void loop() {
// Read analog value from AO pin
int analogValue = analogRead(analogPin);
float temperature = (analogValue * 5.0 / 1023.0) * 100.0;
// Convert analog value to temperature in °C
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" °C");
// Read digital value from DO pin
int digitalValue = digitalRead(digitalPin);
if (digitalValue == HIGH) {
digitalWrite(ledPin, HIGH); // Turn on LED if threshold is crossed
Serial.println("Threshold exceeded!");
} else {
digitalWrite(ledPin, LOW); // Turn off LED if below threshold
}
delay(1000); // Wait 1 second before next reading
}
Temperature (°C) = (Analog Value * Vcc / 1023) * 100
Vcc
is the operating voltage (typically 5V for Arduino UNO).No Output from the Module:
Incorrect Temperature Readings:
Digital Output Not Triggering:
Q: Can the KY-028 measure negative temperatures?
A: Yes, the LM35 sensor can measure temperatures as low as -55°C. However, the analog output may require additional processing to interpret negative values correctly.
Q: How do I calibrate the sensor?
A: The LM35 is factory-calibrated, so no additional calibration is required. However, you can adjust the threshold for the digital output using the onboard potentiometer.
Q: Can I use the KY-028 with a 3.3V microcontroller?
A: Yes, the KY-028 operates within a voltage range of 3.3V to 5V, making it compatible with 3.3V microcontrollers like the ESP32 or Raspberry Pi Pico.
Q: What is the purpose of the onboard LED?
A: The onboard LED lights up when the temperature exceeds the threshold set by the potentiometer, providing a visual indication of the digital output state.