Nodemcu firebase database configuration and step by step programming
Description:
Firebase-You will learn how to create your firebase account in this tutorial and create your first project from anywhere in the world to monitor a sensor in real time. It’s a tutorial to begin using firebase with nodemcu esp8266 unit, so I chose to use a variable resistor as a sensor to keep things simple.
But I’ll use the firebase for intermediate and advanced projects in my next tutorials.
what is Firebase
Firebase is a robust mobile development platform that provides you with the tools to build high-quality apps, broaden your user base and earn more money to cover the essentials of your business.
The basic terminology is divided into three parts:
- creating your app
- Improving the app’s quality
- Enterprise production
Let’s start without any further delay!!!
The components and tools Purchase links are given below:
Arduino Uno: https://amzn.to/39aq6ZT
Mega 2560: https://amzn.to/2SszMsI
nodemcu=https://amzn.to/2ZzhWpz
lm7805 Voltage Regulator: https://amzn.to/2ERYoTJ
330-ohm resistors pack: https://amzn.to/2Qj1Igg
female DC power jack socket: https://amzn.to/377Pg9M
470uf capacitors: https://amzn.to/2MrN3xR
5×7 cm Vero board: https://amzn.to/37b7KWO
female headers: https://amzn.to/350w6RE
connection wires: https://amzn.to/2MvOJXd
Super Starter kit for Beginners: https://amzn.to/398dliF
Jumper Wires: https://amzn.to/2SrnBwo
Bread Board: https://amzn.to/2MxV5FM
12v Adaptor: https://amzn.to/2MuOlZk
PCB plate: https://amzn.to/2MuwNMB
Variable Supply: https://amzn.to/39d0KdP
Digital Multimeter: https://amzn.to/34WbVoa
Vero Board / stripboard: https://amzn.to/39nL9Zg
Soldering iron kit: “best” You guys should definitely purchase this: https://amzn.to/2PVwexF
Solder wire: https://amzn.to/2QlOvTS
Wire Stripper: https://amzn.to/353tYJa
wirecutter: https://amzn.to/2tV2lFj
PCB small portable drill machine: https://amzn.to/2MvQqnx
DISCLAIMER:
Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!
Firebase Database Configuration:
Open your browser online and go to console.firebase.google.com,
Click on the project to add it.
Write the name of your project
Check all the boxes and press the project create button.
Click to go on.
You can see Authentication Database Storage Hosting Functions and ML Kit by clicking the develop button.
Let’s start with the settings of the project first …
Click the accounts for the service …
Click the secrets for the database …
Select and copy the view ….
Then open the firebase authentication program and paste it …
Now click on the server for the firebase host …
Select a database realtime …
Copy and paste this link into the programming …
Now we have completed our settings, now we can click the check button to compile our program and check for any errors.
Let’s discuss the diagram of the circuit now …
Circuit Diagram:
As you can see, the circuit diagram is really easy. Connect the variable resistor’s right and left legs with the 3.3v and GND wifi module Nodemcu esp8266. Connect the variable resistor middle leg with the Nodemcu A0 pin.
Programming:
Arduino Jason:
https://github.com/bblanchon/ArduinoJson
FirebaseArduino library:
#include <ESP8266WiFi.h> #include <SoftwareSerial.h> #include <FirebaseArduino.h> #include <ArduinoJson.h> #include <ESP8266HTTPClient.h> // Set these to run example. #define FIREBASE_HOST "fahad-ba398.firebaseio.com" #define FIREBASE_AUTH "d0vy3ZgNMiwszDZsZ3iT1jg9enRLbKypvadDEPz1" #define WIFI_SSID "ZONG MBB-E8231-6E63" #define WIFI_PASSWORD "08659650" String myString; int vr = A0; // variable resistor connected int sdata = 0; // The variable resistor value will be stored in sdata. void setup() { // Debug console Serial.begin(9600); pinMode(vr ,INPUT); // connect to wifi. pinMode(D0,OUTPUT); 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.setString("Variable/Value","fahad"); } void loop() { sdata = analogRead(vr); myString = String(sdata); Serial.println(myString); Firebase.setString("Variable/Value",myString); delay(1000); }