KY-019 5V Relay Module

View on Amazon
Overview
About KY-019 5V Relay Module
The KY-019 5V Relay Module allows microcontrollers like Arduino and ESP32 to control high-voltage devices. It operates on a 5V signal and can switch AC loads up to 250V at 10A or DC loads up to 30V at 10A. The module features a single-channel relay with both normally open (NO) and normally closed (NC) contacts, providing flexibility in controlling connected devices. An onboard LED indicates the relayβs status, lighting up when the relay is active.
Get Your KY-019
π‘ Prices are subject to change. We earn from qualifying purchases as an Amazon Associate.
KY-019 Specifications
Complete technical specification details for KY-019 5V Relay Module
π Technical Parameters
KY-019 Pinout
The **KY-019** is a 3-pin 5V relay module for high-voltage/current switching:
Visual Pinout Diagram

Pin Types
Quick Tips
**Interface**: Digital control (relay switching),β‘ **Relay**: Single-channel with NO (normally open) and NC (normally closed) contacts
**Power**: 5V coil voltage required,π **Capacity**: AC 250V/10A or DC 30V/10A switching
**LED**: Onboard status indicator (lights when active),π― **Applications**: Home automation, appliance control, motor control, light switching
Pin Descriptions
| Pin Name | Type | Description | Notes |
|---|---|---|---|
1 Pin (-) | Power | Ground connection | |
2 Pin (+) | Power | Power supply | 5V required for relay coil |
3 Pin (S) | Control | Control signal input | HIGH to activate relay |
Wiring KY-019 to ESP32
To interface the **KY-019** with an **ESP32** for relay control:
Visual Wiring Diagram

Connection Status
Protocol
Pin Connections
| KY-019 Pin | Connection | ESP32 Pin | Description |
|---|---|---|---|
1 Pin (-) Required | GND | Ground | |
2 Pin (+) Required | 5V | Power supply (5V required) | |
3 Pin (S) Required | GPIO5 | Control signal (any GPIO) |
**Control**: Set GPIO HIGH to activate relay, LOW to deactivate
**GPIO Selection**: Any digital GPIO pin works, GPIO5 is just an example
**5V Required**: Relay coil needs 5V - ESP32's 3.3V may not be sufficient
**Load Wiring**: Connect high-voltage load to NO/NC/COM terminals on relay
**High Voltage**: Use proper safety precautions when working with AC mains
KY-019 Troubleshooting
Common issues and solutions to help you get your sensor working
Common Issues
Issue: The relay does not switch when the control signal is applied.
Solutions:
- Ensure the control signal voltage is 5V; the relay may not activate with lower voltages.
- Verify that the
Pin (+)is connected to a stable 5V power source. - Check for proper grounding between the module and the microcontroller.
Issue: The relay switches intermittently or unpredictably.
Solutions:
- Ensure that the power supply can provide sufficient current for the relay.
- Check for loose connections or faulty wiring.
- Confirm that the control signal is not experiencing noise or interference.
Debugging Tips
Use the Serial Monitor to check for error messages and verify the sensor's output. Add debug prints in your code to track the sensor's state.
Use a multimeter to verify voltage levels and check for continuity in your connections. Ensure the power supply is stable and within the sensor's requirements.
Additional Resources
KY-019 Programming Examples
Ready-to-use code examples for different platforms and frameworks
int relayPin = 10; // Relay connected to digital pin 10
void setup() {
pinMode(relayPin, OUTPUT);
Serial.begin(9600);
Serial.println("KY-019 Relay Module Test");
}
void loop() {
digitalWrite(relayPin, HIGH); // Turn relay on
Serial.println("Relay is ON");
delay(1000); // Wait for a second
digitalWrite(relayPin, LOW); // Turn relay off
Serial.println("Relay is OFF");
delay(1000); // Wait for a second
}This Arduino code sets up the KY-019 relay module on digital pin 10. It alternates the relay state every second, turning it on and off, while printing the status to the serial monitor.
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#define RELAY_PIN GPIO_NUM_5
void app_main(void) {
gpio_config_t io_conf = {
.pin_bit_mask = (1ULL << RELAY_PIN),
.mode = GPIO_MODE_OUTPUT,
.pull_up_en = GPIO_PULLUP_DISABLE,
.pull_down_en = GPIO_PULLDOWN_DISABLE,
.intr_type = GPIO_INTR_DISABLE
};
gpio_config(&io_conf);
printf("KY-019 Relay Module Test\n");
while (1) {
gpio_set_level(RELAY_PIN, 1); // Turn relay on
printf("Relay is ON\n");
vTaskDelay(pdMS_TO_TICKS(1000)); // Wait for a second
gpio_set_level(RELAY_PIN, 0); // Turn relay off
printf("Relay is OFF\n");
vTaskDelay(pdMS_TO_TICKS(1000)); // Wait for a second
}
}This ESP-IDF code configures GPIO5 as an output to control the KY-019 relay module. It toggles the relay state every second, turning it on and off, while printing the status to the console.
switch:
- platform: gpio
pin: GPIO5
name: "KY-019 Relay"
icon: "mdi:relay"
restore_mode: ALWAYS_OFFThis ESPHome configuration sets up the KY-019 relay module on GPIO5 as a switch. The relay can be controlled from Home Assistant and will always start in the OFF state when powered up.
platformio.ini
[env:esp32]
platform = espressif32
board = esp32dev
framework = arduinomain.cpp
#include <Arduino.h>
#define RELAY_PIN 5
void setup() {
pinMode(RELAY_PIN, OUTPUT);
Serial.begin(115200);
Serial.println("KY-019 Relay Module Test");
}
void loop() {
digitalWrite(RELAY_PIN, HIGH);
Serial.println("Relay is ON");
delay(1000);
digitalWrite(RELAY_PIN, LOW);
Serial.println("Relay is OFF");
delay(1000);
}This PlatformIO code configures GPIO5 as an output for the KY-019 relay module. The relay toggles ON and OFF every second, with the status printed to the serial monitor.
import machine
import time
RELAY_PIN = machine.Pin(5, machine.Pin.OUT)
while True:
RELAY_PIN.value(1)
print("Relay is ON")
time.sleep(1)
RELAY_PIN.value(0)
print("Relay is OFF")
time.sleep(1)This MicroPython script configures GPIO5 as an output to control the KY-019 relay module. The relay turns ON and OFF every second, with messages printed to the console.
Wrapping Up KY-019
The ESP32 KY-019 5V Relay Module is a powerful KY-0xx module sensor that offers excellent performance and reliability. With support for multiple development platforms including Arduino, ESP-IDF, ESPHome, PlatformIO, and MicroPython, it's a versatile choice for your IoT projects.
Best Practices
For optimal performance, ensure proper wiring and follow the recommended configuration for your chosen development platform.
Safety First
Always verify power supply requirements and pin connections before powering up your project to avoid potential damage.
Ready to Start Building?
Now that you have all the information you need, it's time to integrate the KY-019 into your ESP32 project and bring your ideas to life!
Explore Alternative Sensors
Looking for alternatives to the KY-019? Check out these similar sensors that might fit your project needs.

KY-023 Dual Axis Joystick Module
The KY-023 is a dual-axis joystick module that provides analog outputs for X and Y positions, along with a digital output for a built-in...

KY-004 Key Switch Module
The KY-004 is a key switch module equipped with a tactile push-button. It provides a digital output signal when pressed, making it ideal for...

KY-026 Flame Sensor Module
The KY-026 is a flame sensor module capable of detecting light in the 760 nm to 1100 nm wavelength range. It offers both analog and digital...





