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.
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.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.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.vcc
connected to NO
on 1-Channel Relay.gnd
connected to +
on 12V Solenoid Lock.-
connected to C
on 1-Channel Relay.+
connected to gnd
on 2x 18650 Battery Pack.// 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="";
}
}
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.