Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Bettesworth Construction
Arduino Uno

Smart Plug with Arduino UNO and HC-05 Bluetooth Module: Build Guide and Safety Limits

This Arduino UNO and HC-05 project is a local Bluetooth relay controller—not a certified smart plug. Learn the wiring, code, pairing steps, troubleshooting, and safety limits.

By Bettesworth Construction Team 8 min read

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This project is a local Bluetooth-controlled relay outlet, not a modern Wi-Fi smart plug. A phone sends the characters 1 or 0 to an HC-05 module; an Arduino UNO interprets them and drives a relay. It is an excellent low-voltage Arduino exercise, but the mains socket must not be treated as a beginner breadboard project. For unattended household use, a properly certified commercial smart plug is the safer choice.

What the project does

The original Arduino Project Hub design, published on March 12, 2020, combines an Arduino UNO, HC-05 Bluetooth module, 5 V relay module, 12 V DC adapter, AC socket and plug, jumper wires, and an MIT App Inventor application. The phone provides the interface; the HC-05 provides a serial Bluetooth link; the UNO runs the control logic; and the relay switches the load.

As an Amazon Associate I earn from qualifying purchases.

Its basic signal path is:

Phone app → Bluetooth → HC-05 → UART serial → Arduino UNO → relay input → relay contacts → load

The design provides short-range, local control. The source project does not establish cloud access, scheduling, energy monitoring, secure authentication, product certification, or safe household-mains construction.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

See the original Arduino Project Hub project.

Required hardware

  • Arduino UNO Rev3
  • HC-05 Bluetooth serial module
  • 5 V relay module with a logic input
  • Appropriate regulated power supplies
  • Jumper wires for the low-voltage circuit
  • Bluetooth serial-terminal app or the project’s MIT App Inventor application
  • For safe low-voltage testing: a suitable low-voltage load and enclosure

The UNO Rev3 uses an ATmega328P, operates at 5 V, and provides 14 digital I/O pins, six analog inputs, a 16 MHz clock, 32 KB flash, 2 KB SRAM, and 1 KB EEPROM. Arduino recommends 7–12 V for external input and specifies 20 mA as the recommended maximum current per I/O pin. A UNO output should drive the relay module’s input—not a bare relay coil. The module should contain the required transistor or driver circuitry. Review the official UNO Rev3 documentation.

#1 Best Overall
Arduino UNO R4 WiFi [ABX00087] - Renesas RA4M1 + ESP32-S3, Wi-Fi, Bluetooth, USB-C, CAN, 12-bit DAC, OP AMP, Qwiic Connector, 12x8 LED Matrix for Advanced IoT & Embedded Projects
  • Dual-Core Processing with Renesas RA4M1 and ESP32-S3: The Arduino UNO R4 WiFi combines the Renesas RA4M1 microcontroller (ARM Cortex-M4) and the ESP32-S3 Wi-Fi/Bluetooth chip, delivering powerful dual-core processing capabilities. This combination offers flexibility for a wide range of projects, from high-speed communications and wireless control to real-time data processing and edge AI applications.
  • Comprehensive Wireless Connectivity: Equipped with Wi-Fi and Bluetooth 5.0, the UNO R4 WiFi ensures robust wireless communication for IoT projects, remote sensors, smart devices, and wireless control applications. Whether connecting to the cloud, other devices, or local networks, the board offers stable and high-speed wireless connectivity for seamless operation.
  • Modern USB-C, CAN, & Qwiic Connector: The USB-C port enables efficient power delivery and fast programming, improving ease of use compared to traditional USB connections. The Controller Area Network (CAN) support allows for reliable, real-time communication in industrial, automotive, or robotic systems. Additionally, the Qwiic Connector makes it easy to add I2C sensors and peripherals, simplifying the connection process and reducing the need for complex wiring.
  • High-Precision 12-bit DAC & OP-AMP: For projects that require high-quality analog output, the 12-bit DAC (Digital-to-Analog Converter) and integrated operational amplifier (OP-AMP) provide precise analog signal generation and amplification. This feature is ideal for audio projects, sensor interfacing, or applications where analog signal control and processing are necessary.
  • Integrated 12x8 LED Matrix: The UNO R4 WiFi includes a built-in 12x8 LED Matrix, enabling users to display dynamic visuals, messages, or real-time data on the board itself. This makes it perfect for projects that require immediate visual feedback, such as status indicators, event displays, or interactive user interfaces.

