File Exchange Pick of the Week

Our best user submissions

Reading from sensors on your mobile phone

Jiro's picks this week are Android Sensor support and iPhone and iPad Sensor support by the MathWorks Mobile Sensor Connectivity Team.

If you own a smart phone, you're probably holding a device with a number of sensors that is constantly collecting information from its surroundings. Many of the apps on your phone make use of these various sensors to operate. Now, you can read from your phone's sensors using MATLAB! If you have R2013a or newer and an Android phone or an iPhone/iPad, you will want to check this out.

After installing a free app for your Android or iPhone/iPad, you can now receive sensor data from you phone directly into your MATLAB session. It is written using MATLAB Classes, and it has a simple interface to read sensor data from your phone.

Establish connection with your phone:

sensor = sensorgroup('AndroidMobile')
sensor = 
sensorgroup logging data from Android device on port 60000

  Measurements: (showLatestValues)

    Acceleration                        Orientation

    Latitude                            Speed
    Altitude                            MagneticField

Read the latest values from the sensors:

Measurement              Latest Values              Units   Log Size
-------------  ----------------------------------  -------  --------
Acceleration         4.51       -3.30       -8.16  m/s^2    <1x3>
MagneticField   -3.56e-06   -2.49e-05    1.11e-05  Tesla    <2x3>
Orientation         27.08       27.14      -19.39  degrees  <2x3>

Waiting for: Latitude, Longitude, Altitude, and Speed.  More information.

Get specific measurements:

ans =
   20.6081   34.4375  -15.0781

The entry also comes with a MATLAB app that shows a live view of the data coming in, as well as an example of using the magnetic field information from the phone to rotate a 3D plot.

Learn more about these mobile supports from this page for Android and this page for iPhone/iPad.


Tell us about your applications using your mobile devices and MATLAB or leave a comment for the MathWorks Mobile Sensor Connectivity Team.

Published with MATLAB® R2013a

  • print


To leave a comment, please click here to sign in to your MathWorks Account or create a new one.