Google FireBase IOT Automation
download complete files from this link-
https://drive.google.com/file/d/10Z-_5Oepy14nl700qrr_yLoSvEAbd38S/view?usp=sharing
download the required Library from Github link--https://github.com/anokhramesh/4relaycontfirebasesp8266ok
https://drive.google.com/file/d/1iYn-QB8AXtyHERfikzX7EErFWZogudjH/view?usp=sharing
Firebase IOT Application aia file link:-https://creator.kodular.io/#6605302336061440
#include <FirebaseESP8266.h> // install the FirebaseESP8266 Library
#include <ESP8266WiFi.h>// install the ESP8266 WIFI library
#define ssid "dewa406"//Enter the Wifi SSID
#define password "Ramesh16384"//Enter wifi password
#define FIREBASE_HOST "Enter the Firebase Database project url here"//paste database url
#define FIREBASE_AUTH "Enter Firebase project Aut token here "//Enter firebase token
FirebaseData firebaseData;
int LEDPIN_1 = D0; //initialize the LED1 to D0 Pin
int LEDPIN_2 = D1; //initialize the LED2 to D1 Pin
int LEDPIN_3 = D2; //initialize the LED3 to D2 Pin
int LEDPIN_4 = D3; //initialize the LED4 to D3 Pin
void setup() {
Serial.begin(9600);
WiFi.begin (ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println ("");
Serial.println ("WiFi Connected!");
Firebase.begin(FIREBASE_HOST,FIREBASE_AUTH);
pinMode(LEDPIN_1,OUTPUT);//initialize the LED1 OUTPUT HIGH
pinMode(LEDPIN_2,OUTPUT);//initialize the LED2 OUTPUT HIGH
pinMode(LEDPIN_3,OUTPUT);//initialize the LED3 OUTPUT HIGH
pinMode(LEDPIN_4,OUTPUT);//initialize the LED4 OUTPUT HIGH
}
void loop() {
if (Firebase.get(firebaseData,"/Led1")) {
if (firebaseData.dataType() == "string") {
String led1 = firebaseData.stringData();
if (led1=="1"){
digitalWrite(LEDPIN_1,HIGH); //led 1 is ON
}
else if (led1=="0"){
digitalWrite(LEDPIN_1,LOW);//led 2 if OFF
}}}
if (Firebase.get(firebaseData,"/Led2")) {
if (firebaseData.dataType() == "string") {
String led2 = firebaseData.stringData();
if (led2=="1"){
digitalWrite(LEDPIN_2,HIGH);//led2 is ON
}
else if (led2=="0"){
digitalWrite(LEDPIN_2,LOW);// Led2 os OFF
}}}
if (Firebase.get(firebaseData,"/Led3")) {
if (firebaseData.dataType() == "string") {
String led3 = firebaseData.stringData();
if (led3=="1"){
digitalWrite(LEDPIN_3,HIGH);//Led3 is ON
}
else if (led3=="0"){
digitalWrite(LEDPIN_3,LOW);//Led3 is OFF
}}}
if (Firebase.get(firebaseData,"/Led4")) {
if (firebaseData.dataType() == "string") {
String led4 = firebaseData.stringData();
if (led4=="1"){
digitalWrite(LEDPIN_4,HIGH);//Led is ON
}
else if (led4=="0"){
digitalWrite(LEDPIN_4,LOW);//Led is OFF
}}}
}
Comments
Post a Comment