Connect Google Firebase with Nodemcu ESP8266

  1. Nodemcu ESP8266
  2. Firebase Account ( We are going to work with the firebase realtime database )
  3. Basic Knowledge about Arduino

Install Arduino JSON Library

​Install Firebase Library

Create a Real-Time Database on Firebase

  1. First, click on Go to console
#include <ESP8266WiFi.h>
#include <SoftwareSerial.h>
#include <FirebaseArduino.h>
#include <ArduinoJson.h>
#include <ESP8266HTTPClient.h>

// Set these to run example.
#define FIREBASE_HOST “nodemcu-xxxxx-xxxxx-xxxx.firebaseio.com”
#define FIREBASE_AUTH “xGJVxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxZz”
#define WIFI_SSID “Nokia 5” //provide ssid (wifi name)
#define WIFI_PASSWORD “xxxxxxxxx” //wifi password
void setup()
{

// Debug console
Serial.begin(9600);
// 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);
if(Firebase.failed())
{
Serial.print(Firebase.error());
}
else{

Serial.print(“Firebase Connected”);
Firebase.setString(“Senura/Value”,”0");
}
}

void loop()
{
for(int i = 0; i <= 100; i++)
{
Firebase.setInt(“/Senura/Value”,i);
delay(1000);
}

}

Testing

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Senura Vihan Jayadeva

Senura Vihan Jayadeva

93 Followers

Software Engineering undergraduate of Sri Lanka Institute of Information Technology | Physical Science Undergraduate of University of Sri Jayewardenepura