Original control logic

The original sketch uses digital pin 12 for the relay, starts serial communication at 9600 baud, interprets character '0' as off and '1' as on, and sends status text back over serial:

int relay = 12;
int state = 0;
int flag = 0;

void setup() {
  pinMode(relay, OUTPUT);
  digitalWrite(relay, LOW);
  Serial.begin(9600);
}

void loop() {
  if (Serial.available() > 0) {
    state = Serial.read();
    flag = 0;
  }

  if (state == '0') {
    digitalWrite(relay, LOW);
    if (flag == 0) {
      Serial.println("POWER: Off");
      flag = 1;
    }
  } else if (state == '1') {
    digitalWrite(relay, HIGH);
    if (flag == 0) {
      Serial.println("POWER: On");
      flag = 1;
    }
  }
}

This code assumes that HIGH activates the relay. Many relay boards are active-low, so their behavior is reversed. Test the actual module before connecting any load.

Low-voltage wiring

Build and test the control side separately from the mains side:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • UNO GND to relay-module GND
  • UNO 5 V to relay-module VCC only when the board is designed for 5 V operation
  • UNO pin 12 to relay-module IN
  • HC-05 GND to UNO GND
  • HC-05 VCC according to that breakout board’s specification
  • HC-05 TX to the Arduino RX pin being used
  • Arduino TX to HC-05 RX through the appropriate voltage protection if required by the module

HC-05 breakout boards are not standardized. Pin labels, regulators, default pairing PINs, logic levels, firmware, and baud-rate behavior vary. Check the documentation for the exact board instead of assuming that every board accepts the same supply or signal voltage.

A better UNO sketch

The UNO’s pins 0 and 1 are its hardware serial interface and are also connected to the USB-to-serial circuitry. This can prevent uploads and interfere with debugging. Using SoftwareSerial leaves the USB serial connection available.

Rank #2
HiLetgo 5V 4 Channel Relay Shield for UNO R3
  • 5V 4 Channel Relay Shield for Arduino UNO R3
  • UNO R3 Relay Shield with Four Channel Relay
  • With Indication LED's for Relay output status
  • Standard interface that can be controlled directly by microcontroller
#include <SoftwareSerial.h>

SoftwareSerial bluetooth(10, 11); // Arduino RX, TX
const byte RELAY_PIN = 12;

// Reverse these values for an active-low relay module.
const byte RELAY_ON  = HIGH;
const byte RELAY_OFF = LOW;

void setup() {
  pinMode(RELAY_PIN, OUTPUT);
  digitalWrite(RELAY_PIN, RELAY_OFF);

  Serial.begin(9600);
  bluetooth.begin(9600);
  bluetooth.println("READY");
  Serial.println("READY");
}

void loop() {
  if (bluetooth.available()) {
    char command = bluetooth.read();

    if (command == '1') {
      digitalWrite(RELAY_PIN, RELAY_ON);
      bluetooth.println("POWER: On");
      Serial.println("POWER: On");
    } else if (command == '0') {
      digitalWrite(RELAY_PIN, RELAY_OFF);
      bluetooth.println("POWER: Off");
      Serial.println("POWER: Off");
    }
  }
}

In SoftwareSerial bluetooth(10, 11), the first number is the Arduino’s RX pin and the second is its TX pin. Therefore, HC-05 TX connects to Arduino pin 10, and Arduino pin 11 connects to HC-05 RX through any required level shifting.

Upload and test procedure

  1. Assemble only the UNO, HC-05, and relay module’s low-voltage connections.
  2. If using pins 0 and 1, disconnect the HC-05 before uploading. The USB serial path shares those pins.
  3. Upload the sketch and reconnect the module, or use the SoftwareSerial version from the start.
  4. Power the control circuit and pair the phone with the HC-05 using the module’s documented procedure. Pairing PINs vary by module.
  5. Open a compatible Bluetooth serial terminal or the MIT App Inventor app.
  6. Send ASCII character 1. The relay should change to its on state and return POWER: On.
  7. Send ASCII character 0. The relay should change to its off state and return POWER: Off.
  8. Test with an LED and resistor or another low-voltage load before considering any mains connection.

