Best homeautomation PCB with SMD Components, ESP32 Chip.

Best homeautomation PCB with SMD Components, ESP32 Chip.

Best homeautomation PCB with SMD Components, ESP32 Chip.

Hello friends, In this article I will introduce a homeautomation pcb which is smallest homeautomation pcb i have ever used.

By using esp32 chip and the  SMT components , I am able to reduce the size of pcb.

Now using this pcb we can make internet and manual control control homeautomation system. In which we are able to control our appliances via blynk app as well through manual switches, and also we can monitor the real time status of appliances in the blynk app.

These two onboard leds are used for wifi status.

If Esp32 is connected with wifi then both leds were glow and If wifi is not available only single led will glow.

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.

Ordering the PCBs at PCBWay

This project is sponsored by PCBWay. PCBWay is a full feature Printed Circuit Board manufacturing service.

Turn your DIY breadboard circuits into professional PCBs – get 10 boards for approximately $5 + shipping (which will vary depending on your country).

Once you have your Gerber files, you can order the PCB. Follow the next steps.

1. Download the Gerber files – click here to download the .zip file.

2. Go to PCBWay website and open the PCB Instant Quote page. 

3. PCBWay can grab all the PCB details and automatically fills them for you. Use the “Quick-order PCB (Autofill parameters)”.

4. Press the “+ Add Gerber file” button to upload the provided Gerber files.

And that’s it. You can also use the OnlineGerberViewer to check if your PCB is looking as it should.

Now select the shipping method , the one you prefer and has cost efficient.

You can increase your PCB order quantity and change the solder mask color. I’ve ordered the Green color.

Once you’re ready, you can order the PCBs by clicking “Save to Cart” and complete your order.

After approximately one week using the DHL shipping method, I received the PCBs at my place. As usual, everything comes well packed, and the PCBs are really high-quality. 

The letters on the silkscreen are really well-printed and easy to read. Additionally, the solder sticks easily to the pads.

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

Blynk Application.

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

Scan 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.

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


#define DEBUG_SW 0


#define Switch1 32
#define Relay1 19

#define Switch2 33
#define Relay2 21

#define Switch3 34
#define Relay3 22


#define Switch4 35
#define Relay4 23


#define LED1 26
#define LED2 25




int MODE = 0;


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

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


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 thing upload the code after selecting right board and COM port.

Press and hold the boot button and press the reset button once to make this module go inside the boot mode.

Connection of bulb and switches.

Connect all the bulbs & switches as per the above circuit diagram.

3 thoughts on “Best homeautomation PCB with SMD Components, ESP32 Chip.

  1. Hello, I’d like to make this project, but the Gerber file is no longer available? Are you able to reupload? Thank you

  2. This home automation PCB with SMD components and an ESP32 chip sound like a fantastic innovation in the field of smart home technology. The use of SMT components and the ESP32 chip has enabled a significant reduction in the size of the PCB, making it more compact and efficient. The ability to control appliances through both the Blynk app and manual switches provides flexibility and convenience to users. The inclusion of onboard LEDs for Wi-Fi status is a thoughtful addition, allowing users to quickly determine the connection status. The mention of using EasyEDA for designing the PCB and PCBWay for manufacturing demonstrates a systematic approach to the project. Overall, this seems like an impressive solution for home automation enthusiasts looking for a reliable and space-saving option.

Leave a Reply

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

Back To Top