Array of Android Magnetometers

Curious about magnetometers, I wrote a small web app that used a Chrome preview feature that allowed me to access three-axis magnetometer hardware integrated into many Android phones. I showed that three-dimension data in the form of a virtual compass needle and had fun seeing it react to holding magnets near my phone.

Then for more fun, I ran my web app on more phones! I pulled out my entire stockpile of retired Android phones. This is a collection of my own retired phones and those retired by my friends for one reason or another. (I ask my friends for them after they moved on to new phones.) It’s a collection of cracked screens, flaky touch input, exhausted batteries, and other reasons why people decide to get a new phone. I found the subset that could boot up and run my web app. I had to go to “chrome://flags” on all of them to activate the preview feature, of course, but I believe that was still less onerous than if I had written a native Android app. To install my own native app, I would have to put the phone into developer mode and sideload my app via USB, which would have been a more complex procedure.

First round of this experiment with seven running old phones exposed some problems, immediately visible by the fact these virtual compass needles were pointing in wildly different directions. They should all be aligned to Earth’s magnetic field! Tracking down various ideas, I found two made the biggest difference:

  1. The values given to web apps were apparently “calibrated” values, but the calibration routine has not yet been run. This is something that happens behind the scenes. All I had to do was to pick up each phone and do the figure-8 twirl. My app continued running while this was occurring and, once I set the phone back down, my virtual compass needle pointed in a different direction than it had a minute earlier.
  2. The phones needed to be spaced further apart. Obvious in hindsight: there are a few strong magnets inside a phone for their speakers and possibly other peripherals. While each phone might have properly isolated their magnetometer from their own magnets, they aren’t necessarily isolated from another phone sitting nearby.

Things look better on the second round of this experiment. After taking account for those two factors and waking up an eighth phone to join the fun. They still don’t completely agree but at least they all point in the same general direction. And when I wave a strong magnet through the air, all of those virtual needles react and point to my magnet. It was more fun than I had expected, even if it was ridiculously underutilizing the capabilities of these old phones and not anywhere near the best tool for the job. If the goal was to visualize magnetic fields, we have far easier and cheaper ways to do it. Like using a sheet of magnetic field viewing film.

My exploratory project is publicly availble on GitHub to run on your own Android phone (or phones)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s