IOT Based Smart Parking System with Firebase Realtime Database

IOT Based Smart Parking System with Firebase Realtime Database It is smart Parking system in which I Have used IR sensor (Infrared obstacle detection) to detect the incoming or outgoing cars in parking areas   so, car owners are facing problems while searching parking in High Traffic Areas.

In This Project I used IR Sensors to detect incoming or outgoing cars in Parking as well as Servo motor is used to Open and Close the gate When any care come in or goes out of parking IR Sensor detect it and increase available slots by +1 or decrease available slots by -1. 16x2 LCD is used to display total Slots and Available slots. To make Anyone can check the available slots Far Away from a Parking Area I used Nodemcu ESP8266 to Upload Available Slots Data to Firebase Realtime Database and I make an android Application Which will Retrieve data from Firebase Realtime Database.


Hardware Required :

Software Required :

  

Arduino Library's Used :  

  • Servo
  • LiquidCrystal
  • SoftwareSerial
  • Firebase Arduino
  •  ESP8266WiFi

 

Download Library's & Android app AIA file : Google Drive

Note : Update Your Nodemcu and Arduino Board In Arduino IDE if not or it will Make Error While Compiling.

Also Read :


Circuit Diagram :



Important Points :
Creating Firebase Database :

  • Go to Firebase console.
  • Click on Add Project and Give Name to Your Project and Click on Continue Create Project.
  • Go to Realtime Database and Click on Create Database in test mode.
  • Click on add Child on Realtime database and create database.
Firebase database url

Modify Android App AIA File :

  • Open creator.kodular.io website Create or Login with your account.
  • Click on Import Project.
  • Download AIA file given in above Google Drive link and open SmartParking.aia File and click Import.
  • Find all Component Click firebase_Database.
  • Firebase Database change Firebase Token, Firebase URL and Project bucket.
  • Go to Blocks And Change "Available Slots" to your tag name which data you want to Get.(note : This tag is indie project bucket which we created earlier firebase.)
  • Export Project as Android Apk.

SoftwareSerial Library Issue with Servo motor :

  • Supported Baud rate for SoftwareSerial Library is 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, and 115200.
  • While using Baud rate of 9600 or less than 9600 Servo motor will jitter in ideal Condition.
  • To Avoid this Baud rate for Serial Communication Used must be Above 9600.
  • I am Using 115200 Baud rate it Works just fine.
  • Alternative Solution For This is we can also use I2C and SPI Communication Protocols.

Firebase Arduino Library mandatory edit :

  • Go to your Arduino IDE installation Folder and find Firebase arduino library and open src folder.
C:\Program Files (x86)\Arduino\libraries\firebase-arduino-master\src

FirebaseArduino
  • Open Your Firebase Console go to your Project Realtime Database.
Firebase database

  • Copy Link of Firebase Database.
Firebase database link

GRC Fingerprint

  • You will get latest fingerprint In table Below "Security Certificate's Authentic Fingerprint" Copy that String.
Custom Site Fingerprinting


  • Edit FirebaseHttpClient.h in Notepad.
  • Search in Notepad for "static const char kFirebaseFingerprint[] =".
Edit Fingerprint

  • Change Fingerprint and Save the File.

Also Read :

Programming :

Nodemcu Code


#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#include <SoftwareSerial.h>

SoftwareSerial s(D6,D5);

                          
#define FIREBASE_HOST "iot-based-smart-parking-84476-default-rtdb.firebaseio.com"                     //Your Firebase Project URL goes here without "http:" , "\" and "/"
#define FIREBASE_AUTH "GjWwc5ImRtmh48Fc0vqBiewSkn63kBSArG56Q1Bn"                      //Your Firebase Database Secret goes here

#define WIFI_SSID "DIGISOL"                                               //WiFi SSID to which you want NodeMCU to connect
#define WIFI_PASSWORD "mastidahi"                                      //Password of your wifi network 

int8_t indexOfA;
char c;
String Space; 
String dataIn;

int firebaseSpace;

int val=0;

void setup() {

  s.begin(115200);
  Serial.begin(57600);

  Serial.println("Serial communication started\n\n"); 
           
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);                                     //try to connect with wifi
  Serial.print("Connecting to ");
  Serial.print(WIFI_SSID);


  
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }

  
  Serial.println();
  Serial.print("Connected to ");
  Serial.println(WIFI_SSID);
  Serial.print("IP Address is : ");
  Serial.println(WiFi.localIP());                                            //print local IP address
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);   // connect to firebase
delay(1000);
}

