Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Nano Bluetooth-Controlled Relay Switch

View and Edit Project In Cirkit DesignerImage of Arduino Nano Bluetooth-Controlled Relay Switch

Circuit Documentation

Summary of the Circuit

This circuit is designed to control a 4-channel relay module via Bluetooth communication using an Arduino Nano as the microcontroller. The HC-05 Bluetooth module is used to receive commands wirelessly from a Bluetooth-enabled device. The Arduino Nano processes these commands and controls the relay module accordingly, which can switch four separate circuits, potentially connected to AC or DC loads. An AC to DC converter is included to provide the necessary 5V power supply to the Arduino Nano, the relay module, and the Bluetooth module from an AC source.

Component List

Arduino Nano

HC-05 Bluetooth Module

Relay 4 Channel 5V

AC to DC Converter (labeled as "actodc")

AC Source

Wiring Details

Arduino Nano

HC-05 Bluetooth Module

Relay 4 Channel 5V

AC to DC Converter (actodc)

AC Source

Documented Code

#include <SoftwareSerial.h> 
SoftwareSerial module_bluetooth(0, 1); // pin RX | TX

char data = 0;             
void setup() 
{
  Serial.begin(9600);         
  pinMode(2, OUTPUT);  // Initialize PIN 2 as Output
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  digitalWrite(2, HIGH); // Set HIGH initially to turn off relay (active-low)
  digitalWrite(3, HIGH);
  digitalWrite(4, HIGH);
  digitalWrite(5, HIGH);
  
}
void loop()
{
  if(Serial.available() > 0)  
  {
    data = Serial.read(); // Read incoming data      
    if(data == '1'){
      digitalWrite(2, LOW); // Turn on relay
    }
    else if(data == '2'){      
      digitalWrite(2, HIGH); // Turn off relay
    } 
    else if(data == '3'){
      digitalWrite(3, LOW); 
    }
    else if(data == '4'){      
      digitalWrite(3, HIGH); 
    } 
    else if(data == '5'){
      digitalWrite(4, LOW); 
    }
    else if(data == '6'){      
      digitalWrite(4, HIGH); 
    } 
    else if(data == '7'){
      digitalWrite(5, LOW); 
    }
    else if(data == '8'){      
      digitalWrite(5, HIGH); 
    } 
   
                             
}

This code is designed to run on the Arduino Nano and listens for serial input. When a character is received, it checks the character and toggles the corresponding relay channel. The relays are controlled by digital pins 2 to 5. The relays are active-low, meaning that setting the pin to LOW turns the relay on, and setting it to HIGH turns it off.