The KY-028 is a temperature sensor module designed for measuring ambient temperature. It features the LM35 temperature sensor, which provides an analog output proportional to the temperature in degrees Celsius. The module also includes a digital output that can be triggered when the temperature exceeds a user-defined threshold, adjustable via an onboard potentiometer.
The KY-028 module has four pins, as described in the table below:
Pin | Name | Description |
---|---|---|
1 | VCC | Power supply input (3.3V to 5V DC) |
2 | GND | Ground connection |
3 | DO (Digital) | Digital output pin; HIGH when temperature exceeds the threshold, LOW otherwise |
4 | AO (Analog) | 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 on your microcontroller to measure the temperature.DO
pin to a digital input pin on your microcontroller to detect when the temperature exceeds the threshold.Below is an example code to read both the analog and digital outputs of the KY-028 module using an 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
void setup() {
Serial.begin(9600); // Initialize serial communication
pinMode(digitalPin, INPUT); // Set digital pin as input
}
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
// Read digital value from DO pin
int digitalValue = digitalRead(digitalPin);
// Print results to Serial Monitor
Serial.print("Temperature (°C): ");
Serial.println(temperature);
Serial.print("Digital Output: ");
Serial.println(digitalValue);
delay(1000); // Wait 1 second before next reading
}
Temperature (°C) = (Analog Value * Vcc / 1023) * 100
Vcc
is the operating voltage (5V in this case).No Output from the Module
Inaccurate Temperature Readings
Digital Output Always HIGH or LOW
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 calibration for negative values.
Q: How do I calibrate the sensor for more accurate readings?
A: Use a known temperature source (e.g., an ice bath or boiling water) to compare the sensor's output and adjust the formula or scaling factor in your code.
Q: Can I use the KY-028 with a 3.3V microcontroller?
A: Yes, the module operates at 3.3V. Ensure the analog-to-digital conversion formula in your code reflects the 3.3V reference voltage.
Q: What is the purpose of the potentiometer on the module?
A: The potentiometer adjusts the temperature threshold for the digital output (DO pin). Rotate it to increase or decrease the threshold.
By following this documentation, you can effectively integrate the KY-028 temperature sensor module into your projects for reliable temperature monitoring and control.