Phone compatibility is not universal. The application, phone operating system, Bluetooth profile support, and HC-05 firmware all matter. A phone that pairs successfully may still require a suitable serial-terminal app to send the expected characters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Active-high versus active-low relays

Do not infer contact behavior from the input LED. With the load disconnected, upload a test program that changes the relay input between HIGH and LOW. Listen for the click and verify continuity with an appropriate meter. Then set:

const byte RELAY_ON  = HIGH;
const byte RELAY_OFF = LOW;

For an active-low board, use:

const byte RELAY_ON  = LOW;
const byte RELAY_OFF = HIGH;

Also distinguish the relay’s logic state from its contact state. A lit indicator does not prove that the intended COM, NO, or NC terminals are connected correctly.

Mains safety: keep it separate

The relay contacts may switch an AC circuit, but a relay module does not make an exposed outlet safe. Household mains can cause fatal shock and fire. Do not work on energized wiring, and do not place mains conductors on a solderless breadboard or leave screw terminals and jumpers exposed.

Rank #3
ELEGOO 8 Channel DC 5V Relay Module with Optocoupler for Arduino Projects
  • Eight Independent 5 V Relay Channels: Control up to eight separate loads from compatible 5 V microcontroller projects; each channel uses an active-low input and has its own status LED for easier testing and troubleshooting
  • Flexible NO/NC Wiring: Each relay channel provides normally open (NO), common (COM) and normally closed (NC) terminals, allowing the load circuit to be wired for normally open or normally closed operation
  • Channel Status Indicators: A power LED and eight individual channel LEDs make relay states easier to check during setup and troubleshooting; onboard flyback diodes help clamp relay-coil transients
  • Optocoupler-Equipped Input Stages: Eight optocouplers separate the control-input stages from the relay-drive circuitry; use the JD-VCC/VCC configuration required by your project and follow the board documentation for isolated-power setups
  • Relay Contact Rating: Each relay is marked for up to 10 A at 250 V AC or 30 V DC under the relay manufacturer’s specified conditions; actual usable load depends on load type, wiring and switching conditions

A permanent mains assembly requires, at minimum, an electrically suitable flame-retardant enclosure, strain relief, insulation and spacing appropriate to the voltage, suitable overcurrent protection, secure terminals, and a relay whose voltage, current, inrush, load-type, duty-cycle, and certification ratings match the appliance. The switching arrangement must disconnect the correct conductor for the applicable electrical system. Have line-voltage construction reviewed or completed by a qualified electrician.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Load type matters. A small resistive lamp, LED driver, heater, motor, compressor, charger, and power tool impose different stresses on relay contacts. A printed “10 A” rating alone does not prove suitability for a motor or unattended household installation.

The original project’s parts list includes an AC socket and plug, but its page does not provide enough authoritative electrical-safety detail to establish that a particular mains build is safe. Treat the original as a control demonstration, not as a certified construction design.

Known failure modes

The relay never activates

  • Check VCC, GND, and continuity to pin 12.
  • Test both HIGH and LOW logic because the module may be active-low.
  • Confirm that the supply can provide the module’s coil current.
  • Check whether the board uses a separate JD-VCC arrangement.

The relay clicks but the load remains off

Check COM versus NO/NC, load termination, contact damage, and the appliance’s steady-state and inrush requirements. Never test uncertain mains wiring while energized.

Bluetooth pairs but commands do nothing

Check RX/TX crossover, shared ground, baud rate, selected Arduino pins, and whether the app sends ASCII 1 and 0 rather than numeric values. Line endings or extra characters can also affect simple command handling.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
AEDIKO 4pcs DC 5V Relay Module - 1 Channel Relay Switch Board with Optocoupler Isolation, High or Low Level Trigger
  • 5V Relay Module: Working Voltage: DC 5V; Maximum Load: AC 250V/10A, DC 30V/10A; Trigger Current of Opto-Isolator: 5mA
  • Fault-Tolerant Design: Fault Tolerant Design, Even if the Control Line is Broken, the Relay will not Operate;All Interfaces of Relay can be Wired Out Through the Terminals Directly,Normally Open and Normally Closed
  • Optocoupler Isolation:1 Channel Relay Board use Optocoupler Isolation that has Strong Driving Ability and Stable Performance ,The Isolation Circuit Prevent Damages to I / O Port by Relay Switch Current
  • Jumper Design: The Relay Module has a Jumper That You Can Set Rather the Unit State Changes with High or Low Signal. Has Screw Terminals for Relay (NC,C,NO) and for Input; Coil +, Coil - and Trigger.
  • Wide Application: DC 5V Relay Module Works Well with ARM /PIC /AVR /MCU/Raspberry/CNC Machine/ PS4 etc.

