22
$\begingroup$

Is there a way to capture Data from an android phone to be later analyzed in Mathematica?

$\endgroup$

1 Answer 1

23
$\begingroup$

There is a neat application called Tasker, which allows for the automation of scripts (tasks) on the android phone, triggered by events, time or phone state changes. In this example, we'll simulate the "It's just metadata" approach by capturing some phone variables and pushing the values into the new DataDrop Universal accumulator via the web api.

Configuration of Profiles and Tasks on the Android phone side using Tasker.

Task Creation. Created a task called WolframDataDrop, which contains two actions. The first action:Say was placed there for debugging purposes. It will announce that data will be pushed to the cloud. The HTTP Post is the actual action that uses the Web API to accumulate the data points into the Databin.

enter image description here

HTTP Post Action. This is the actual WEBAPI Details, the screen capture explains how to set up the different data pieces.

enter image description here

Profile. I've generated a profile that will trigger the posting of the variables into the Wolfram Data Drop every two minutes.

enter image description here

After all is set and up and running, we can check on the databin page if everything is working.

enter image description here enter image description here

Now to the Mathematica side. Let's check some of the data capture. First, Battery Level.

db=Databin["myDataBin"];
battery=db["Data"]["battery"]

enter image description here

The Tasker HTTP Posting is sending the data in String type, so we need to convert the records to numbers.

battery[[2,1]]=ToExpression[battery[[2,1]]];
DateListPlot[battery,PlotRange->{Automatic,{0,100}},PlotLabel->"Battery Charge (%) Trend",PlotTheme->"Detailed"]

enter image description here

Now let's look at the speed of the commute. The GPS is capturing speed in m/s, we want the records to be in miles per hour.

locSpeed=TimeSeries[db["Data"]["locSpeed"]];
    locSpeed[[2,1]]=UnitConvert[Quantity[ToExpression[locSpeed[[2,1]]],"m/s"],"mph"];
DateListPlot[TimeSeriesWindow[locSpeed,{{2015,03,17,06,50},
2015,03,17,08,10}}],Filling->Axis,PlotRange->{Automatic,{0,60}},
PlotLabel->"Speed of Commute (mph)",PlotTheme->"Detailed"]

enter image description here

Finally some Geographics:

geoData=db["Data"]["loc"];
geoData[[2,1]]=GeoPosition[ToExpression[#]]&/@geoData[[2,1]];
GeoGraphics[{Darker@Green,PointSize[Large],Point[geoData[[2,1]]]},ImageSize->Large]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.