Created
December 24, 2019 11:41
-
-
Save sidishere/a6e5cb66f82a6926792a01aebda73dde to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino | |
#include <FirebaseArduino.h> //needed for Wifimanager library | |
#include <DNSServer.h> | |
#include <ESP8266WebServer.h> | |
#include <WiFiManager.h> //led init | |
#define RED_LED D0 | |
#define GREEN_LED D1 | |
#define BLUE_LED D2 //Dataabase init | |
#define FIREBASE_HOST "YOUR HOST ID" //link of api | |
#define FIREBASE_AUTH "YOUR AUTH ID" //database secret | |
void setup() | |
{ | |
pinMode(RED_LED,OUTPUT); | |
pinMode(GREEN_LED,OUTPUT); | |
pinMode(BLUE_LED,OUTPUT); | |
Serial.begin(115200); | |
WiFiManager wifiManager; | |
wifiManager.autoConnect("AutoConnectAP"); | |
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH); //connect to Database | |
} | |
void loop() | |
{ | |
String smartACstatus= Firebase.getString("smartAC/status"); | |
Serial.println("smartAC status" +smartACstatus); | |
String smartBulbstatus= Firebase.getString("led2/status"); | |
Serial.println("smartBulbstatus" +smartBulbstatus); | |
String smartFanstatus= Firebase.getString("led3/status"); | |
Serial.println("smartFanstatus" +smartFanstatus); | |
if (smartACstatus=="ON") digitalWrite(RED_LED,HIGH); | |
else | |
digitalWrite(RED_LED,LOW); | |
if(smartBulbstatus=="ON") | |
digitalWrite(GREEN_LED,HIGH); | |
else | |
digitalWrite(GREEN_LED,LOW); | |
if (smartFanstatus=="ON") | |
digitalWrite(BLUE_LED,HIGH); | |
else | |
digitalWrite(BLUE_LED,LOW); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment