Bilgiler > ESP Program FireBase kod
ESP Program FireBase kod
//// Copyright 2015 Google Inc.//// Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at//// http://www.apache.org/licenses/LICENSE-2.0
//// Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License.//// FirebaseDemo_ESP8266 is a sample that demo the different functions// of the FirebaseArduino API.#include #include // Set these to run example.#define FIREBASE_HOST "esprole-561d9.firebaseio.com"#define FIREBASE_AUTH "1mNOCNpKjY4LxyPNz1Jrfq0ILb2xQ9z1ZCvS39O9"#define WIFI_SSID "Airties2"#define WIFI_PASSWORD "03MAYIS2016s@"void setup() { Serial.begin(9600); // connect to wifi. WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Serial.print("Wifi ye baglanıyor"); while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); } Serial.println(); Serial.print("Wifi ye baglandı. Yerel IP : "); Serial.println(WiFi.localIP()); Firebase.begin(FIREBASE_HOST,FIREBASE_AUTH); Serial.println("veri tabani adresi ve sifresi girildi"); delay(3000);} String durum; String eskiDurum="";void loop() { if (Firebase.failed()) { Serial.print("Veri tabanina baglanamadı hata: "); Serial.println(Firebase.error()); delay(3000); Firebase.begin(FIREBASE_HOST,FIREBASE_AUTH); wdt_enable(WDTO_15MS); return; } delay(3000); String durum = Firebase.getString("/ESP/D1"); if(!(durum.equals(eskiDurum))){ if(durum.equals("\"ON\"")){ Serial.println("Led Durum: ON" ); Firebase.setBool("LED", true); } if(durum.equals("\"OFF\"")){ Serial.println("Led Durum: OFF"); Firebase.setBool("LED", false); } eskiDurum = durum; } }
***