Kunkune

Wemos D1 Mini Relay Shield Setup and Home Automation Ideas

Wemos D1 Mini Relay Shield Setup and Home Automation Ideas

By Kunkune | Published: 2026-10-28

Category: How-to Guides

Learn how to set up the Wemos D1 Mini Relay Shield for home automation projects. Step-by-step guide with wiring, code, and safety tips.

Quick answer

The Wemos D1 Mini Relay Shield lets you control high-voltage devices from an ESP8266 board. This guide walks you through setup, code, and practical home automation ideas.

Why use a relay shield instead of a separate relay module?

The Wemos D1 Mini Relay Shield plugs directly into your board, eliminating extra wiring and keeping your project compact. It handles up to 250V AC at 10A, enough for lamps, fans, or pumps. However, the shield lacks optocoupler isolation, so you must be careful with high-voltage wiring to avoid damaging the ESP8266.

Step-by-step setup

  1. Mount the shield: Align the shield's pins with the female headers on your Wemos D1 Mini and press firmly. Ensure all pins are fully seated to avoid intermittent connections. A loose connection can cause random relay toggling. Double-check alignment before powering on.
  2. Wire the high-voltage side: Connect your load (e.g., a lamp) to the relay's COM and NO terminals. For safety, use a mains-rated cable and keep the wiring away from the low-voltage ESP8266 side while the device is unpowered. Never work on the high-voltage wiring while the board is connected to USB or mains. Always disconnect power first.
  3. Upload the control sketch: In the Arduino IDE, select your Wemos D1 Mini board and use the following code to toggle the relay every five seconds: void setup() { pinMode(D1, OUTPUT); } void loop() { digitalWrite(D1, HIGH); delay(5000); digitalWrite(D1, LOW); delay(5000); } The relay is controlled by pin D1 (GPIO5). If the relay doesn't click, verify you selected the correct board in the IDE and that the USB cable supplies enough current (at least 500 mA).
  4. Test the relay: After uploading, the relay should click on and off every five seconds. Connect an LED or multimeter to the relay output to confirm switching without connecting high voltage during testing. Testing with a low-voltage indicator (like an LED) avoids electric shock and lets you verify timing before connecting mains devices.
  5. Add Wi-Fi control for home automation: Use the ESP8266WiFi library to connect your Wemos to your home network. Then serve a simple web page that toggles the relay via HTTP GET requests. This allows you to control lights or appliances from your phone. For reliable operation, ensure your Wi-Fi signal is strong near the Wemos. A weak signal can cause disconnections and leave your relay in an unknown state.

Product facts

  • Wemos D1 mini/Pro Relay Shield: Wemos D1 mini/Pro Relay Shield This shield is designed to stack directly on a Wemos D1 Mini or Pro, providing a single relay output without needing breadboard or jumper wires.
    Wemos D1 mini/Pro Relay Shield
    Wemos D1 mini/Pro Relay Shield

Shop Related Products

Wemos D1 mini/Pro Relay Shield

Wemos D1 mini/Pro Relay Shield

$1.94 $2.90

Shop Now