Simple DIY hardware hack for address conflicting I2C devices

Recently I’m doing some experiments with beagle bone black SBC’s I2C bus and encountered some errors with devices that have the same address . One device is DS1307 with an eeprom( 24C32) and the MPU6050 DMP module that I’ve got from ebay.



Both DS1307 and MPU6050 hold the hexadecimal address 0x68 . So the beagle bone black’s I2C bus is confused when detecting the two devices. Then I’ve searched for the options . The DS1307 address can’t  be changed , it’s fixed one . So I have to choose the second option. Ground the AD0 pin of MPU6050 with VCC pin . So I soldered a little wire connecting both AD0 and VCC pins together shown as in below figure.


So after doing this simple diy hack the MPU6050’s device address should be 0x69. OK , let’s test the addresses that connected to the I2C bus of the beagle bone black using the following command.

$ i2cdetect -r 2

So this is the result I’ve got 😀


Aha 🙂 that diy hack worked well!.

That s it 🙂

So I’ve now ready to continue the experiment.

Important :- In this experiment I’ve used MPU6050 as a test device and it has AD0 pin. Here I’ve change the pin logic to 0 to 1 and that changed the  device address 0x68 to 0x69. Also keep in mind that this is a one method. Some I2C devices has software based address changing methods . In that type of devices we must read the manual and use a special firmware to change the I2C device address. We can use arduino like microcontroller to run that special firmware to do that task.  

Have a nice day!


How to create your first ROR app with mysql database support on windows?

When you are creating your first app on ruby on rails it default supports “sqlite” database. You can see it while open the “Gemfile” of  your project using a text editer like “Sublime Text”. When your app’s data are growing  bigger n bigger the “sqlite” is not suitable to store that data. So there are some alternative database systems for that like “mysql”,”postgresql” or “oracle”. My preferred choice is mysql. So .in this post I’ll show you how to create you first ROR app that includes mysql database support.

First you have to install gemfile for mysql . This can be install issuing the following command in the terminal window.

 gem install mysql2

After that you can see the following progress on the terminal window


Then issue the following command to create new rails app that includes mysql support

 rails new testr -d mysql

After few minutes that will create your new rails app.

Now move to the development directory issuing the following command on terminal window.

 E:\>cd testr

Then issue the following command in  the terminal to run the app

 E:\testr> rails server


Then open your web browser and  type the following url in the address bar



Oops.. ! . There is an error occurred 😦 . What can we do to resolve that error ?.

Ok, lets examine the database.yml in your app directory (in my example testr) using “Sublime Text” editor.


It shows us that there is a predefined database “testr_development” and we haven’t a database in our mysql server.

So to get rid of this we open the mysql command line interface and must issue the following command in it

 mysql> create schema testr_development;


After that refresh the browser window and also see the terminal window. You can see that following  result shows mysql is correctly configured with you project.



Yay! Now you know how to make ROR app with the support of mysql database.

Thats all .

Have happy coding and have a nice day 🙂 !

How to create your first ROR app with mysql database support on windows?

How to update the ruby version on heroku ?

When we want to update the ruby version of our heroku hosted ruby website, heroku eventually send a notification for it when there is need to update the ruby version of the heroku app.

This post shows how to update the ruby version on heroku,

These are the prerequisites on your windows machine before begin the update process

  1. Node.js
  2. Ruby 2.2.4
  3. Heroku toolbelt
  4. Git 1.8.6 >

That’s it.

Then you have to login to heroku account using this command

$ heroku login




Then you have to clone the site folder using git.




After that you have to move to the cloned site folder


If you want to update the bundler version of your site issue the following command inside the folder



Then configure the heroku build packs if your heroku ruby project issuing following command




To lock the bundler version if you have encountered an error we must have to lock it to specific version issuing following command in the terminal


After that open the gem file using your favorite text editor “notepad++” or “sublime text”

Then you have to add the following line to your ruby gem file inside your cloned folder.

You must add this line after the “source ‘https: //’ ” line

ruby “2.2.4”


Then save the gem file, that’s all

There is no need to change the other lines of this file

Then issue the following commands one by one to push the source repository to the heroku.





That’s all after that you’ll see following successful progress screen



















This is the final result after updating the ruby version “2.0.0” to “2.2.4”


Thats all . Have a nice day 🙂 !


How to update the ruby version on heroku ?

Finally upgraded to ROR 5 !

I’ve experimenting web developing on Ruby on Rails as a hobby. Last few days I’ve work with ruby 1.9.3 and ROR 3.2.x and felt that I must move to ruby version 2.x.x and  ROR 5 because ROR community fastly moved to new ROR version and old version is being deprecated. So here I’ve show you what is on it. Before that below screenshot shows that how the old ROR 4 start page looks like . Because I loved that very much :-).


Let’s rock on!

Here firstly I’ve fully removed ruby 1.8.7 and ROR 4 from my machine. After that I’ve installed ruby 2.2.4 and ROR

After that in the terminal I’ve issued the following command

>rails new first_app

So it creates a new rails app


Oh Screenshot 😀

After that move to that newly created rails app folder and issue the following command in the windows or linux terminal.

first_app>rails server


After that type the following url in your web browser


Now you can see the browser screen as below.


Yay 😀 it rocks !

The main difference is the welcome page is been changed and it’s clean and simple .Also the web server moved to “WEBRICK” to “PUMA”.

