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.
D1/TX
connected to HC-05 Bluetooth Module RXD
D0/RX
connected to HC-05 Bluetooth Module TXD
D2
to D5
connected to Relay 4 Channel 5V IN1
to IN4
respectivelyGND
connected to the common ground net5V
connected to the 5V power netRXD
connected to Arduino Nano D1/TX
TXD
connected to Arduino Nano D0/RX
GND
connected to the common ground netVCC
connected to the 5V power netIN1
to IN4
connected to Arduino Nano D2
to D5
respectivelyGND
connected to the common ground netVCC
connected to the 5V power net12v
, -
, 5v
, live
, neutral
pins are present5v
connected to the 5V power net-
connected to the common ground netlive
connected to AC Source +
neutral
connected to AC Source -
+
connected to AC to DC Converter live
-
connected to AC to DC Converter neutral
#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.