MPU6050 on GY-521 - Hourglass Prj Part 5

Read Part 4

After bringing hourglass to a satisfactory working level with the simple ball tilt sensor (see pic below) I wanted to go back to the original idea and make it work not only in the Upright-Upside-down directions, but also have the balls fall and roll in all compass directions as the object’s tilt angle changes. Of course the simple ball in a tube sensor cannot do that.

It happens that a GY-521 breakout board with a MPU6050 on it was waiting for this opportunity. I had acquired for about $3.00 some time ago but I had never used it. The GY-521 has a gyroscope and accelerometer on it combined with a processing unit to calculate rotation angles on the board itself. After a quick search I found a library about it on github by J.Rowberg and experimented with it.

See connections, it uses the 2 wire communication. Connections to GY-521 from Arduino UNO

I was able to get rotation angle readings and they seemed to be at times meaningful, but they were not consistently right. After that I went ahead and downlaoded a MPU6050 calibrarion sketch which works well. But still it did not help me, it seemed at times the MPU was thinking North was South and other times it was just opposite and correct.

Well it turned out that when I was experimenting with it, I must have maken a mistake and I picked the wrong attribute out of the Yaw-Pitch-Roll combination offered by the library as output values via the global array ypr[]. After switching from Yaw to Pitch as my main angle reading and later applying some help from Roll readings onto it, I was finally able to tell orientation of the object satisfactorily.

It is a great thing to see an idea come to life. The balls immediately started falling in the direction of the inclination in a smooth fashion no matter how I twisted and turned the hourglass.

My next step is to clean the code and bring it to a publishable level with comments, and also make a video of the working hourglass to release together with it.

Read final project status