Dhananjay Khairnar @. Powered by Blogger.

26 December 2016

ESP8266(Arduino) interface with Firebase:

  

Aim:
 Make such application in which LED can be control from mobile or website from any remote location where internet connectivity is available.

Requirement:
1 ) ESP8266-E12 WiFi module as shown in picture. You can get start and setup it with help of this post.
2) Download and install firebase-arduino-master  library in Arduino IDE.
3) Need gmail account for create Firebase project.

Step 1:
Go to https://console.firebase.google.com and create new project.

Step 2:
Click on Database now you will see the host name show in image
 

Copy that host name and past in Arduino code given below at line
 #define FIREBASE_HOST "fir-app-example.firebaseio.com"

Step 3:
Go to Setting>Project Setting>SERVICE ACCOUNTS>DATABASE Secretes.
Copy "Database Secrets" Shown in below image

 

Copy and paste Database Secrets at the line in code 
#define FIREBASE_AUTH "examplesd2asdasdasdasd2asd3asd2asd2as32das3d2as2da3" 

Step 6 :
Change line with your WiFi router name and password
#define WIFI_SSID "Wifi Router Name"
#define WIFI_PASSWORD "Router Password"

Step 5:
Download following code in arduino

#include
#include

// Set these to run example.
#define FIREBASE_HOST "
fir-app-example.firebaseio.com"
#define FIREBASE_AUTH "
examplesd2asdasdasdasd2asd3asd2asd2as32das3d2as2da3"
#define WIFI_SSID "Wifi Router Name"
#define WIFI_PASSWORD "Router Password"

#define LED 2

void setup() {

  pinMode(LED,OUTPUT);
  digitalWrite(LED,0);
 
  Serial.begin(9600);
 
  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.setInt("LEDStatus",0);
}

void loop() {
  if(Firebase.getInt("LEDStatus"))
  { 
    digitalWrite(LED,HIGH);
  }
  else
  {
    digitalWrite(LED,LOW);
  }
  if (Firebase.failed())  // Check for errors
 {
      Serial.print("setting /number failed:");
      Serial.println(Firebase.error()); 
      return;
  } 
  delay(1000);
}

Step 6:
After reseting ESP8266check serial terminal whether the ESP is get connected with your router and got IP adress.
you can now see the new variable created in database. 


Step 7:  
Double click "LEDStatus" and edit it to 1. instantly (its depends on your internet connection) LED on ESP 8266 module get Turn off.

Step 8: 
If you have knowledge of Android you can create App for control LED from mobile. You need to read Firebase documentation and integration methods.

I created my android app for controlling LED from mobile. As Firebase can be assess from world wide so you have end to end IoT application.

For any question comment below. Thank You.
Published: By: DK - 07:15

14 December 2016

JHD12864E interfacing with Arduino Uno( 128x64 Bit MAp Graphics LCD) :

 
Requirement :
1 ) JHD12864E LCD
2 ) Arduino
3 ) Connecting wires


Aim: Convert and display JPEG image on Graphics LCD as Bitmap image

Step 1 : 
Download and put Glcd library in Documents/Arduino/library folder
GLCD library

Step 2 :
Download BMP-To-LCD software to convert JPEG image to BMP array
BMP-TO-LCD

Step 3:  
Make connection of LCD to Arduino UNO as shown in figure.

Step 4:
 Download any image from internet.

Step 5: Open image in Paint
 

Step 6:
 

Step7 :
  

 

Step 8:

Step 9: 
Click on resize without selecting area

Step 10: 
Save image as 1.bmp 

Step 11 : open Image in BMP-LCD software

And click on Genarate code


Copy that genarated code in Arduino sketch



Step 12: Copy Paste code in bitmaps.h with some modification as shown in below image
 

Main sketch is as shown below image 

You can download it from here Arduino_GLCD_Sketch.rar


If You have any question comment below.

 
Published: By: DK - 06:21