Introduction: Google Earth Controlled by Accelerometer(MPU-6050)

About: Former software engineer. Beginner of Arduino.

Recently, I bought a 3-axis gyroscope and accelerometer called “MPU-6050” from Amazon. It cost $5. When I was researching applications of “Leap Motion,” I found many demo programs which can control Google Earth through Leap Motion. I tried to use MPU-6050 to control Google Earth in this project.

Step 1: About Google Earth API

Google Earth provides plug-ins and API for developers. You can embed the plug-in to your webpage. You can also control Google Earth with Javascript.

At first, I learned the basics of Google Earth API, such as setting latitude and longitude, from these tutorials.

Step 2: About MPU-6050

MPU-6050 provides you 3-axis gyro and acceleration data. It connects to Arduino via I2C. The sensor that I bought from Amazon doesn't have a manual or datasheet, so I needed information on how to use it.

The Arduino official web site has a page for MPU-6050. It mentioned that “Reading raw values is easy, the rest is not.” It sounds difficult! I searched through many websites and found a sample program. The program read raw 3-axis acceleration values from the sensor. I needed angle data to control Google Earth API, so I calculated the angle by the raw 3-axis acceleration values, which is good enough for this project. You can find a formula to get the angle between two vectors from Wikipedia.

Step 3: System Architecture

The system architecture of this project is drawn above. The procedure to control Google Earth with the raw values from the sensor is as follows:

  1. Arduino reads raw values from the sensor and calculates the angle.
  2. The angle data is transmitted to Mac via XBee.
  3. Mac sends the data to Browser via Socket.IO.
  4. Browser calls Google Earth API with the angle data.

I added three tact switches to execute extra operations. The breadboard wiring diagram is also shown above.

Step 4: Specification to Control Google Earth

You can download source codes for this project from GitHub.

I designed the following specifications using a combination of data from MPU-6050 and Google Earth API.

  • The map moves based on the angle of the sensor. The amount of movement is adjusted by the map’s scale. The larger the scale, the more movement even though the angle is the same.
  • The tact switches have different roles. One switch is assigned to be a mode changer. The other two switches are for operation. The system has four modes.
    1. Position Mode: You can change the scale via operation switches.
    2. Tile Mode: You can change the tilt of your viewpoint (birds-eye view).
    3. Rotation Mode: You can rotate the map.
    4. Color Mode: You can change the background color of the web page.
  • You can go back to the default position (I set Tokyo as a default) by holding down the mode changer for 2 sec.

Google Earth Plug-in provides the image data of the Moon and Mars. I tried it but didn't find it interesting. When I look at the map of earth, I can understand where it is. However, I cannot understand where they are by looking at the map of the Moon and Mars. If you are familiar with them, you may enjoy it.

Step 5: Conclusion

In this project, I created an original Google Earth controller using 3-axis accelerometer and switches. It is a fresh experience for me to control a computer without a keyboard or mouse. The device is primitive but this project has given me the fun of creating an original human-computer interface.

Microcontroller Contest

Participated in the
Microcontroller Contest