Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino Nano-Controlled Bluetooth Relay for Solenoid Lock

Image of Arduino Nano-Controlled Bluetooth Relay for Solenoid Lock

Circuit Documentation

Summary

The circuit is designed to control a 12V solenoid lock using an Arduino Nano microcontroller and a 1-Channel Relay. The Arduino Nano is interfaced with an HC-05 Bluetooth Module to receive commands wirelessly. The relay acts as an electrically operated switch that controls the power to the solenoid lock. The power source for the relay and the Bluetooth module is provided by the Arduino Nano's 5V output, while the solenoid lock is powered by a separate 2x 18650 battery pack.

Component List

Arduino Nano

  • Microcontroller board based on the ATmega328P.
  • It has a variety of digital and analog I/O pins.
  • Used for controlling the relay and communicating with the HC-05 Bluetooth module.

HC-05 Bluetooth Module

  • A wireless communication module that allows for serial communication via Bluetooth.
  • It is used to receive commands from a Bluetooth-enabled device to control the circuit.

1-Channel Relay (5V 10A)

  • An electromechanical switch that allows for controlling high power devices with low power signals.
  • In this circuit, it is used to control the power to the 12V solenoid lock.

2x 18650 Battery Pack

  • A power source consisting of two 18650 lithium-ion batteries.
  • Provides power to the solenoid lock.

12V Solenoid Lock

  • An electrically-controlled lock that operates on 12V.
  • It is the actuator in the circuit, controlled by the relay.

Wiring Details

Arduino Nano

  • D1/TX connected to RXD on HC-05 Bluetooth Module.
  • D0/RX connected to TXD on HC-05 Bluetooth Module.
  • D3 connected to signal on 1-Channel Relay.
  • GND connected to GND on HC-05 Bluetooth Module and ground on 1-Channel Relay.
  • 5V connected to VCC on HC-05 Bluetooth Module and power on 1-Channel Relay.

HC-05 Bluetooth Module

  • RXD connected to D1/TX on Arduino Nano.
  • TXD connected to D0/RX on Arduino Nano.
  • GND connected to GND on Arduino Nano.
  • VCC connected to 5V on Arduino Nano.

1-Channel Relay (5V 10A)

  • signal connected to D3 on Arduino Nano.
  • ground connected to GND on Arduino Nano.
  • power connected to 5V on Arduino Nano.
  • C connected to - on 12V Solenoid Lock.
  • NO connected to vcc on 2x 18650 Battery Pack.

2x 18650 Battery Pack

  • vcc connected to NO on 1-Channel Relay.
  • gnd connected to + on 12V Solenoid Lock.

12V Solenoid Lock

  • - connected to C on 1-Channel Relay.
  • + connected to gnd on 2x 18650 Battery Pack.

Documented Code

// sketch.ino

String readString;
#define relay1 3    // Connect relay1 to pin D3

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

void loop()
{
  while(Serial.available()) 
  {
    delay(10);           
    char c = Serial.read(); 
    if (c == '#'){
      break;            
    }
    readString += c;               
  }
  if (readString.length() >0)
  {
    Serial.println(readString);
              
    if(readString == "f success"){
      digitalWrite(relay1, HIGH);
      delay(3000);
      digitalWrite(relay1, LOW);
    }
    readString="";
  }
}

Code Explanation

  • readString: A String variable to accumulate characters read from the serial port.
  • relay1: A macro defining the relay control pin as digital pin 3 on the Arduino Nano.
  • setup(): Initializes the serial communication at 9600 baud rate and sets the relay pin as an output, initially turned off (LOW).
  • loop(): Continuously checks for incoming serial data. If the character '#' is received, it breaks out of the reading loop. If the received string matches "f success", it activates the relay for 3 seconds, unlocking the solenoid lock, then deactivates it.