Message Boards Message Boards

Capturing Data from an Android Phone using Wolfram Data Drop

GROUPS:

Started reading Bruce Schneier's "Data and Goliath's" Book, which made me wonder on the potential of mass surveillance. Let's tests some concepts of what can be done by the metadata generated by the smartphone, using the Wolfram Data Drop announced by Stephen Wolfram this march on the wolfram blog.

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.

Here is the how-to recipe to establish a data push to the databin every two minutes.

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 releasing the profile, we can check if the data is flowing by visiting the databin's web page.

enter image description here

Now to the Mathematica side of things.

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

We can also see on a map where we've been located since we turned on the data log.

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

What about speeding during the commute? Let's take the GPS Speed variable and chart this morning's travel. The pnone captures the speed in meters/second. Let's chart using 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

POSTED BY: Diego Zviovich
Answer
3 years ago

This is just amazing Diego! I'll definitely experiment with my Android Tablet using this. Thanks for sharing!

Answer
3 years ago

Thanks Bernat. Loved your Time Lapse Video and Data Drop example. Please let me know what cool things you got to do with the table.

POSTED BY: Diego Zviovich
Answer
3 years ago

This is fantastic, Diego, thank you for sharing! I will have to play with this. I am giving the link to the Tasker app you were using. Looks like they have some starter guides on their site.

POSTED BY: Vitaliy Kaurov
Answer
3 years ago

Thanks Vitaly! I'm currently logging a snapshot of the variables every 2 minutes. For a better study on my phone usage pattern, I created three additional profiles:one when I turn on the screen, one when I turn off the screen, one when I navigate between applications. I had to remove the wolframdatalog task from them and replace it with a data logger on the phone memory due to the restrictions of a maximum of 60 data points per hour on the free account.

I'll have to search for a similar app for my kid's iphones. Im interested to see how much of their time they spend on their phone. Seems they are always plugged to the device.

POSTED BY: Diego Zviovich
Answer
3 years ago

I'd be interested to see if there was an iPhone version of Tasker as well.

Thanks!

POSTED BY: Adriana O'Brien
Answer
3 years ago

You can try IFTTT apps.

POSTED BY: Vitaliy Kaurov
Answer
3 years ago

Hi,

I did something similar, but without Databin at the time for the iPhone,

http://community.wolfram.com/groups/-/m/t/344278

I have managed to look at Parkinson tremor data with it though. The things is that the streaming only works within the same network or it records the data locally - which is not that much fun. Alternatively, a Raspberry can pick the signal up and relay it to the Databin. I, too, have tried to get a Tasker like program for the iPhone and the closest thing I could find was:

https://workflow.is

It can send data by email. I managed to record my GPS positions on the way to work with it and have it sent to an email account. So technically it should work with the Databin. I'll try to show results later.

Cheers,

M.

POSTED BY: Marco Thiel
Answer
3 years ago

Yes, Marco, I also thought of your smart phone post right away. If you get any experimenting with iOS done - let us know, I would be very curious. There is new Barometer sensor on iPhone 6 - interesting to test.

POSTED BY: Vitaliy Kaurov
Answer
3 years ago

Diego, this is terrific. Tasker hadn't occurred to me before, but I immediately started creating some tasks and profiles on my phone after reading your post.

You might consider adding "Interpretation" to your databin so all the values for a given key are automatically assigned correct quantities or put into more immediately useful formats.

Here you can find out standard units for different Tasker variables: http://tasker.dinglisch.net/userguide/en/variables.html.

And then you could do something like this with your example bin above :

SetOptions[
  Databin[MyBinID], 
  “Interpretation”->
     {
      "loc"->"GeoCoordinates",
      "locSpeed" -> Restricted["StructuredQuantity", ("Meters")/("Seconds")], 
      "lightLevel" -> Restricted["StructuredQuantity", "Lux"], 
      "magneticField" -> Restricted["StructuredQuantity", "Microteslas”]
     }
  ]
POSTED BY: Alan Joyce
Answer
3 years ago

Thank you for the posting Alan, it is most helpful!

POSTED BY: Diego Zviovich
Answer
3 years ago

Another trick I'm enjoying:

Rule[#[[1]], #[[2]]] & /@ Values[Normal[bin[All, {"loc", "magneticField"}]]];
GeoRegionValuePlot[%]

There's almost certainly a more elegant way to handle the first step there, but the output is a nice map that plots the intensity of some selected variable at the point it was sampled.

POSTED BY: Alan Joyce
Answer
3 years ago

Wanted to share with the community some extra very interesting functionality that @nikie answered in the mathematica stackexchange that can be very useful and cool when combined with the GeoLocation Data gathering functionality. Extracting road curves from image.

POSTED BY: Diego Zviovich
Answer
3 years ago

Group Abstract Group Abstract