Extra 5% OFF Use Code: OL05
Free Shipping over ₹999

Project 20: Digital Temperature Sensor

Introduction

The KY-028 Digital Temperature Sensor module combines an NTC thermistor and a comparator to detect temperature changes. It outputs both analog and digital signals, making it suitable for precise monitoring or threshold-based triggering. When connected to an Arduino, it can read analog values for actual temperature or use the digital pin for set temperature alerts. In this tutorial, we will learn how to interface the KY-028 with Arduino and use it to monitor temperature effectively.

Required Components

  • Arduino UNO
  • KY-028 Digital Temperature Sensor
  • Jumper wires
  • Breadboard (optional)

Pinout

Circuit Diagram / Wiring

  • KY-028 VCC → 5V (Arduino)
  • KY-028 GND → GND (Arduino)
  • KY-028 AO  → Pin A0 (Arduino)
  • KY-028 DO  → Pin D2 (Arduino)

Arduino Code / Programming

int analogPin = A0;  // Analog output from KY-028
int digitalPin = 2;  // Digital output from KY-028
int analogValue;
int digitalValue;

void setup() {
  Serial.begin(9600);
  pinMode(digitalPin, INPUT);
}

void loop() {
  analogValue = analogRead(analogPin);
  digitalValue = digitalRead(digitalPin);

  Serial.print("Analog Temp Value: ");
  Serial.print(analogValue);
  Serial.print(" | Digital Output: ");
  Serial.println(digitalValue);

  delay(1000);
}

Explanation of the Code

  • The code reads temperature data from the KY-028’s analog (A0) and digital (D0) pins.
  • analogRead gives a variable value indicating temperature changes, while digitalRead shows HIGH or LOW based on a set threshold.
  • The results are printed to the Serial Monitor every second for easy monitoring.

Testing and Troubleshooting

  • Ensure all connections are secure and the sensor is properly powered (5V and GND).
  • If analog values don’t change, try warming the sensor slightly with your hand to test responsiveness.
  • Adjust the onboard potentiometer to change the digital output threshold if it’s always HIGH or LOW.

    Leave a Reply

    Your email address will not be published.

    Need Help?