Home
About Us
Achievement
Home
Raspberry-Pi Projects
_Raspberry Pi 4 Complete Guide
Arduino Project
_All Projects
Esp8266 Project
_All Projects
Esp32 Project
_Automation-with-feedback
Internet And Manual Home Automation Using Blynk App
Just Do Electronics
March 31, 2020
I
have shown to make your own Internet and Manually controlled home automation project along with the real-time feedback this time using Blynk App.
Circuit Diagram :-
OFF
ON
Code :-
//Prateek //www.prateeks.in #define BLYNK_PRINT Serial #include
#include
#include
#include
#include
BlynkTimer timer; void checkPhysicalButton(); int relay1State = LOW; int pushButton1State = HIGH; int relay2State = LOW; int pushButton2State = HIGH; int relay3State = LOW; int pushButton3State = HIGH; int relay4State = LOW; int pushButton4State = HIGH; #define AUTH "rw43t6t744wsggt6e43q4tghse" #define WIFI_SSID "Justdoelectronics" #define WIFI_PASS "justdoelectronics" #define SERVER "blynk-cloud.com " #define PORT 8442 #define RELAY_PIN_1 D7 #define RELAY_PIN_2 D6 #define RELAY_PIN_3 D5 #define RELAY_PIN_4 D4 #define PUSH_BUTTON_1 D1 #define PUSH_BUTTON_2 D2 #define PUSH_BUTTON_3 D3 #define PUSH_BUTTON_4 D0 #define VPIN_BUTTON_1 V12 #define VPIN_BUTTON_2 V13 #define VPIN_BUTTON_3 V14 #define VPIN_BUTTON_4 V15 #define OTA_HOSTNAME "Home_Automation" BLYNK_CONNECTED() { // Request the latest state from the server Blynk.syncVirtual(VPIN_BUTTON_1); Blynk.syncVirtual(VPIN_BUTTON_2); Blynk.syncVirtual(VPIN_BUTTON_3); Blynk.syncVirtual(VPIN_BUTTON_4); } // When App button is pushed - switch the state BLYNK_WRITE(VPIN_BUTTON_1) { relay1State = param.asInt(); digitalWrite(RELAY_PIN_1, relay1State); } BLYNK_WRITE(VPIN_BUTTON_2) { relay2State = param.asInt(); digitalWrite(RELAY_PIN_2, relay2State); } BLYNK_WRITE(VPIN_BUTTON_3) { relay3State = param.asInt(); digitalWrite(RELAY_PIN_3, relay3State); } BLYNK_WRITE(VPIN_BUTTON_4) { relay4State = param.asInt(); digitalWrite(RELAY_PIN_4, relay4State); } void checkPhysicalButton() { if (digitalRead(PUSH_BUTTON_1) == LOW) { // pushButton1State is used to avoid sequential toggles if (pushButton1State != LOW) { // Toggle Relay state relay1State = !relay1State; digitalWrite(RELAY_PIN_1, relay1State); // Update Button Widget Blynk.virtualWrite(VPIN_BUTTON_1, relay1State); } pushButton1State = LOW; } else { pushButton1State = HIGH; } if (digitalRead(PUSH_BUTTON_2) == LOW) { // pushButton2State is used to avoid sequential toggles if (pushButton2State != LOW) { // Toggle Relay state relay2State = !relay2State; digitalWrite(RELAY_PIN_2, relay2State); // Update Button Widget Blynk.virtualWrite(VPIN_BUTTON_2, relay2State); } pushButton2State = LOW; } else { pushButton2State = HIGH; } if (digitalRead(PUSH_BUTTON_3) == LOW) { // pushButton3State is used to avoid sequential toggles if (pushButton3State != LOW) { // Toggle Relay state relay3State = !relay3State; digitalWrite(RELAY_PIN_3, relay3State); // Update Button Widget Blynk.virtualWrite(VPIN_BUTTON_3, relay3State); } pushButton3State = LOW; } else { pushButton3State = HIGH; } if (digitalRead(PUSH_BUTTON_4) == LOW) { // pushButton4State is used to avoid sequential toggles if (pushButton4State != LOW) { // Toggle Relay state relay4State = !relay4State; digitalWrite(RELAY_PIN_4, relay4State); // Update Button Widget Blynk.virtualWrite(VPIN_BUTTON_4, relay4State); } pushButton4State = LOW; } else { pushButton4State = HIGH; } } void setup() { Serial.begin(115200); Blynk.begin(AUTH, WIFI_SSID, WIFI_PASS,"blynk-cloud.com", 8442); ArduinoOTA.setHostname(OTA_HOSTNAME); // For OTA - Use your own device identifying name ArduinoOTA.begin(); // For OTA pinMode(RELAY_PIN_1, OUTPUT); pinMode(PUSH_BUTTON_1, INPUT_PULLUP); digitalWrite(RELAY_PIN_1, relay1State); pinMode(RELAY_PIN_2, OUTPUT); pinMode(PUSH_BUTTON_2, INPUT_PULLUP); digitalWrite(RELAY_PIN_2, relay2State); pinMode(RELAY_PIN_3, OUTPUT); pinMode(PUSH_BUTTON_3, INPUT_PULLUP); digitalWrite(RELAY_PIN_3, relay3State); pinMode(RELAY_PIN_4, OUTPUT); pinMode(PUSH_BUTTON_4, INPUT_PULLUP); digitalWrite(RELAY_PIN_4, relay4State); // Setup a function to be called every 100 ms timer.setInterval(500L, checkPhysicalButton); } void loop() { Blynk.run(); ArduinoOTA.handle(); timer.run(); }
0 Comments
Newer
Older
ESP32 Interfacing With LDR Sensor
IoT Based Patient Health Monitoring System Using Blynk App
Measure CO2 Level in Air Using Arduino
ESP32 Led Blink With Push Button
Esp32 Cam Based Face Unlock
IoT Based Fingerprint Biometric Attendance System Using NodeMCU (Esp8266)
NRF Based Servo Motor Control
Home Security System Using Arduino, Pir Sensor And GSM Sim900A
DIY Weighing Scale using Load Cell HX711 & Arduino
Home Automation with GSM SIM800L DTMF & Voice Feedback Using Arduino Uno Board
YouTube
Like on Facebook
Follow on Twitter
Follow on Google+
Follow on Instagram
Subscribe on Youtube
Hi WelCome To My Website If you have a creative mind and want to learn Electronics even without studying it then FRIENDS this Website And Youtube Channel is for you, I am crazy creators who love making Electronics things. I have a bunch of more than 130 Tutorial Videos on My YouTube Channel and I upload a new Tutorial every Sunday.
Tags
Arduino Project
Esp32 Project
Esp8266 Project
0 Comments