-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmart_room.ino
56 lines (43 loc) · 1.19 KB
/
smart_room.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#define light1 D5
#define light2 D6
#define FIREBASE_HOST "Firebase-HostName"
#define FIREBASE_AUTH "Firebase-Secret-Token"
#define WIFI_SSID "wifi-name"
#define WIFI_PASSWORD "wifi-password"
void setup() {
pinMode(light1,OUTPUT);
pinMode(light2,OUTPUT);
digitalWrite(light1,HIGH);
digitalWrite(light2,HIGH);
Serial.begin(115200);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("connected: ");
Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}
void loop() {
int status1 = Firebase.getString("firebase/bulb1").toInt();
int status2 = Firebase.getString("firebase/bulb2").toInt();
if(status1){
digitalWrite(light1,LOW);
Serial.println("Turning light-1 ON!!");
}else{
digitalWrite(light1,HIGH);
Serial.println("light-1 Going DOWN.");
}
if(status2){
digitalWrite(light2,LOW);
Serial.println("Turning light-2 ON!!");
}else{
digitalWrite(light2,HIGH);
Serial.println("light-2 Going DOWN.");
}
}