SMT 4 Node Smart HomeAutomation PCB.|ESP32

SMT 4 Node Smart HomeAutomation PCB.|ESP32

SMT 4 Node Smart HomeAutomation PCB.|ESP32

Hey hello friends welcome to another post, In this article, I am going to introduce my newly design fully SMT components used 4 channel remotely and manually controlled homeAutomation PCB.

I have also made 8 channel SMT homeautomation PCB, TMT Components used homeautomation PCB.

This homeautoamtion PCB is very small in size and compact which can easily fits in your electrical switch boards.

This PCB has inbuilt OTA button, that is, you can update the code wirelessly over the air.

And there is two Onbaord Led’s which you could use according to your need like testing your code or something else.

In my case I have  used as WIFI indicator that is if WIFI connection is available then both the Led’s will glow else only single Led will glow.

By using this PCB, I will make a small homeautomation system that is internet and manual controlled homeautoamtion system using blynk iot plateform.

In this home-automation system we can control our home-appliances by using blynk smartphone application from anywhere in this world

Apart from this we can also control our home-appliances through manual switches that we generally use in our homes and we can also monitor the real-time status in the blynk smartphone application.

This PCB is compatible for all the smart speakers available in the market like Amazons Alexa , google home and Apples SIRI.

Designing the PCB.

To design the circuit and PCB, we used EasyEDA which is a browser based software to design PCBs.

Designing the circuit works like in any other circuit software tool, you place some components and you wire them together. 

Then, you assign each component to a footprint.

Having the parts assigned, place each component. When you’re happy with the layout, make all the connections and route your PCB.

Save your project and export the Gerber files.

Seeed Fusion PCB Assembly.

Seeed Studio Fusion PCB Assembly  Service takes care of the entire fabrication process from PCB manufacturing , parts sourcing, assembly and testing services, so you can be sure that they are getting a quality product. After gauging market interest and verifying a working prototype, Seeed Propagate Service can help you bring the product to market with professional guidance and a strong network of connections.

Let's Make it...!

Now grab all the components whose list is mention below, and soldered the rest of components on the PCB.

1.HI-LINK (5M05).

2.Relay (5 volt).

3.optocoupler(PC817).

4.Two Pin Terminal Connector.

After soldiering rest of components PCB look like this neat, clean and well arranged.

Blynk Application.

Blynk mobile application is available for both IOS as well as Android users.

Scan the above QR Code with your phone and you will get a full copy of this project.

Code.

To flash the code into ESP32 chip, I will use ESP32 development board.

Make the connections according to below schematic.

Copy or download the following code to your Arduino IDE and upload it to your Arduino board.

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
BlynkTimer timer;


#define DEBUG_SW 0


#define Switch1 34
#define Relay1 23

#define Switch2 35
#define Relay2 22

#define Switch3 32
#define Relay3 21


#define Switch4 33
#define Relay4 19


#define LED1 13
#define LED2 12




int MODE = 0;


// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "XXXXXXXXXXXX";
char pass[] = "XXXXXXXXX";

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = " XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";


int Flag1 = 0;
int Flag2 = 0;
int Flag3 = 0;
int Flag4 = 0;


BLYNK_WRITE(V1)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  digitalWrite(Relay1, pinValue);
  // process received value
}

BLYNK_WRITE(V2)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V2 to a variable
  digitalWrite(Relay2, pinValue);
  // process received value
}

BLYNK_WRITE(V3)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V3 to a variable
  
  digitalWrite(Relay3, pinValue);
  // process received value
}

BLYNK_WRITE(V4)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V4 to a variable
  digitalWrite(Relay4, pinValue);
  // process received value
}