Thats it !


Finally upgraded to ROR 5 !

First step to groovy on windows

Hi , I’m already refreshing my knowledge about programming languages . I’m also java a lover . So when I searched about something about java and accidentally click on a link about java run-time environment based programming languages . Bingo…! bingo..! , it is a post on groovy . So  then I read that article and got some idea about groovy.

In this post I’will explain how to prepare the basic environment to run/develop groovy on windows 64 bit editions.

First thing is to  point to below url and download the windows setup binary




Before this step you must have to install proper java SE development kit . I have installed  Java SE Development Kit 8u73 64bit edition ,

Now double click and run  the setup file








In below step you will find that sometimes installer says unable to find jvm or JAVA_HOME . but ignore that and proceed to the next step.




After finishing the setup you have to modify some settings as below . Open “Advance system settings” from the windows properties and click on “Environmental Variables”



Then modify the settings according to the below screen shots




Then you have to copy “groovy.exe” ,”groovyw.exe” from the folder “D:\Groovy2.4.5\Supplementary\native\64bit” to to the “D:\Groovy-2.4.5\bin” because we have to run 64 bit edition of groovy . Then give the permission to overwrite and replace the files


After that move to the “D:\Groovy-2.4.5\Supplementary\JavaArch” folder using windows command prompt


Then run the command “java  -jar GetArchModel.jar”

If the result is ok you will find the following message

“Found a 64 bit java installation.”

After that close the windows command prompt and then get a new command prompt window

Then type “groovy”

If the all the settings are successful you’ll find the following screen


That’s all 🙂 !

Notice that if you are using 32 bit version of jdk and windows os  you don’t have to worry about copying “groovy.exe” ,”groovyw.exe” to the “D:\Groovy-2.4.5\bin” folder

If you have any comments let me know.It is very important!

Have a nice day 🙂 !


First step to groovy on windows


This is a sample tutorial describes how to check your grammar is in correct order or not and print the DFA states of your grammar using bison and flex in windows environment.

To describe the procedure I’ve got the “simple thermostat controller example” from the “Ivan’s Blog” at ““.

First we must define our grammar in lex (*.l) and yacc (*.y) files. In this example I named them as “heat.l” and “heat.y” according to the “Ivan’s Blog” because these files are describes a process of heat equipment. (Figure 1)

6235-1 copy

Figure 1


#include <stdio.h>
#include ""
[0-9]+ yylval=atoi(yytext); return NUMBER;
heat return TOKHEAT;
on|off yylval=!strcmp(yytext,"on");return STATE;
target return TOKTARGET;
temperature return TOKTEMPERATURE;\n /*ignore end of line*/;
[\t]+ /*ignore whitespace*/;
int yywrap(void)
 return 1;




#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
int lineno =1;
void yyerror(char *str);
%start commands
commands :/*empty*/
|commands command
command :heat_switch
heat_switch :TOKHEAT STATE
   printf("\tHeat turned on \n");
   printf("\tHeat turned off \n");
   printf("\tTemperature set to %d\n",$3);
void yyerror(char *str)
   fprintf(stderr,"line %d: %s\n",lineno,str);


Then open a terminal and type the following command only for “heat.y” file only (Figure 2)

>bison –dv heat.y   (here the –v parameter for more details type >bison –help)

6235-2 copy

Figure 2

This will generate following output file (Figure 3)


6235-3 copy

Figure 3

When we open the file using a text editor the file includes the following data

  • Used and unused nonterminals.
  • Used and unused terminals.
  • Grammar rules.
  • And the states of the Finite Automata (DFA).


rule 1 commands -> /* empty */
rule 2 commands -> commands command
rule 3 command -> heat_switch
rule 4 command -> target_set
rule 5 heat_switch -> TOKHEAT STATE
Terminals, with rules where they appear
$ (-1)
error (256)
NUMBER (257) 6
TOKHEAT (258) 5
STATE (259) 5
Nonterminals, with rules where they appear
commands (8)
on left: 1 2, on right: 2
command (9)
on left: 3 4, on right: 2
heat_switch (10)
on left: 5, on right: 3
target_set (11)
on left: 6, on right: 4
state 0
$default reduce using rule 1 (commands)
commands go to state 1
state 1
commands -> commands . command (rule 2)
$ go to state 10
TOKHEAT shift, and go to state 2
TOKTARGETshift, and go to state 3
command go to state 4
heat_switch go to state 5
target_set go to state 6
state 2
heat_switch -> TOKHEAT . STATE (rule 5)
STATE shift, and go to state 7
state 3
TOKTEMPERATURE shift, and go to state 8
state 4
commands -> commands command . (rule 2)
$default reduce using rule 2 (commands)
state 5
command -> heat_switch . (rule 3)
$default reduce using rule 3 (command)
state 6
command -> target_set . (rule 4)
$default reduce using rule 4 (command)
state 7
heat_switch -> TOKHEAT STATE . (rule 5)
$default reduce using rule 5 (heat_switch)
state 8
NUMBER shift, and go to state 9
state 9
$default reduce using rule 6 (target_set)
state 10
$ go to state 11
state 11
$default accept


If there is an error it will show the errors in (*.output) file as a below (Figure 4)

6235-4 copy

Figure 4

This method is briefly described in page 6 of “LEX & YACC TUTORIAL” by Tom Niemann.

Thank you!