Is there a way to capture Data from an android phone to be later analyzed in Mathematica?
1 Answer
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.
HTTP Post Action. This is the actual WEBAPI Details, the screen capture explains how to set up the different data pieces.
Profile. I've generated a profile that will trigger the posting of the variables into the Wolfram Data Drop every two minutes.
After all is set and up and running, we can check on the databin page if everything is working.
Now to the Mathematica side. Let's check some of the data capture. First, Battery Level.
db=Databin["myDataBin"];
battery=db["Data"]["battery"]
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"]
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"]
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]