Skip to main content

Home automation with IOT

 Home automation with IOT 

What is the Blynk app?

The Blynk app is simply an open-source platform designed for iOS / Android devices to remotely control and view hardware. It is also designed for the Internet of Things (IoT). The dashboard can be customized in a very useful way by using various Widgets such as Buttons, Displays, Sliders included in this Blynk app. Also, this widget allows you to turn devices on / off and view sensor values. Lastly, you can view, store and visualize data through this.


Install Blynk Library in Arduino IDE

There are two ways to install Blynk Library for Arduino IDE:

  1. Using built-in library manager in Arduino IDE

  2. Installing Blynk library as ZIP file in Arduino IDE

1.Install Blynk Library using built-in library manager in Arduino IDE

To install a new library into your Arduino IDE you can use the Library Manager (available from IDE version 1.6.2). Open the IDE and click to the "Sketch" menu and then Include Library > Manage Libraries.

Then the Library Manager will open and you will find a list of libraries that are already installed or ready for installation. Search for Blynk library and in the version selection choose the latest version to date

Finally click on Install and wait for the IDE to install the new library. Downloading may take time depending on your connection speed. Once it has finished, an Installed tag should appear next to the Bridge library. You can close the library manager.


You can now find the new library available in the Sketch > Include Library menu.


2. Install Blynk as ZIP file in Arduino IDE

Blynk library is available as a downloadable ZIP. Starting with Arduino IDE version 1.0.5, you can install 3rd party libraries in the IDE.

Download Blynk Library by clicking the button: Download Blynk Library

**Do not unzip the downloaded library, leave it as is.


In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library. 

At the top of the drop down list, select the option to "Add .ZIP Library''.

  1. Return to the Sketch > Include Library menu. menu. You should now see the library at the bottom of the drop-down menu. It is ready to be used in your sketch. The zip file will have been expanded in the libraries folder in your Arduino sketches directory.

  2. The Library will be available to use in sketches, but with older IDE versions examples for the library will not be exposed in the File > Examples until after the IDE has restarted.




Sign Up

  1. Open your computer browser.

  2. Search blynk.cloud in the search bar.

  3. Then sign up with a new account with your mail.

  4. Then verify your account on your gmail.


  1. Then click on the create password and give your own password and remind it for next time sign in. Then click on Next.





  1. Now click on skip.


  1. Then click on the cancel button.




  1. Your account is successfully completed.












LED turn on/off using blynk cloud and your mobile phone on the NODEMCU


Go to blynk cloud website and login your blynk account. Then follow the following process.

  1. Now click on the Template as shown in figure.


  1. Then click on the “New Template”.

  1. Now give your template name of project name and change the hardware into ESP8266 or ESP32 also work for NodeMCU ESP8266. Or you can describe also in description box. Then click on the ‘Done’ button.

(******Dear all, we will recommend only ESP8266 for this and further projects. So here the described method is shown for only ESP8266.)

  1. Now go to the Datastream section and click on New datastream to create a medium between to pass the data. Then choose a virtual pin and select it.



Then change the name and pin to choose any you want. Data type as it is. Units can be changed as you want(i.e for distance it could be meter). Min and Max value refer to minimum and Maximum value. To turn on or off light it will be 0 and 1 respectively. But for an example if you want to show temperature it could be from 0 10 100. Then save it.


  1. Now go to the web dashboard section. And drag the switch button to turn on and off light. But to monitor the sensor data or any data you can choose gauge and to receive and send text you can choose terminal. For the present time we will choose a switch. Then save it.

  1. Now click on the search button as shown below.


  1. Then click on New Device.


  1. Then click on ” From Template”. And choose the template name and device name as you created before. Then click on create.


  1. Now your dashboard will look like below. And remind that from this section you need template id, device name and auth token as shown below if right side with black background. Or this can be seen from device info also.






















For mobile app:


Download the mobile app named as BLYNK IOT from play store and install it.



















Test your blynk and nodemcu using a simple code.

  1. Go to your arduino IDE and open the example as below.

Files>Examples>Blynk>Boards_Wifi>ESP8266_Standalone


You can copy this code and paste it.

#define BLYNK_PRINT Serial

/* Fill-in your Template ID (only if using Blynk.Cloud) */

//#define BLYNK_TEMPLATE_ID   "YourTemplateID"

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>


// You should get Auth Token in the Blynk App.

// Go to the Project Settings (nut icon).

char auth[] = "YourAuthToken";


// Your WiFi credentials.

// Set password to "" for open networks.

char ssid[] = "YourNetworkName";

char pass[] = "YourPassword";


void setup()

{

  // Debug console

  Serial.begin(9600);


  Blynk.begin(auth, ssid, pass);

}


void loop()

{

  Blynk.run();

}


2.Then change the auth token, ssid password as follows:


3. Change the  SSID (Wifi name) and password also.

**if there is a process to login for wifi access then you should not use such type of wifi. You can use either laptop hotspot or mobile hotspot but the hotspot should not be in 5GHz . It means it must be in 2GHz.**

