Dhananjay Khairnar @. Powered by Blogger.

26 December 2016

ESP8266(Arduino) interface with Firebase:


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

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


// Set these to run example.
#define WIFI_SSID "Wifi Router Name"
#define WIFI_PASSWORD "Router Password"

#define LED 2

void setup() {

  while (WiFi.status() != WL_CONNECTED) {
  Serial.print("connected: ");


void loop() {
  if (Firebase.failed())  // Check for errors
      Serial.print("setting /number failed:");

Step 6:
After reseting ESP8266 check 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

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

29 November 2016

Download English Dictionary words for Microcontroller based Text to Speech (TTS) convertor:

What is TTS?
Speech synthesis is the artificial production of human speech. A computer system used for this purpose is called a speech computer or speech synthesizer, and can be implemented in software or hardware products. A text-to-speech (TTS) system converts normal language text into speech; other systems render symbolic linguistic representations like phonetic transcriptions into speech.
Basic architecture is explained in following block diagram.
Microcontroller feed with text data from any interface . microcontroller make tokens of that string into and compare appropriate soud file per word from data bases. After getting all index of each word of string micro controller play sound files one after another with proper delay in words.

As per post title I am going to use Python script to make my own speech files database(format in mp3).

Prerequisite :
1) Installed python 2.7 ( Download and install from https://www.python.org/download/releases/2.7/)
2) Internet

Step 1:
locate Python27\Scripts director

install requred python packages

press and hold shift key and rigth click > click open command window here

in command prompt type and enter

pip.exe install wget

this is package used by our script to download .mp3 files from internet

Step 2:

We are going to download all our .mp3 file from google database.
we need to replace “hello.mp3” with our word that we want to download.

Step 3:

Here I used the file words.txt that contains daily used English words. We take each word from file and replace in base URL to download it.

download this this file and keep it in same directory where following script is placed.

Step 4:

create new text file, copy and paste following code in it. Rename that file as script.py

import wget
import os
import os.path

with open("words.txt", "r") as ins:

def chomp(x):
if x.endswith("\r\n"): return x[:-2]
if x.endswith("\n"): return x[:-1]
return x[:]

for line in ins:
if False==os.path.isfile(line):
print "new file added\n"
file_url = "https://ssl.gstatic.com/dictionary/static/sounds/de/0/"
print file_url
file_name = wget.download(file_url)
else :
print "file exist"

open command prompt from director of script and run script as

> python script.py

Step 6:

Download will take time as their is load of words in text file. you can reduce them as per your requirement.

Now you have you mp3 database for text to speech converter. I have working prototype for it using microcontroller.
If you have any question please comment below or contact me.
Published: By: DK - 04:03

10 November 2016

Raspberry pi 3 kernel module compilation:


Raspberry pi 3 kernel module compile :

Step 1:
Update current kernel

$sudo apt-get update

$sudo apt-get upgrade

$sudo apt-get install bc

$sudo apt-get install gcc

Step 2:
Download linux headers for current kernel version

$uname -r

copy kernel version

and goto url https://www.niksula.hut.fi/~mhiienka/Rpi/linux-headers-rpi/ and find your kernel version
here in my case
linux-headers-4.4.26-v7+_4.4.26-v7+-2_armhf.deb    20-Oct-2016 21:07             6891064

Download it

Now install the downloaded inux headers.

$sudo dpkg -i linux-headers-4.4.26-v7+_4.4.26-v7+-2_armhf.deb

it takes while let it be complete without interrupt process.

Step 4 :

$mkdir kmod

$cd kmod

$sudo nano hello-1.c

copy and past following programe in file then save it [^X]

/*hello−1.c − The simplest kernel module.*/
#include < linux/init.h >             //linux/init.h Macros used to mark up functions e.g., __init __exit
#include < linux/module.h >           //linux/module.h Core header for loading LKMs into the kernel
#include < linux/kernel.h >           //linux/kernel.h Contains types, macros, functions for the kernel

int init_module(void) 
    printk(KERN_INFO "Hello world 1.\n");
    /*A non 0 return means init_module failed; module can't be loaded.*/
    return 0;

void cleanup_module(void)
    printk(KERN_INFO "Goodbye world 1.\n");

Now for compile this module we need make file
$sudo nano Makefile

copy and past following code in make file

obj-m += hello-1.o

    make -C /lib/modules/4.4.26-v7+/build M=/home/pi/kmod modules
    make -C /lib/modules/4.4.26-v7+/build M=/home/pi/kmod clean

remember the there is Tab before make.

Save it

Step 5:

compile our hello world module

$sudo make
make -C /lib/modules/4.4.26-v7+/build M=/home/pi/kmod modules

make[1]: Entering directory '/usr/src/linux-headers-4.4.26-v7+'

CC [M] /home/pi/kmod/hello-1.o

Building modules, stage 2.

MODPOST 1 modules

CC /home/pi/kmod/hello-1.mod.o

LD [M] /home/pi/kmod/hello-1.ko

make[1]: Leaving directory '/usr/src/linux-headers-4.4.26-v7+'

Step 6:
insert module into kernel
$sudo insmod hello-1.ko

if there is noerror then your module get successfully installed

Step 7:
to verify it
$sudo dmesg

You get following result 

now to remove module 

$sudo rmmod hello-1.ko

to verify

$sudo dmesg

you see the kernel log as follows


Thank You . if you have any question comment below or email me.

Published: By: DK - 07:49