Phipps Electronics

Order within the next 

FREE SHIPPING OVER $199

50,000+ ORDERS

WORLDWIDE SHIPPING

SSL SECURED

Using the Temperature Sensor Module KY-001 with Arduino

Contents

Introduction

In this tutorial, we will learn about the KY-001 module, what is a DS18B20 temperature sensor and we will build a simple project to read the temperature sensed by the KY-001 module using an Arduino.

Temperature Sensor Module KY-001

The KY-001 Module will be our main component for this tutorial. This module has a DS18B20 1-Wire digital thermometer in a TO-92 package and mounted on a breakout board with an LED and resistor. Figure 1 shows the module as seen in fritzing.

Figure 1: KY-001 Temperature Sensor Module

Pinout

The KY-001 module has three pins.

PinDescription
(-)GND
Middle+5V
SSignal

What is DS18B20?

A DS18B20 is a digital thermometer made by Maxim Integrated™ that can give temperature readings from -10 to +85 degrees Celsius. It incorporates the 1-Wire® Interface which only uses one pin for communication.

Project - Arduino Ambient Thermometer

After learning about the KY-001 module and the DS18B20 IC, it is now time to build a project using the module. Our project will get the temperature reading from the KY-001 module and display it on the serial monitor.

Components

For this project, we need the following components:

  • Arduino Uno board (1 pc.)
  • KY-001 Temperature Sensor Module (1 pc.)
  • Jumper wires

Wiring Diagram

Figure 2: Connection Diagram

Figure 2 shows the connection between the Arduino Uno and the KY-001 Temperature Sensor Module.

The KY-001 module pins are connected to the Arduino Uno board as follows:

Component PinUNO Board Pin
(-)GND
Middle+5V
S8

Libraries

To be able for Arduino to communicate with the KY-001 module, we need two modules. We need the OneWire library to communicate with the DS18B20 IC and the Dallas Temperature Control library to convert the data from the KY-001 module to temperature.

The libraries can be downloaded and installed via the Library Manager of the Arduino IDE or by using the links below.

1. OneWire library (https://github.com/PaulStoffregen/OneWire)
2. Dallas Temperature Control library (https://github.com/milesburton/Arduino-Temperature-Control-Library)

The Code

Below is the Arduino sketch for our project. I have added comments to explain important parts of the code. Save the code as KY-001.ino and upload it to your Arduino board.

				
					// Arduino and KY-001 module Tutorial
#include <OneWire.h>
#include <DallasTemperature.h>
OneWire oneWire(8);    // KY-001 Signal pin is connected to Arduino pin 8
DallasTemperature sensors(&oneWire);  // create DallasTemperature object and pass
                    //  oneWire object as parameter
void setup(void)
{
  Serial.begin(9600);   // initialize arduino serial port
  sensors.begin();      // initialize DallasTemperature object
}
void loop(void)
{
  sensors.requestTemperatures();    // Send command to get temperatures
  Serial.print("Temperature from KY-001 is: ");
  Serial.println(sensors.getTempCByIndex(0));// get temperature from KY-001 module
                                               //  and display in serial monitor
  delay(1000);
}
				
			

Project Test

Apply power to your Arduino Uno board and open the Serial Monitor in the Arduino IDE. Arduino will request temperature from the KY-001 module connected to pin 8 and display the temperature in degrees Celsius to the serial monitor every second.

SUBSCRIBE FOR NEW POST ALERTS

Subscribe to be the first to know when we publish a new article!
List Subscriptions(Required)

POPULAR POSTS

Scroll to Top