Upload fails

Disconnect the HC-05 from UNO pins 0 and 1 during uploading, or use the alternate-pin sketch. Those pins share the UNO’s USB serial path. Arduino’s UNO documentation explains the serial interface and SoftwareSerial option.

Status text is garbled

Make the serial monitor, HC-05, and application use the same baud rate and compatible line endings. Normal data-mode and AT-command-mode baud rates may differ.

The relay changes state after reset

The original code writes LOW during startup, but the physical result depends on relay polarity. Choose and document the desired reset state explicitly. The project does not define a watchdog, brownout, power-loss, or Bluetooth-disconnection policy.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Improvements for a more reliable design

  • Replace single-character commands with framed commands such as ONn, OFFn, and STATUSn.
  • Validate commands and return explicit acknowledgements.
  • Define what happens after reset, watchdog recovery, or power loss.
  • Consider a physical manual override.
  • Add a carefully designed connection-timeout policy; a quiet but connected phone must not be mistaken for a lost connection.
  • Add current and temperature monitoring only with appropriately designed sensing and protection circuits.
  • Do not assume HC-05 Bluetooth control is secure. The original design describes no authentication or authorization scheme.

UNO and wireless alternatives

A UNO with HC-05 is useful when the goal is learning UART communication. It is bulky, short-range, and not a drop-in route to internet-connected automation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The UNO WiFi Rev2 includes Wi-Fi, Bluetooth connectivity through its wireless module, and an ATECC608 cryptographic chip, but it uses a different wireless architecture and software stack; the HC-05 sketch and app workflow are not drop-in compatible. See the UNO WiFi Rev2 documentation.

Best Value
DSD TECH HM-10 Bluetooth 4.0 BLE iBeacon UART Module with 4PIN Base Board for Arduino UNO R3 Mega 2560 Nano
  • Low Energy: With HM-10 bluetooth 4.0 module, you can add Bluetooth features to your project and support iphone4s or later.
  • DSD TECH Brand 4pin Base Board: Through this base board, leads to VCC, GND, TX, RX. You can be very convenient to connect to your arduino project
  • Led status indication: when the connection is established will always light, disconnection is flash
  • iBeacon Support:You can make this module into ibeacon mode.So you can have your own ibeacon.it also Supports Apple Notification Center Service (ANCS)
  • working voltage 3.6 V to 6V,Default rate of 9600. DSD TECH back this Bluetooth 4.0 BLE module with ONE Year WARRANTY. If you meet any question, please contact us, we will fix your issue within 24 hours.

The newer UNO R4 WiFi is another redesign option, but it likewise requires adapting the hardware and software rather than simply replacing the HC-05.

Build or buy?

Approach Best for Main limitation
UNO + HC-05 + relay Learning and local Bluetooth experiments No native Wi-Fi, weak security, and substantial safety responsibility
Low-voltage relay project Safe classroom and bench demonstrations Does not reproduce a household outlet
UNO WiFi Rev2 or UNO R4 WiFi Redesigned connected projects Requires a different wireless stack
Certified consumer smart plug Household appliances and unattended use Less educational and tied to its ecosystem

Use this Arduino project when the objective is education, serial communication, or a properly enclosed low-voltage controller. Do not build it as described for a heater, motor, compressor, power tool, child-accessible installation, or unattended mains device unless the electrical design is professionally addressed. For ordinary household use, choose a suitably certified commercial smart plug and verify its ratings and platform compatibility.

Frequently Asked Questions

What commands does the original project use?

It uses the ASCII character 1 for on and 0 for off, at 9600 baud.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why should the HC-05 be disconnected during uploading?

The original wiring uses UNO pins 0 and 1, which are shared with the USB serial interface. The module can interfere with uploading and debugging.

Is this Arduino smart plug safe for household mains?

The project page does not establish that. Treat it as a low-voltage learning exercise unless the mains assembly has suitable protection, enclosure, ratings, and qualified electrical review.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Site Office

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.