The code will be like this after changing your template id and ssid name password.


#define BLYNK_PRINT Serial


#define BLYNK_TEMPLATE_ID "TMPL09mgzGQd"

#define BLYNK_DEVICE_NAME "project1"

#define BLYNK_AUTH_TOKEN "qT1XpiEBwwW-U54IdimqyOfrEtFFNHsp"

/* Fill-in your Template ID (only if using Blynk.Cloud) */

//#define BLYNK_TEMPLATE_ID   "YourTemplateID"

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.

// Go to the Project Settings (nut icon).

char auth[] = "qT1XpiEBwwW-U54IdimqyOfrEtFFNHsp";

// Your WiFi credentials.

// Set password to "" for open networks.

char ssid[] = "YourNetworkName";

char pass[] = "YourPassword";

void setup()

{

  // Debug console

  Serial.begin(9600);


  Blynk.begin(auth, ssid, pass);

}


void loop()

{

  Blynk.run();

}



4. Now upload it after choosing the port and go to your blynk dashboard. You will see there online in your search button



Before uploading code

After uploading code you will see online.





Now lets try lo control led from 

  1. Add the following code part in the above code.Or you can copy and paste following code but you have to change the template id and ssid name password.

  2. Components required:

i) Breadboard

ii) NodeMCU ESP8266

iii) LED

iv) Jumper wires

v) 10 Kohm resistor

vi) Type B USB cable


Code:


#define BLYNK_PRINT Serial

#define BLYNK_TEMPLATE_ID "TMPL09mgzGQd"

#define BLYNK_DEVICE_NAME "project1"

#define BLYNK_AUTH_TOKEN "qT1XpiEBwwW-U54IdimqyOfrEtFFNHsp"


#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>


char auth[] = "qT1XpiEBwwW-U54IdimqyOfrEtFFNHsp";


// Your WiFi credentials.

// Set password to "" for open networks.

char ssid[] = "RAN-2GHz";

char pass[] = "PR4B1DH1-2";

int relay1 = 12;  // D6 pin 

BLYNK_WRITE(V1)

{

  int led1=param.asInt();

  digitalWrite(relay1,led1);

}


void setup()

{

  // Debug console

  Serial.begin(9600);

  pinMode(relay1,OUTPUT);

   digitalWrite(relay1, LOW);

  Blynk.begin(auth, ssid, pass);

}

void loop()

{

  Blynk.run();

}

Circuit Diagram:


Now check by turning off the switch from your computer’s dashboard. Then also check from mobile app.


Now to turn off and on your AC bulb

The code and the blynk dashboard are the same till now. We will change only the circuit diagram.

The circuit diagram is shown below:


Components required:

  1. Single channel relay module

  2. 2 pin

  3. 9 W LED bulb

  4. AC wire

  5. Bulb holder

  6. Breadboard

  7. ESP8266

  8. Type USB cable

  9. Jumper wire


Circuit diagram:


Warning

Don't touch the relay after connecting the AC supply otherwise you will be shocked.


If you use two channel relay then you have to change code format. In setup, initially you have to give HIGH because the two channel relay is active in LOW. Then in the dashboard while you choose the virtual pin then minimum value 1 and maximum value 0. Then the circuit works properly. Similarly another part is that you have to supply external DC voltage greater than 5v and less than 12 volt to run 2 channel relay. Because the power source from nodemcu is not sufficient to run the relay.











Comments

Popular posts from this blog

IOT based Weather monitoring system

  IOT based Weather monitoring system  Introduction In today's world, the importance of accurate and real-time weather monitoring cannot be overstated. Weather conditions significantly impact various aspects of life, from agriculture and transportation to disaster management and daily activities. With the advancement of technology, it is now possible to develop sophisticated yet affordable weather monitoring systems that can provide real-time data and alerts. One such innovative approach involves using the NodeMCU microcontroller and the DHT11 sensor. This project aims to design and implement a weather monitoring system that leverages these technologies to measure and report environmental parameters such as temperature and humidity. Objectives The primary objectives of this project are as follows: Design and Implementation: To design and implement a reliable weather monitoring system using the NodeMCU microcontroller and the DHT11 sensor. Real-time Data Acquisition: To acquire...

2017//2(b)//Engineering Eco//KU

A loan of $10,000 is to be repaid over a period of eight years. During the first four years, exactly half of the loan principal is to be repaid (along with accumulated compound interest) by a uniform series of payments of A1 dollar per year. The other half of the loan principal is to be repaid over four years, with accumulated interest, by a uniform series of payments of A2 dollar per year, If i=9% per year, what are A1 and A2?

2018//2(b)//Engineering Eco//KU

A large lithium-ion phosphate battery pack for an industrial application is expected to save $20,000 in annual energy expenses over its 6-year life. For a 3-year simple payback period, the permissible capital investment is $60,000. What is the internal rate of return on this $60,000 battery pack if it has a residual value of $10,000 at the end of 6 years? The MARR is 18% per year.