Skip to content

Instantly share code, notes, and snippets.

@yakutozcan
Created November 7, 2017 19:55
Show Gist options
  • Save yakutozcan/909b2e785d1c3cb3c30c16ec086edade to your computer and use it in GitHub Desktop.
Save yakutozcan/909b2e785d1c3cb3c30c16ec086edade to your computer and use it in GitHub Desktop.
Firebase,IoT,Google,Arduino,NodeMCU
////yakutozcan.blogspot.com
// 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 <ESP8266WiFi.h>
#include <FirebaseArduino.h>
// firebase url
#define FIREBASE_HOST "bloggerled-89c15.firebaseio.com"
//firebase realtime database token
#define FIREBASE_AUTH "********************"
//Wifi adi
#define WIFI_SSID "wifiadi"
//Wifi Sifre
#define WIFI_PASSWORD "wifisifre"
//Led pini
#define LED LED_BUILTIN
void setup() {
pinMode(LED,OUTPUT);
digitalWrite(LED,0);
Serial.begin(9600);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("baglaniyor");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("baglandi, ip: ");
Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
Firebase.setInt("LEDStatus",0);
}
void loop() {
//Firebase den LedStatus alanını çekiyoruz
Serial.println(Firebase.getInt("LEDStatus"));
//0 ise aç 1 ise kapat :)
if(Firebase.getInt("LEDStatus"))
{
digitalWrite(LED,HIGH);
}
else
{
digitalWrite(LED,LOW);
}
if (Firebase.failed())
{
Serial.print("HATA:");
Serial.println(Firebase.error());
return;
}
delay(100);
}
//yakutozcan.blogspot.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment