What is Industry 4.0 and what are some of the technologies that are driving it? Industry 4.0 is a term that refers to the fourth industrial revolution, which is characterized by the integration of digital technologies, such as artificial intelligence, cloud computing, big data, the internet of things, robotics, and 3D printing, into the manufacturing sector. Industry 4.0 aims to create smart factories that are more efficient, flexible, and responsive to customer needs and market changes. Some of the technologies that are enabling Industry 4.0 are: - Artificial intelligence (AI) : AI is the ability of machines to perform tasks that normally require human intelligence, such as reasoning, learning, decision-making, and problem-solving. AI can help optimize production processes, improve product quality, reduce costs, and enhance customer satisfaction. - Cloud computing: Cloud computing is delivering computing services, such as servers, storage, databases, software, and analytics, over t
How does home automation work?
Home automation is a network of hardware, communication, and electronic interfaces that work to integrate everyday devices with one another via the Internet. Each device has sensors and is connected through Wi-Fi, so you can manage them from your smartphone or tablet whether you’re at home, or miles away. This allows you to turn on the lights, lock the front door, or even turn down the heat, no matter where you are.
What are the benefits of home automation?
The purpose of a home automation system is to streamline how your home functions. Consider some of these benefits:
- Remote access: Control your home from mobile devices, including your laptop, tablet, or smartphone.
- Comfort: Use home automation to make your home a more comfortable, livable space. Preprogram your thermostat with your preferred settings so that your home is always at a comfortable temperature, set up smart speakers to play music when you get home from work, or adjust your lights to soften or brighten based on the time of day.
- Convenience: Program devices to turn on automatically at certain times, or access their settings remotely from anywhere with an Internet connection. When you don’t have to remember to lock the door behind you or switch off the lights, you can turn your attention to more important things.
- Increased safety: Smart fire detectors, carbon monoxide monitors, pressure sensors, and other home automation security features can help protect your home from disaster.
- Energy efficiency: Home automation allows you to be more mindful of your power usage. For example, you can save on energy bills by reducing the length of time that lights stay on, or by lowering temperatures when you leave a room.
Requirements
- Node MCU
- DHT11
- 4 Ch relay
- Toggle switches X 4
- Hi-Link (220V AC to 12V DC)
Circuit Diagram
Program
#define BLYNK_TEMPLATE_ID "**your ID***"
#define BLYNK_DEVICE_NAME "*****name*****"
#define BLYNK_AUTH_TOKEN "***********Your Auth***********"
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "WIFI NAME";
char pass[] = "WIFI PASSWORD";
bool fetch_blynk_state = true; //true or false
//#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>
#define DHTPIN D4 //D4 pin connected with DHT
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21 // DHT 21, AM2301
// define the GPIO connected with Relays and switches
#define RelayPin1 5 //D1
#define RelayPin2 4 //D2
#define RelayPin3 14 //D5
#define RelayPin4 12 //D6
#define SwitchPin1 10 //SD3
#define SwitchPin2 D3 //D3
#define SwitchPin3 13 //D7
#define SwitchPin4 3 //RX
#define wifiLed 16 //D0
//Change the virtual pins according the rooms
#define VPIN_BUTTON_1 V1
#define VPIN_BUTTON_2 V2
#define VPIN_BUTTON_3 V3
#define VPIN_BUTTON_4 V4
#define VPIN_BUTTON_C V5
#define VPIN_TEMPERATURE V6
#define VPIN_HUMIDITY V7
// Relay State
bool toggleState_1 = LOW; //Define integer to remember the toggle state for relay 1
bool toggleState_2 = LOW; //Define integer to remember the toggle state for relay 2
bool toggleState_3 = LOW; //Define integer to remember the toggle state for relay 3
bool toggleState_4 = LOW; //Define integer to remember the toggle state for relay 4
// Switch State
bool SwitchState_1 = LOW;
bool SwitchState_2 = LOW;
bool SwitchState_3 = LOW;
bool SwitchState_4 = LOW;
int wifiFlag = 0;
float temperature1 = 0;
float humidity1 = 0;
char auth[] = BLYNK_AUTH_TOKEN;
BlynkTimer timer;
DHT dht(DHTPIN, DHTTYPE);
// When App button is pushed - switch the state
BLYNK_WRITE(VPIN_BUTTON_1) {
toggleState_1 = param.asInt();
digitalWrite(RelayPin1, !toggleState_1);
}
BLYNK_WRITE(VPIN_BUTTON_2) {
toggleState_2 = param.asInt();
digitalWrite(RelayPin2, !toggleState_2);
}
BLYNK_WRITE(VPIN_BUTTON_3) {
toggleState_3 = param.asInt();
digitalWrite(RelayPin3, !toggleState_3);
}
BLYNK_WRITE(VPIN_BUTTON_4) {
toggleState_4 = param.asInt();
digitalWrite(RelayPin4, !toggleState_4);
}
BLYNK_WRITE(VPIN_BUTTON_C) {
all_SwitchOff();
}
void all_SwitchOff(){
toggleState_1 = 0;
digitalWrite(RelayPin1, HIGH);
Blynk.virtualWrite(VPIN_BUTTON_1, toggleState_1);
delay(100);
toggleState_2 = 0;
digitalWrite(RelayPin2, HIGH);
Blynk.virtualWrite(VPIN_BUTTON_2, toggleState_2);
delay(100);
toggleState_3 = 0;
digitalWrite(RelayPin3, HIGH);
Blynk.virtualWrite(VPIN_BUTTON_3, toggleState_3);
delay(100);
toggleState_4 = 0;
digitalWrite(RelayPin4, HIGH);
Blynk.virtualWrite(VPIN_BUTTON_4, toggleState_4);
delay(100);
Blynk.virtualWrite(VPIN_HUMIDITY, humidity1);
Blynk.virtualWrite(VPIN_TEMPERATURE, temperature1);
}
void checkBlynkStatus() { // called every 2 seconds by SimpleTimer
bool isconnected = Blynk.connected();
if (isconnected == false) {
wifiFlag = 1;
Serial.println("Blynk Not Connected");
digitalWrite(wifiLed, HIGH);
}
if (isconnected == true) {
wifiFlag = 0;
if (!fetch_blynk_state){
Blynk.virtualWrite(VPIN_BUTTON_1, toggleState_1);
Blynk.virtualWrite(VPIN_BUTTON_2, toggleState_2);
Blynk.virtualWrite(VPIN_BUTTON_3, toggleState_3);
Blynk.virtualWrite(VPIN_BUTTON_4, toggleState_4);
}
digitalWrite(wifiLed, LOW);
//Serial.println("Blynk Connected");
}
}
BLYNK_CONNECTED() {
// Request the latest state from the server
if (fetch_blynk_state){
Blynk.syncVirtual(VPIN_BUTTON_1);
Blynk.syncVirtual(VPIN_BUTTON_2);
Blynk.syncVirtual(VPIN_BUTTON_3);
Blynk.syncVirtual(VPIN_BUTTON_4);
}
Blynk.syncVirtual(VPIN_TEMPERATURE);
Blynk.syncVirtual(VPIN_HUMIDITY);
}
void readSensor(){
float h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
else {
humidity1 = h;
temperature1 = t;
// Serial.println(temperature1);
// Serial.println(humidity1);
}
}
void sendSensor()
{
readSensor();
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(VPIN_HUMIDITY, humidity1);
Blynk.virtualWrite(VPIN_TEMPERATURE, temperature1);
}
void manual_control()
{
if (digitalRead(SwitchPin1) == LOW && SwitchState_1 == LOW) {
digitalWrite(RelayPin1, LOW);
toggleState_1 = HIGH;
SwitchState_1 = HIGH;
Blynk.virtualWrite(VPIN_BUTTON_1, toggleState_1);
Serial.println("Switch-1 on");
}
if (digitalRead(SwitchPin1) == HIGH && SwitchState_1 == HIGH) {
digitalWrite(RelayPin1, HIGH);
toggleState_1 = LOW;
SwitchState_1 = LOW;
Blynk.virtualWrite(VPIN_BUTTON_1, toggleState_1);
Serial.println("Switch-1 off");
}
if (digitalRead(SwitchPin2) == LOW && SwitchState_2 == LOW) {
digitalWrite(RelayPin2, LOW);
toggleState_2 = HIGH;
SwitchState_2 = HIGH;
Blynk.virtualWrite(VPIN_BUTTON_2, toggleState_2);
Serial.println("Switch-2 on");
}
if (digitalRead(SwitchPin2) == HIGH && SwitchState_2 == HIGH) {
digitalWrite(RelayPin2, HIGH);
toggleState_2 = LOW;
SwitchState_2 = LOW;
Blynk.virtualWrite(VPIN_BUTTON_2, toggleState_2);
Serial.println("Switch-2 off");
}
if (digitalRead(SwitchPin3) == LOW && SwitchState_3 == LOW) {
digitalWrite(RelayPin3, LOW);
toggleState_3 = HIGH;
SwitchState_3 = HIGH;
Blynk.virtualWrite(VPIN_BUTTON_3, toggleState_3);
Serial.println("Switch-3 on");
}
if (digitalRead(SwitchPin3) == HIGH && SwitchState_3 == HIGH) {
digitalWrite(RelayPin3, HIGH);
toggleState_3 = LOW;
SwitchState_3 = LOW;
Blynk.virtualWrite(VPIN_BUTTON_3, toggleState_3);
Serial.println("Switch-3 off");
}
if (digitalRead(SwitchPin4) == LOW && SwitchState_4 == LOW) {
digitalWrite(RelayPin4, LOW);
toggleState_4 = HIGH;
SwitchState_4 = HIGH;
Blynk.virtualWrite(VPIN_BUTTON_4, toggleState_4);
Serial.println("Switch-4 on");
}
if (digitalRead(SwitchPin4) == HIGH && SwitchState_4 == HIGH) {
digitalWrite(RelayPin4, HIGH);
toggleState_4 = LOW;
SwitchState_4 = LOW;
Blynk.virtualWrite(VPIN_BUTTON_4, toggleState_4);
Serial.println("Switch-4 off");
}
}
void setup()
{
Serial.begin(9600);
pinMode(RelayPin1, OUTPUT);
pinMode(RelayPin2, OUTPUT);
pinMode(RelayPin3, OUTPUT);
pinMode(RelayPin4, OUTPUT);
pinMode(wifiLed, OUTPUT);
pinMode(SwitchPin1, INPUT_PULLUP);
pinMode(SwitchPin2, INPUT_PULLUP);
pinMode(SwitchPin3, INPUT_PULLUP);
pinMode(SwitchPin4, INPUT_PULLUP);
//During Starting all Relays should TURN OFF
digitalWrite(RelayPin1, !toggleState_1);
digitalWrite(RelayPin2, !toggleState_2);
digitalWrite(RelayPin3, !toggleState_3);
digitalWrite(RelayPin4, !toggleState_4);
dht.begin(); // Enabling DHT sensor
digitalWrite(wifiLed, HIGH);
//Blynk.begin(auth, ssid, pass);
WiFi.begin(ssid, pass);
timer.setInterval(2000L, checkBlynkStatus);
timer.setInterval(1000L, sendSensor);
Blynk.config(auth);
delay(1000);
if (!fetch_blynk_state){
Blynk.virtualWrite(VPIN_BUTTON_1, toggleState_1);
Blynk.virtualWrite(VPIN_BUTTON_2, toggleState_2);
Blynk.virtualWrite(VPIN_BUTTON_3, toggleState_3);
Blynk.virtualWrite(VPIN_BUTTON_4, toggleState_4);
}
}
void loop()
{
manual_control();
Blynk.run();
timer.run();
}
Comments
Post a Comment