Control a Relay with ESP32 via Bluetooth Using MIT App Inventor

Welcome to Part 1 of our IoT Home Automation series. In this comprehensive guide, we will focus on the Hardware Architecture required to control high-voltage appliances using an ESP32 and a Relay Module via Bluetooth.

This isn't just a demo—by the end of this article, you will have a safe, fully wired circuit ready for programming. We will cover the specific voltage requirements of the ESP32 and how to wire the relay terminals (COM/NO/NC) correctly.


The Microcontroller: ESP32

We chose the ESP32 over the Arduino UNO for this project because it has built-in Bluetooth Classic and Wi-Fi, eliminating the need for external modules like the HC-05.

[Image of ESP32 Pinout diagram]
  • Logic Voltage: 3.3V (Critical for relay selection)
  • Bluetooth: v4.2 BR/EDR and BLE standard
  • GPIOs: We will use GPIO 23 for signaling.

The Switching Component: Relay Module

A relay is an electromechanical switch. Since the ESP32 operates at 3.3V, you must use a relay module that can trigger at 3.3V. Standard 5V relays often fail to switch when connected directly to an ESP32.

Understanding Relay Terminals

  • COM (Common): Connect your external power source (Live wire) here.
  • NO (Normally Open): Connect your appliance here. The circuit remains disconnected until you send the Bluetooth signal.
  • NC (Normally Closed): The circuit is connected by default. (Rarely used for this type of automation).

Step 1: The Wiring Diagram

Follow this schematic carefully. We are powering the relay control logic from the ESP32 directly, while the switching side handles the load.

🔌 Wiring Connections:
  • ESP32 3.3V ➔ Relay VCC
  • ESP32 GND ➔ Relay GND
  • ESP32 D23 ➔ Relay IN

⚠️ Safety Warning: If you are testing with AC mains voltage (110V/220V) on the Relay COM/NO side, ensure the power is disconnected while wiring.


Step 2: Preparing for Mobile Control

In the upcoming parts, we will use MIT App Inventor to build the controller. For now, you simply need to create a free account at ai2.appinventor.mit.edu.

The logic we will implement involves sending a simple Character String ('1' or '0') from the phone to the ESP32 serial buffer.


Watch the Hardware Demo

See the actual wiring and the relay clicking in action in the Part 1 video below:


Next Steps

Now that your hardware is wired, let's write the code.

Comments

Popular posts from this blog

How to Import CSV Files into PostgreSQL Automatically

Apache NiFi ETL Tutorial for Beginners | Installation & Data Pipeline Basics

ESP32 TFT LCD 240x240 Tutorial-Display Images & DHT11 Sensor

Contact Form

Name

Email *

Message *