void with_internet()
{
  if (digitalRead(Switch1) == LOW)
  {
    if (Flag1 == 0 )
    {
      digitalWrite(Relay1, LOW);
      if (DEBUG_SW) Serial.println("Relay1- ON");
      Blynk.virtualWrite(V1, 0);
      Flag1 = 1;
    }
    if (DEBUG_SW) Serial.println(" -ON");

  }
  if (digitalRead(Switch1) == HIGH )
  {
    if (Flag1 == 1)
    {
      digitalWrite(Relay1, HIGH);
      if (DEBUG_SW) Serial.println("Relay1 OFF");
      Blynk.virtualWrite(V1, 1);
      Flag1 = 0;
    }
    if (DEBUG_SW)Serial.println(" OFF");
  }


  if (digitalRead(Switch2) == LOW)
  {
    if (Flag2 == 0 )
    {
      digitalWrite(Relay2, LOW);
      if (DEBUG_SW)  Serial.println("Relay2- ON");
      Blynk.virtualWrite(V2, 0);
      Flag2 = 1;
    }
    if (DEBUG_SW) Serial.println("Switch2 -ON");

  }
  if (digitalRead(Switch2) == HIGH )
  {
    if (Flag2 == 1)
    {
      digitalWrite(Relay2, HIGH);
      if (DEBUG_SW) Serial.println("Relay2 OFF");
      Blynk.virtualWrite(V2, 1);
      Flag2 = 0;
    }
    if (DEBUG_SW)Serial.println("Switch2 OFF");
    //delay(200);
  }

  if (digitalRead(Switch3) == LOW)
  {
    if (Flag3 == 0 )
    {
     
      digitalWrite(Relay3, LOW);
      if (DEBUG_SW) Serial.println("Relay3- ON");
      Blynk.virtualWrite(V3, 0);
      Flag3 = 1;
    }
    if (DEBUG_SW) Serial.println("Switch3 -ON");

  }
  if (digitalRead(Switch3) == HIGH )
  {
    if (Flag3 == 1)
    {
      
      digitalWrite(Relay3, HIGH);
      if (DEBUG_SW) Serial.println("Relay3 OFF");
      Blynk.virtualWrite(V3, 1);
      Flag3 = 0;
    }
    if (DEBUG_SW)Serial.println("Switch3 OFF");
    //delay(200);
  }

  if (digitalRead(Switch4) == LOW)
  {
    if (Flag4 == 0 )
    {
      digitalWrite(Relay4, LOW);
      if (DEBUG_SW) Serial.println("Relay4- ON");
      Blynk.virtualWrite(V4, 0);
      Flag4 = 1;
    }
    if (DEBUG_SW) Serial.println("Switch4 -ON");

  }
  if (digitalRead(Switch4) == HIGH )
  {
    if (Flag4 == 1)
    {
      digitalWrite(Relay4, HIGH);
      if (DEBUG_SW) Serial.println("Relay4 OFF");
      Blynk.virtualWrite(V4, 1);
      Flag4 = 0;
    }
    if (DEBUG_SW)Serial.println("Switch4 OFF");
    //delay(200);
  }



}

void without_internet()
{

  digitalWrite(Relay1, digitalRead(Switch1));
  digitalWrite(Relay2, digitalRead(Switch2));
  digitalWrite(Relay3, digitalRead(Switch3));
  digitalWrite(Relay4, digitalRead(Switch4));

}


void checkBlynk() { // called every 3 seconds by SimpleTimer

  bool isconnected = Blynk.connected();
  if (isconnected == false) {
    MODE = 1;
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, LOW);
    
  }
  if (isconnected == true) {
    MODE = 0;
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, HIGH);
   
  }
}

void setup()
{
  // Debug console
  if (DEBUG_SW) Serial.begin(9600);
  pinMode(Switch1, INPUT);
  pinMode(Relay1, OUTPUT);

  pinMode(Switch2, INPUT);
  pinMode(Relay2, OUTPUT);

  pinMode(Switch3, INPUT);
  pinMode(Relay3, OUTPUT);

  pinMode(Switch4, INPUT);
  pinMode(Relay4, OUTPUT);


  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
 

  digitalWrite(LED1, HIGH);
  delay(200);
  digitalWrite(LED2, HIGH);
  delay(200);

  digitalWrite(LED1, LOW);
  digitalWrite(LED2, LOW);
  
  delay(500);

  digitalWrite(LED1, HIGH);
  delay(200);
  digitalWrite(LED2, HIGH);
  delay(200);
 

  digitalWrite(LED1, LOW);
  digitalWrite(LED2, LOW);
 
  //pinMode(MODE, INPUT);
  WiFi.begin(ssid, pass);
  timer.setInterval(3000L, checkBlynk); // check if connected to Blynk server every 3 seconds
  Blynk.config(auth);//, ssid, pass);

}

void loop()
{
  if (WiFi.status() != WL_CONNECTED)
  {
    if (DEBUG_SW) Serial.println("Not Connected");
  }
  else
  {
    if (DEBUG_SW) Serial.println(" Connected");
    Blynk.run();
  }

  timer.run(); // Initiates SimpleTimer
  if (MODE == 0)
    with_internet();
  else
    without_internet();
}

Copy the above code and open in arduino ide. before you upload the code you need to enter the ssid and password of your router or hotspot. And blynk authentication token that is sent by blynk on your registered email id.

After doing this much of modifications, Upload the code in your ESP32 Board after selecting right board and COM port.

Connection of Switches & Bulbs.

Connect all the bulb and switches as Shown in the Schematics below.

Now your homeautomation system is ready to work.

If you have any question or queries regarding this project please comment below.


Thank you so much for reading. 

3 thoughts on “SMT 4 Node Smart HomeAutomation PCB.|ESP32

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top