Project showcase
Real-Time Data Access Using Arduino and Firebase

Real-Time Data Access Using Arduino and Firebase © GPL3+

A good project for leaning and implementing serial communication, real-time data access, and using Firebase.

  • 5,978 views
  • 5 comments
  • 9 respects

Components and supplies

Apps and online services

About this project

Hello there!

I started working on this project as a part of my collage work. This project is basically a real time data monitoring system and developed with love and passion. :-P

This project has three major parts

1) Data collecting components (sensors)

2) Microcontrollers

3) An online database service (Firebase in this case)

Now, coming to how these things work together?

So, the data collecting components collect data in real time from an environment and are interfaced with the help of an Arduino Uno. The Arduino serially sends this data to NodeMCU which uploads the data on to Firebase.

Once the data is on firebase, it can be accessed from anywhere in the world with an internet connection of course!

Just integrate the database in your website or application and you are good to go!

Code

serial communication C/C++
*To be uploaded on the arduino uno*
This is the code for serial communication between arduino uno and nodeMCU (esp8266).
#include <SoftwareSerial.h>
SoftwareSerial ArduinoUno(3,2);
int n;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  ArduinoUno.begin(4800);
  
pinMode (3,INPUT);
pinMode (2,OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:
  n=analogRead(A2);
   ArduinoUno.print(n);
  ArduinoUno.println("\n");
  Serial.println(n);
  delay(300);
}
Uploading data to firebaseC/C++
*to be uploaded on the nodeMCU*
This code uploads the data received by the nodeMCU on to firebase.
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#include <SoftwareSerial.h>

// Set these to run example.
#define FIREBASE_HOST "***********************************"
#define FIREBASE_AUTH "***********************************"
#define WIFI_SSID "WiFi ssid"
#define WIFI_PASSWORD "PASSWORD"
SoftwareSerial esp(D2,D3);

void setup() {
  Serial.begin(9600);
  esp.begin(4800);

  // 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);
}

int n = 0;
float val;

void loop() {

   while(esp.available()>0)
  {
     float val = esp.parseFloat();
     if(esp.read()=='\n')
     {
       Serial.println(val);
       
     }

  // set value
  Firebase.setFloat("number", val);
  // handle error
  if (Firebase.failed()) {
      Serial.print("setting /number failed:");
      Serial.println(Firebase.error());  
      return;
  }
  delay(100);
  


  // get value 
  Serial.print("number: ");
  Serial.println(Firebase.getFloat("number"));
  delay(100);


  // append a new value to /logs
  String name = Firebase.pushInt("logs", n++);
  // handle error
  if (Firebase.failed()) {
      Serial.print("pushing /logs failed:");
      Serial.println(Firebase.error());  
      return;
  }
  Serial.print("pushed: /logs/");
  Serial.println(name);
  delay(100);
  }
}

Schematics

circuit
This one is just for reference. It will be updated soon.
De zq6jfiacnd

Comments

Similar projects you might like

Send MKR1000 Data to Google Sheets

Project tutorial by Stephen Borsay

  • 9,998 views
  • 28 comments
  • 31 respects

IOT2020 - RFID Real-Time Access Control

Project tutorial by Team SIT

  • 7,749 views
  • 2 comments
  • 27 respects

Temperature Streaming with Arduino + Big Data Tools

Project showcase by Gabriel Rodriguez

  • 5,407 views
  • 1 comment
  • 28 respects

Export Data from Arduino to Excel Sheet

Project showcase by ahmed ismail

  • 14,781 views
  • 1 comment
  • 7 respects

Temperature and Humidity Data Logger

Project tutorial by Wimpie van den Berg

  • 23,409 views
  • 2 comments
  • 22 respects

Race Car Dashboard (Online Connectivity)

Project showcase by Team Jatayu

  • 15,283 views
  • 48 comments
  • 31 respects
Add projectSign up / Login