void loop() { 
  
  while(s.available()>0){
      c = s.read();

      if(c=='/n') {break;}
      else        {dataIn+=c;}
    }
  if(c='/n'){
    
    indexOfA = dataIn.indexOf("A");

    Space = dataIn.substring(0, indexOfA);
    //Parse_the_data();

    Serial.println("Available Space is = " + Space);
    Serial.println("========================");
    c=0;
    dataIn="";
    }

  delay(1000);

  firebaseSpace = Space.toInt();
  Serial.println("firebaseSpace = " + firebaseSpace);


// Firebase Error Handling ************************************************
  if (Firebase.failed())
  { delay(500);
    Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
    Serial.println(Firebase.error());
  Serial.println("Connection to firebase failed. Reconnecting...");
  delay(500);
  }
  
 else { 
    Serial.println("Everything is ready!");
    delay(300); Serial.println("Everything is ready!");
    delay(300); Serial.println("Everything is ready! \n \n \n");
    delay(300);


    Firebase.setInt("/data",val);
   Serial.println(val);
    delay(1000); Serial.println("uploaded data to firebase \n \n \n");

    Firebase.setInt("/mobile/Available Slots", firebaseSpace);
    delay(1000); Serial.println("uploaded Available Slots to firebase \n \n \n");
    
  val++;
 }

}
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

Arduino Code


#include <Servo.h> 
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>

SoftwareSerial s(11, 12);//rx,tx
LiquidCrystal lcd(2, 3, 4, 5, 6, 7); //(rs,e,d4,d5,d6,d7)

int Space2;
Servo myservo1;
int ir_s1 = 8;
int ir_s2 = 9;
boolean execute = false;
int Total = 5;
boolean execute2 = false;

void setup() {
  // put your setup code here, to run once:
  pinMode(13, OUTPUT);
  pinMode(ir_s1, INPUT);
  pinMode(ir_s2, INPUT);

  Serial.begin(57600);// for Serial Monitor
  s.begin(115200);//for Seial Communication
  delay(1000);

  myservo1.attach(10); //Servo Attached to digital pin no 10
  myservo1.write(100);

  lcd.begin(16, 2);  
  lcd.setCursor (0,0);
  lcd.print("  Car  Parking  ");
  lcd.setCursor (0,1);
  lcd.print("     System     ");
  delay (2000);
  lcd.clear();  


  Space2 = Total;
}

void loop() {
  
//Logic Behind free slots update
 if(digitalRead (ir_s1) == LOW && execute2 == true){
    execute2=false;
   }
  if(digitalRead (ir_s1) == HIGH && digitalRead (ir_s2) == LOW){
    if(Space2>0){
      myservo1.write(200);
      delay(5000);
      myservo1.write(100); 
    if(execute2 == false && Space2>0){
      Space2 = Space2-1;
      execute2=true;
      }}

 if(Space2==0 && digitalRead (ir_s1) == HIGH ){
        lcd.setCursor (0,0);
        lcd.print(" Sorry not Space ");  
        lcd.setCursor (0,1);
        lcd.print("    Available    "); 
        delay (1000);
        lcd.clear();      
      }
    }
  

 if(digitalRead(ir_s2)==HIGH){
  if(digitalRead (ir_s1) == LOW && digitalRead (ir_s2) == HIGH){
   if(digitalRead (ir_s2) == HIGH && execute == false && Space2<5){
    Space2 = Space2+1;
    delay(2000);
    execute=true;
   }
  }}

   if(digitalRead (ir_s2) == LOW && execute == true){
    execute=false;
   }

   
lcd.setCursor (0,0);
lcd.print("Total Space: ");
lcd.print(Total);

lcd.setCursor (0,1);
lcd.print("Free Space: ");
lcd.print(Space2);


s.print(Space2); s.print("A"); //Sending Free slot Data to nodemcu with IndexofA
Serial.print(Space2); Serial.print("A");//print it on serial moniter
s.print("\n");
delay(1000);

}

In this Article We Learn how to Make IOT Based Smart Parking System, How to implement firebase with Nodemcu ESP8266, Retrieve Data from Firebase Realtime Database to Android Application , Communication Arduino To Nodemcu Using I2C, Servo And IR Sensor Programming And LCD 16x2 Interfacing This all Steps Are Taken To Make This Project.

1 Comments

  1. Schöne Informationen, wertvolles und exzellentes Design, gute Dinge mit guten Ideen und Konzepten teilen, viele großartige Informationen und Inspirationen, die ich beide brauche, dank der Bereitstellung solch hilfreicher Informationen hier. Elektronische Parkscheibe

    ReplyDelete

Post a Comment

Previous Post Next Post