Header Ads

IOT with Firebase: Control Led Using Firebase Console #Part2




As we continue to learn IOT with Firebase using NodeMCU, we cover ON/OFF a LED connected to Arduino using Firebase Console .
I hope you find using Firebase with IOT to be a breeze after this tutorial. Please share your alternative problem solutions. All of the code and a transcript follows the video below.


If you like videos like this consider donating $1, or simply turn off AdBlocker. Either helps me to continue making tutorials

Transcript / Cheat Sheet


Arduino NodeMCU Code:


// 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>
// Set these to run example.
#define FIREBASE_HOST "esri-eea51.com"
#define FIREBASE_AUTH "qULRQbnuz-------------Q1FxHvM"
#define WIFI_SSID "kavin"
#define WIFI_PASSWORD "123456345"
void setup() {
Serial.begin(9600);
pinMode(D1, OUTPUT);
// connect to wifi.
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);
Firebase.set("LED_STATUS", 0);
}
int n = 0;
void loop() {
// get value
n = Firebase.getInt("LED_STATUS");
// handle error
if (n==1) {
Serial.println("LED ON");
digitalWrite(D1,HIGH);
return;
delay(10);
}
else {
Serial.println("LED OFF");
digitalWrite(D1,LOW);
return;
}
}
At last we are end up with great tutorial on IOT home automation using Firebase Console, NodeMCU.





4 comments:

  1. i got:
    Exception (28):
    epc1=0x402039ca epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

    ctx: cont
    sp: 3ffefaa0 end: 3ffeffc0 offset: 01a0

    >>>stack>>>
    ......

    ReplyDelete
  2. I alway getting a trouble with like this
    Arduino: 1.8.7 Hourly Build 2018/09/10 06:33 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, 4M (1M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

    Build options changed, rebuilding all
    Multiple libraries were found for "FirebaseArduino.h"
    Used: C:\Users\TVSH\Documents\Arduino\libraries\firebase-arduino-master
    In file included from C:\Users\TVSH\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseArduino.h:22:0,

    Not used: F:\ARDUINO\arduino-nightly\libraries\firebase-arduino-master
    Not used: F:\ARDUINO\arduino-nightly\libraries\firebase-arduino-master
    Not used: F:\ARDUINO\arduino-nightly\libraries\firebase-arduino-master
    from F:\ARDUINO\arduino-nightly\libraries\firebase-arduino-master\examples\FirebaseDemo_ESP8266\FirebaseDemo_ESP8266.ino:21:

    Not used: F:\ARDUINO\arduino-nightly\libraries\firebase-arduino-master
    C:\Users\TVSH\Documents\Arduino\libraries\firebase-arduino-master\src/Firebase.h:26:25: fatal error: ArduinoJson.h: No such file or directory

    #include

    ^

    compilation terminated.

    exit status 1
    Error compiling for board NodeMCU 1.0 (ESP-12E Module).

    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.

    ReplyDelete
    Replies
    1. Error compiling for board NodeMCU 1.0 (ESP-12E Module).

      Delete
    2. ok, i just download library ArduinoJson.h

      Delete

Powered by Blogger.