{"id":2932,"date":"2017-06-12T00:00:59","date_gmt":"2017-06-12T07:00:59","guid":{"rendered":"http:\/\/192.168.3.4\/?p=2932"},"modified":"2018-01-09T06:51:50","modified_gmt":"2018-01-09T14:51:50","slug":"ios-sensor-tracking-with-sensorlog","status":"publish","type":"post","link":"https:\/\/www.cloudacm.com\/?p=2932","title":{"rendered":"IOS Sensor Tracking with SensorLog"},"content":{"rendered":"<p>Over the years I&#8217;ve used a variety of sensor tracking programs that ran on smart phones.\u00a0 These programs will read the sensors built in the phone and log them.\u00a0 I like this because it uses hardware that is already available.\u00a0 There are many apps that I have used to do this.\u00a0 The latest one I used is called SensorLog authored by Bernd Thomas.\u00a0 As of this writing it is at version 1.9.2, dated June 2nd, 2017.\u00a0 I&#8217;ll be covering some key points about this app that I hadn&#8217;t found online.\u00a0 Hopefully this will be useful for anyone looking to use this program.<\/p>\n<p>Link to iTunes Apple Store &#8211; <a href=\"https:\/\/itunes.apple.com\/us\/app\/sensorlog\/id388014573?mt=8\">https:\/\/itunes.apple.com\/us\/app\/sensorlog\/id388014573?mt=8<\/a><\/p>\n<p>First, let me give an overview of what SensorLog can do.\u00a0 This program will track and log sensor values read from IOS devices.\u00a0 The logging can be stored locally on the device or over the network using a couple of different methods.\u00a0 The sensors logged are the tilt, gyro, magnetic, audio, and GPS sensors.\u00a0 It also logs the uptime of the sensors as well as battery levels of the IOS device.<\/p>\n<p>SensorLog does not display logged data.\u00a0 It does not have any reporting or other data representation mechanism.\u00a0 The program is focused instead on gathering sensor data to log files.\u00a0 Besides the internal log storage, data logs can also be sent to remote hosts.\u00a0 The first method is creating a sockets connection.\u00a0 Basically this allows the iPhone to open a port up to allow remote hosts to connect to it.\u00a0 Bernd gives an example of an Apple Mac storing the logs to its file system using this command.<\/p>\n<p>nc 192.168.2.106 56204 &gt; mylogfile.csv<\/p>\n<p>The &#8220;nc&#8221; command is called netcat and it is a client server application.\u00a0 In the above example, we are using it on a Mac as a client.\u00a0 It is connecting to the iPhone&#8217;s IP address, mostly via WiFi.\u00a0 The port follows the IP, which is defined in SensorLog.\u00a0 Lastly, the &#8220;&gt; mylogfile.csv&#8221; outputs to a file on the Mac, instead of displaying it on the screen, which is the default behavior of netcat data.\u00a0 Here is an example of netcat used as IRC.<\/p>\n<p>https:\/\/youtu.be\/82UU5s_4FiE<\/p>\n<p>The following screen shows the settings in SensorLog that allow it to be a netcat server.<\/p>\n<p><a href=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/06\/Socket_SaveLog.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2937\" src=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/06\/Socket_SaveLog-300x244.png\" alt=\"\" width=\"300\" height=\"244\" srcset=\"https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/06\/Socket_SaveLog-300x244.png 300w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/06\/Socket_SaveLog-331x270.png 331w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/06\/Socket_SaveLog.png 621w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The recording rate will change how often the sensor values are polled and displayed on the netcat client.\u00a0 It was interesting to log data this way.\u00a0 Connecting the iPhone to wireless and running SensorLog allowed me to track the iPhone from a Linux system with a fairly high recording frequency.\u00a0 The tilt, accelerometer, and gyro data showed as the iphone traveled through the building.<\/p>\n<p>The sockets method can also be used in conjunction with locally saving the data to log files.\u00a0 These can then be emailed through a manual process.\u00a0 If you want a truly automated logging process, the GET\/POST methods should do it.<\/p>\n<p><a href=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/06\/HTTP_Upload.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-2938\" src=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/06\/HTTP_Upload-300x123.png\" alt=\"\" width=\"300\" height=\"123\" srcset=\"https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/06\/HTTP_Upload-300x123.png 300w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/06\/HTTP_Upload.png 590w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The HTTP upload option should be set with either a GET or POST option.\u00a0 There are pre defined frequencies to choose from.\u00a0 The record rate available to socket or file logging doesn&#8217;t have the same resolution or granularity.\u00a0 The URL is going to be the website you plan to provide the sensor data to.<\/p>\n<p>In the example provided by Bernd, available at <a href=\"http:\/\/www.berndthomas.net\/SensorLog.php.zip\">http:\/\/www.berndthomas.net\/SensorLog.php.zip<\/a>, I use a php landing page that takes the URL string submitted by the SensorLog app and writes that to a locally stored log file.\u00a0 If I visit that same URL with a standard computer, it will display the log file contents.\u00a0 This is a great way to share the raw data in real time to anyone.\u00a0 Just be mindful of security if you have concerns and apply it where appropriate.\u00a0 This mechanism provides no security, so you&#8217;ll need to account for that elsewhere.\u00a0 Maybe in future versions the URL will support HTTPS.\u00a0 So do realize that the content can be intercepted and viewed by third parties.<\/p>\n<p><a href=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/06\/Intercepted.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-2939 size-full\" src=\"http:\/\/192.168.3.4\/wp-content\/uploads\/2017\/06\/Intercepted.png\" alt=\"\" width=\"464\" height=\"288\" srcset=\"https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/06\/Intercepted.png 464w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/06\/Intercepted-300x186.png 300w, https:\/\/www.cloudacm.com\/wp-content\/uploads\/2017\/06\/Intercepted-435x270.png 435w\" sizes=\"auto, (max-width: 464px) 100vw, 464px\" \/><\/a><\/p>\n<p>Using Bernd&#8217;s php code wasn&#8217;t difficult, all you really need is a LAMP.\u00a0 I did make some changes to the code.\u00a0 The path of the log file is fully defined.\u00a0 Since I changed the location out of my webroot, I had to set permissions accordingly.\u00a0 Without the permission changes, the page displayed &#8220;Unable to open file&#8221; messages.\u00a0 Once set, I was able to see the data entered in the log file.\u00a0 In addition, when I visited the php page with my computer, I was also able to see the data logged.<\/p>\n<p>It&#8217;s a modest logger, I&#8217;m looking forward to running the app on some bike routes in the future.\u00a0 Having a raw logger is nice because it affords me the option to manipulate, process, and present the data as I like.\u00a0 Who knows, maybe I&#8217;ll expand on the GET POST methods and have php log to a database.\u00a0 From there the data can do some really amazing things.\u00a0 That would be too much to cover in this post.<\/p>\n<p>Since there isn&#8217;t much online information about the app, here is some information taken from the app itself for those interested in the details.<\/p>\n<p><em>With SensorLog you can log your iPhone&#8217;s or iPad&#8217;s sensor data in four different ways: save to a file, read data during recording from a tcp\/ip socket, combine both methods, and \/ or send via HTTP GET\/POST method to a server.<\/p>\n<p>The data sent by SensorLog over the tcp\/ip socket follows the identical syntax as if you use the option log to file. If you select the method &#8220;log data to file&#8221;, you can send the log file as an email attachment or you can download it via iTunes.<\/p>\n<p>To receive sensor data from SensorLog over a tcp\/ip connection you can use any type of application that provides the possibility to open a tcp\/ip connection on a dedicated socket port. On a mac computer running OS X you can do so by starting the terminal application and use for example the programs telenet or nc.<\/p>\n<p>If for instance SensorLog writes to the socket with IP 192.168.2.106 using port 56204 you can save the received data to a file on your Mac&#8217;s filesystem by the following command:<\/p>\n<p>$ nc 192.168.2.106 56204 &gt; mylogfile.csv<\/p>\n<p>Please note that your iPhone and computer need to be connected to a network with policies not blocking the communication.<\/p>\n<p>If no WLAN is available setting up a personal hotspot on your iOS device is also an option to connect with your computer to SensorLog.<\/p>\n<p>To retrieve data via HTTP GET\/POST you need to operate a server which is able to process HTTP GET \/ POST requests. Please enter the fully qualified URL under which your server and its SensorLog service is reachable into the text field titled URL. SensorLog uses the csv column names as GET\/POST argument names and the samples data as their values. A simple PHP example script can be found under<\/p>\n<p><a href=\"http:\/\/www.berndthomas.net\/SensorLog.php.zip\">http:\/\/www.berndthomas.net\/SensorLog.php.zip<\/a><\/p>\n<p>Explanation of the logged data (csv columns):<\/p>\n<p>loggingTime(txt) The time a set of sensor samples (csv line) is written to the log file or socket. For the sample time of an individual sensor please see the timestamp of each sensor.<\/p>\n<p>loggingSample(N) Sample set (csv line) number.<\/p>\n<p>identifierForVendor(txt)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/uikit\/uidevice\/1620059-identifierforvendor\">https:\/\/developer.apple.com\/reference\/uikit\/uidevice\/1620059-identifierforvendor<\/a><br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/foundation\/nsuuid\/1416585-uuidstring\">https:\/\/developer.apple.com\/reference\/foundation\/nsuuid\/1416585-uuidstring<\/a><\/p>\n<p>deviceID(txt) A device ID chosen by the user.<\/p>\n<p>locationTimestamp_since1970(s)<br \/>\nlocationLatitude(WGS84)<br \/>\nlocationLongitude(WGS84)<br \/>\nlocationAltitude(m)<br \/>\nlocationSpeed(m\/s)<br \/>\nlocationCourse(\u00b0)<br \/>\nlocationVerticalAccuracy(m)<br \/>\nlocationHorizontalAccuracy(m)<br \/>\nlocationFloor(Z)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/corelocation\/cllocation\">https:\/\/developer.apple.com\/reference\/corelocation\/cllocation<\/a><\/p>\n<p>locationHeadingTimestamp_since1970(s)<br \/>\nlocationHeadingX(\u00b5T)<br \/>\nlocationHeadingY(\u00b5T)<br \/>\nlocationHeadingZ(\u00b5T)<br \/>\nlocationTrueHeading(\u00b0)\u203alocationMagneticHeading(\u00b0)<br \/>\nlocationHeadingAccuracy(\u00b0)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/corelocation\/clheading\">https:\/\/developer.apple.com\/reference\/corelocation\/clheading<\/a><\/p>\n<p>accelerometerTimestamp_sinceReboot(s)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmlogitem\">https:\/\/developer.apple.com\/reference\/coremotion\/cmlogitem<\/a><br \/>\naccelerometerAccelerationX(G)<br \/>\naccelerometerAccelerationY(G)<br \/>\naccelerometerAccelerationZ(G)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmaccelerometerdata\">https:\/\/developer.apple.com\/reference\/coremotion\/cmaccelerometerdata<\/a><\/p>\n<p>gyroTimestamp_sinceReboot(s)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmlogitem\">https:\/\/developer.apple.com\/reference\/coremotion\/cmlogitem<\/a><br \/>\ngyroRotationX(rad\/s)<br \/>\ngyroRotationY(rad\/s)<br \/>\ngyroRotationZ(rad\/s)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmgyrodata\/1616167-rotationrate\">https:\/\/developer.apple.com\/reference\/coremotion\/cmgyrodata\/1616167-rotationrate<\/a><\/p>\n<p>motionTimestamp_sinceReboot(s)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmlogitem\">https:\/\/developer.apple.com\/reference\/coremotion\/cmlogitem<\/a><br \/>\nmotionYaw(rad)<br \/>\nmotionRoll(rad)<br \/>\nmotionPitch(rad)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmattitude\">https:\/\/developer.apple.com\/reference\/coremotion\/cmattitude<\/a><\/p>\n<p>motionRotationRateX(rad\/s)<br \/>\nmotionRotationRateY(rad\/s)<br \/>\nmotionRotationRateZ(rad\/s)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmdevicemotion\/1615967-rotationrate\">https:\/\/developer.apple.com\/reference\/coremotion\/cmdevicemotion\/1615967-rotationrate<\/a><\/p>\n<p>motionUserAccelerationX(G)<br \/>\nmotionUserAccelerationY(G)<br \/>\nmotionUserAccelerationZ(G)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmdevicemotion\/1616149-useracceleration\">https:\/\/developer.apple.com\/reference\/coremotion\/cmdevicemotion\/1616149-useracceleration<\/a><\/p>\n<p>motionAttitudeReferenceFrame(txt)<br \/>\nmotionQuaternionX(R)<br \/>\nmotionQuaternionY(R)<br \/>\nmotionQuaternionZ(R)<br \/>\nmotionQuaternionW(R)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmattitude\">https:\/\/developer.apple.com\/reference\/coremotion\/cmattitude<\/a><\/p>\n<p>motionGravityX(G)<br \/>\nmotionGravityY(G)<br \/>\nmotionGravityZ(G)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmdevicemotion\/1616164-gravity\">https:\/\/developer.apple.com\/reference\/coremotion\/cmdevicemotion\/1616164-gravity<\/a><\/p>\n<p>motionMagneticFieldX(\u00b5T)<br \/>\nmotionMagneticFieldY(\u00b5T)<br \/>\nmotionMagneticFieldZ(\u00b5T)<br \/>\nmotionMagneticFieldCalibrationAccuracy(Z)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmcalibratedmagneticfield\">https:\/\/developer.apple.com\/reference\/coremotion\/cmcalibratedmagneticfield<\/a><\/p>\n<p>activityTimestamp_sinceReboot(s)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmlogitem\">https:\/\/developer.apple.com\/reference\/coremotion\/cmlogitem<\/a><br \/>\nactivity(txt)<br \/>\nactivityActivityConfidence(Z)<br \/>\nactivityActivityStartDate(txt)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmmotionactivity\">https:\/\/developer.apple.com\/reference\/coremotion\/cmmotionactivity<\/a><\/p>\n<p>pedometerStartDate(txt)<br \/>\npedometerNumberofSteps(N)<br \/>\npedometerDistance(m)<br \/>\npedometerFloorAscended(N)<br \/>\npedometerFloorDescended(N)<br \/>\npedometerEndDate(txt)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmpedometerdata\">https:\/\/developer.apple.com\/reference\/coremotion\/cmpedometerdata<\/a><\/p>\n<p>altimeterTimestamp_sinceReboot(s)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmlogitem\">https:\/\/developer.apple.com\/reference\/coremotion\/cmlogitem<\/a><br \/>\naltimeterReset(bool)<br \/>\naltimeterRelativeAltitude(m)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmaltitudedata\/1615907-relativealtitude\">https:\/\/developer.apple.com\/reference\/coremotion\/cmaltitudedata\/1615907-relativealtitude<\/a><br \/>\naltimeterPressure(kPa)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/coremotion\/cmaltitudedata\">https:\/\/developer.apple.com\/reference\/coremotion\/cmaltitudedata<\/a><\/p>\n<p>IP_en0(txt) IP address of the WLAN connection.<br \/>\nIP_pdp_ip0(txt) IP address of the cellular data connection.<\/p>\n<p>deviceOrientation(Z)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/uikit\/uidevice\/1620053-orientation\">https:\/\/developer.apple.com\/reference\/uikit\/uidevice\/1620053-orientation<\/a><\/p>\n<p>batteryState(R)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/uikit\/uidevicebatterystate\">https:\/\/developer.apple.com\/reference\/uikit\/uidevicebatterystate<\/a><br \/>\nbatteryLevel(Z)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/uikit\/uidevice\/1620042-batterylevel\">https:\/\/developer.apple.com\/reference\/uikit\/uidevice\/1620042-batterylevel<\/a><\/p>\n<p>avAudioRecorderPeakPower(dB)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/avfoundation\/avaudiorecorder\/1389463-peakpower\">https:\/\/developer.apple.com\/reference\/avfoundation\/avaudiorecorder\/1389463-peakpower<\/a><br \/>\navAudioRecorderAveragePower(dB)<br \/>\n<a href=\"https:\/\/developer.apple.com\/reference\/avfoundation\/avaudiorecorder\/1387176-averagepower\">https:\/\/developer.apple.com\/reference\/avfoundation\/avaudiorecorder\/1387176-averagepower<\/a><\/em><\/p>\n<p>I hope you have enjoyed the introduction to the SensorLog app from Bernd Thomas and some of its features.\u00a0 The limited amount of information online is what prompted me to write this post and I hope it offers you some help with the use of this neat app.\u00a0 Enjoy.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over the years I&#8217;ve used a variety of sensor tracking programs that ran on smart phones.\u00a0 These programs will read the sensors built in the phone and log them.\u00a0 I like this because it uses hardware that is already available.\u00a0 There are many apps that I have used to do this.\u00a0 The latest one I used is called SensorLog authored by Bernd Thomas.\u00a0 As of this writing it is at version 1.9.2, dated June 2nd, 2017.\u00a0 I&#8217;ll be covering some&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.cloudacm.com\/?p=2932\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,10,5,3],"tags":[],"class_list":["post-2932","post","type-post","status-publish","format-standard","hentry","category-bike-rides","category-data-mining","category-iphone","category-rd"],"_links":{"self":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/2932","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2932"}],"version-history":[{"count":18,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/2932\/revisions"}],"predecessor-version":[{"id":2936,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=\/wp\/v2\/posts\/2932\/revisions\/2936"}],"wp:attachment":[{"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudacm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}