<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel rdf:about="https://community.wolfram.com">
    <title>Community RSS Feed</title>
    <link>https://community.wolfram.com</link>
    <description>RSS Feed for Wolfram Community showing any discussions tagged with Raspberry Pi sorted by most viewed.</description>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/157461" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/457158" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/157473" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/157704" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/157340" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/170725" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/163395" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/418132" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/246929" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/344278" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/157486" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1028536" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1057588" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/196759" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/456947" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/181641" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/416746" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/157817" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1179035" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/433430" />
      </rdf:Seq>
    </items>
  </channel>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/157461">
    <title>Building a GPS tracker with the Raspberry Pi</title>
    <link>https://community.wolfram.com/groups/-/m/t/157461</link>
    <description>This post shows how to build a simple GPS tracker with the Wolfram Language on a Raspberry Pi. 

To recreate this experiment you will need the following hardware (in addition to the Raspberry Pi itself):
[list]
[*][url=http://www.adafruit.com/products/746]Ultimate GPS Breakout[/url]
[*][url=http://www.adafruit.com/products/954]USB to TTL serial cable[/url]
[*][url=http://www.adafruit.com/products/954][/url][url=http://www.adafruit.com/products/64]Half-size bread board[/url]
[*][url=http://www.adafruit.com/products/758]Male/male jumper wires[/url]
[/list]Plug the GPS module into the breadboard as shown and connect red to VIN, black to GND, green to RX and white to TX, using the jumper wires and the USB to TTL serial cable. Plug the USB end of the cable into the Raspberry Pi (powered down). Power up your Raspberry Pi.

[img=width: 512px; height: 384px;]/c/portal/getImageAttachment?filename=1-out.jpg&amp;amp;userId=11733[/img]

The GPS module starts to transmit data shortly after power up and will continue to do so until it is unplugged from a power source.

In a terminal start the Wolfram Language using the following command:
[code]&amp;gt; wolfram

Wolfram Language (Raspberry Pi Pilot Release)
Copyright 1988-2013 Wolfram Research
Information &amp;amp; help: wolfram.com/raspi

In[1]:= 
[/code]

You can now open the serial port using the [url=reference.wolfram.com/language/ref/DeviceOpen.html]DeviceOpen [/url]by entering:
[mcode]serial = DeviceOpen[&amp;#034;Serial&amp;#034;,{&amp;#034;/dev/ttyUSB0&amp;#034;,&amp;#034;BaudRate&amp;#034;-&amp;gt;9600}]
[/mcode]

This returns a DeviceObject which can be used to read GPS data from. In this case we use [url=http://reference.wolfram.com/language/ref/DeviceReadBuffer.html]DeviceReadBuffer [/url]to read all available GPS data that has been generated up to this point:
[mcode]data = DeviceReadBuffer[serial,&amp;#034;String&amp;#034;]
[/mcode]
The data returned is in a comma separated format, called [url=http://aprs.gids.nl/nmea/]GPS NMEA sentences[/url].[code]     $GPRMC,154541.000,A,4005.8369,N,08814.7322,W,0.04,253.32,201113,,,A*79
     $GPVTG,253.32,T,,M,0.04,N,0.07,K,A*3B
     $GPGGA,154542.000,4005.8369,N,08814.7322,W,1,8,1.07,228.0,M,-33.9,M,,*6B
     $GPGSA,A,3,04,12,10,17,23,24,25,02,,,,,1.31,1.07,0.76*04
     $GPGSV,3,1,12,04,65,040,24,02,63,265,16,10,55,135,39,12,48,302,21*7D
     $GPGSV,3,2,12,17,35,096,33,05,19,190,17,25,13,321,33,24,12,247,16*71
     $GPGSV,3,3,12,23,05,061,31,13,02,090,27,20,02,036,35,45,,,*45
     $GPRMC,154542.000,A,4005.8369,N,08814.7322,W,0.06,253.32,201113,,,A*78[/code]
We can import the data with the Wolfram Language using ImportString:[mcode]csv = ImportString[ data, &amp;#034;CSV&amp;#034; ][/mcode]
The NMEA sentences which contain GPS coordinates start with $GPRMC so we filter for those using Cases and pattern matching:[mcode]gps = Cases[ csv, {&amp;#034;$GPRMC&amp;#034;, ___} ][/mcode]
The coordinates (latitude and longitude) are in the 4th and 6th position of each list, for example this is the GPS coordinate for the first data point:[mcode]Part[ gps, 1, {4,6} ] / 100[/mcode]
which returns the GPS location for Champaign, Illinois, where Wolfram Research is located 40&amp;#039; North, 88&amp;#039; West):[mcode]{40.0583, 88.1474}

[/mcode]</description>
    <dc:creator>Arnoud Buzing</dc:creator>
    <dc:date>2013-11-21T17:10:15Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/457158">
    <title>How to resolve &amp;#034;function value X is not a number&amp;#034; issue?</title>
    <link>https://community.wolfram.com/groups/-/m/t/457158</link>
    <description>Dear Community,&#xD;
&#xD;
I am just new to Mathematica that came with my Raspberry Pi2. For a while now I have been looking for a program, which is able to minimize a discontinuous and nonlinear problem. Up to now I created the following formulas:&#xD;
&#xD;
    f1[x_] := &#xD;
     Piecewise[{{0.00000000000252413096488599 x^4 - &#xD;
         0.0000000295981935774312 x^3 + 0.0001268180409138660 x^2 - &#xD;
         0.239339875030011 x + 368.934089585833, x &amp;gt; 0}, {0, x &amp;lt;= 0}}]&#xD;
    &#xD;
    f2[x_] := &#xD;
     Piecewise[{{0.00000000000327848026710691 x^4 - &#xD;
         0.0000000379764365996404 x^3 + 0.0001584280843487410 x^2 - &#xD;
         0.284905693712486 x + 386.639837124850, x &amp;gt; 0}, {0, x &amp;lt;= 0}}]&#xD;
    &#xD;
    f3[x_] := &#xD;
     Piecewise[{{0.00000000000273770414832564 x^4 - &#xD;
         0.0000000245466477791088 x^3 + 0.0000876247218487314 x^2 - &#xD;
         0.151272246878742 x + 298.178569447775, x &amp;gt; 0}, {0, x &amp;lt;= 0}}]&#xD;
    &#xD;
    f4[x_] := &#xD;
     Piecewise[{{0.00000000000151824463118546 x^4 - &#xD;
         0.0000000164748347339070 x^3 + 0.0000716029554621768 x^2 - &#xD;
         0.140270401260495 x + 293.998348739492, x &amp;gt; 0}, {0, x &amp;lt;= 0}}]&#xD;
&#xD;
    NMinimize[{f1[w] + f2[x] + f3[y] + f4[z], &#xD;
      Plus[w, x, y, z] == 7000}, {w \[Element] Interval[{0, 4000}], &#xD;
      x \[Element] Interval[{0, 4000}], y \[Element] Interval[{0, 3000}], &#xD;
      z \[Element] Interval[{0, 3000}]}]&#xD;
&#xD;
Unfortunately now I get the following error messages three times before the calculation is aborted:&#xD;
&#xD;
    During evaluation of In[8]:= NMinimize::nnum: The function value {812.066} is not a number at {Subscript[w, 1],Subscript[x, 1],Subscript[y, 1],Subscript[z, 1]} = {1052.02,1848.71,2479.67,1619.59}.&#xD;
&#xD;
Is there any quick way of resolving this issue? Did I enter something in a wrong way? At least the sum of the resulting values for w,x,y, and z being 7000 is correct, maybe 812,066 is a local minimum already. But why is there an error message? I also tried to use Minimize and different Methods, but the outcome is the same in all cases.&#xD;
&#xD;
And it is just a LOCAL minimum: As one might be able to see from the equation, fx[0]=0. A minimum value, f.e. for the entered w+x+y+z==7000, should incorporate that some of the functions are set to zero! Is there any way to include this possibility in a fast way? Or do I have to write a minimization for all 16 possibilities and minimize these again?&#xD;
&#xD;
Best regards,&#xD;
Peter</description>
    <dc:creator>Peter Bergmann</dc:creator>
    <dc:date>2015-03-11T16:05:57Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/157473">
    <title>Using the GPIO with the Wolfram Language + Raspberry Pi</title>
    <link>https://community.wolfram.com/groups/-/m/t/157473</link>
    <description>This post shows how to use the GPIO with the Wolfram Language on a Raspberry Pi. 

To recreate this experiment you will need the following hardware (in addition to the Raspberry Pi itself):
[list]
[*][url=http://www.adafruit.com/products/301]Super Bright Blue 5mm LED[/url]
[*][url=http://www.adafruit.com/products/1105]Pi T-Cobbler Breakout Kit[/url]
[*][url=http://www.adafruit.com/products/239]Full sized breadboard[/url]
[*][url=http://www.adafruit.com/products/758]Male/male jumper wires[/url]
[*]A 400 ohm resistor (to prevent the LEDs from burning out).
[/list]

Set up the breadboard as shown: Plug the T-Cobbler into the breadboard with 13 pins in the E column and 13 pin in the G column. Use the jumper wires
to connect pins 4, 17, 27, 22, 18, 23, 24 and 25 to evenly spaced free rows lower on the breadboard. Connect 8 blue LEDs from each jumper wire row to
the blue - column, with the flattened cathode side on the blue - column. Complete the circuit by connecting the resistor from the blue - column to the GND pin.
Connect the ribbon cable to the T-Cobbler and the Raspberry Pi correctly, and turn on your Raspberry Pi.

[img=width: 512px; height: 683px;]/c/portal/getImageAttachment?filename=2-5344gpio_community.jpg&amp;amp;userId=11733[/img]

The GPIO interface requires root privilege for access so the Wolfram Language or Mathematica needs to be started as root for this experiment.

In a terminal start the Wolfram Language using the following command (as root):
[code]&amp;gt; sudo wolfram

Wolfram Language (Raspberry Pi Pilot Release)
Copyright 1988-2013 Wolfram Research
Information &amp;amp; help: wolfram.com/raspi

In[1]:= 
[/code]

First we define the pins that correspond to connected LEDs:
[mcode]pins = {4,17,27,22,18,23,24,25}
[/mcode]

Next we can turn on individual LEDs by writing the value &amp;#039;1&amp;#039; to it:
[mcode]DeviceWrite[ &amp;#034;GPIO&amp;#034;, First[pins] -&amp;gt; 1 ]
[/mcode]

And of course turn it back off, by writing the value &amp;#039;0&amp;#039;:
[mcode]DeviceWrite[ &amp;#034;GPIO&amp;#034;, First[pins] -&amp;gt; 0 ]
[/mcode]

Or turn the LEDs on and off one at a time:
[mcode]Do[ 
 DeviceWrite[ &amp;#034;GPIO&amp;#034;, pins[[i]]-&amp;gt;1 ]; 
 Pause[.2]; 
 DeviceWrite[ &amp;#034;GPIO&amp;#034;, pins[[i]]-&amp;gt;0 ];
 ,{i,8}] 
[/mcode]</description>
    <dc:creator>Arnoud Buzing</dc:creator>
    <dc:date>2013-11-21T17:13:19Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/157704">
    <title>Snapping pictures with the Wolfram Language on the Raspberry Pi</title>
    <link>https://community.wolfram.com/groups/-/m/t/157704</link>
    <description>This post shows how to use the standard Raspberry Pi camera with the Wolfram Language on a Raspberry Pi. 

To recreate this experiment you will need the following hardware (in addition to the Raspberry Pi itself):
[list]
[*][url=http://www.adafruit.com/products/1367l]Raspberry Pi Camera Board[/url]
[/list]
First configure your Raspberry Pi Camera Board following the instructions from the [url=http://www.raspberrypi.org/camera]Raspberry Pi Camera web page[/url].

From the desktop double click the &amp;#039;Mathematica&amp;#039; icon or type &amp;#039;mathematica&amp;#039; in a terminal to launch the notebook interface.

To take pictures, simply run the DeviceRead command:

[mcode]DeviceRead[&amp;#034;RaspiCam&amp;#034;]
[/mcode]

[img=width: 800px; height: 500px;]/c/portal/getImageAttachment?filename=4-camdesk_community.jpg&amp;amp;userId=11733[/img]</description>
    <dc:creator>Arnoud Buzing</dc:creator>
    <dc:date>2013-11-21T17:19:08Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/157340">
    <title>Installing the Wolfram Language and Mathematica on your Raspberry Pi</title>
    <link>https://community.wolfram.com/groups/-/m/t/157340</link>
    <description>[i]Mathematica [/i]and The Wolfram Language are now available from ours and the Raspberry Pi foundation&amp;#039;s software repositories for the default Raspbian Linux distribution for the Pi. If you&amp;#039;re running a Raspbian image provided by the Raspberry Pi foundation, you can now install the software with the following steps:&#xD;
[list=1]&#xD;
[*]Ensure that you have at least [b]600[/b] megabytes of free storage on your Raspberry Pi&amp;#039;s SD card. The package itself will take up 429 megabytes of disk space when installed.&#xD;
[*][code]$ sudo apt-get update &amp;amp;&amp;amp; sudo apt-get install wolfram-engine[/code]&#xD;
[*]Agree to the licensing terms displayed (Use tab to move between fields in the license window. You will only need to do this once).&#xD;
[*]Wait for the installation to complete. &#xD;
[/list]You should now find Mathematica and the Wolfram Language installed on the LXDE desktop under the [b]Education[/b] menu and the Wolfram Language under the [b]Programming [/b]&#xD;
menu.&#xD;
&#xD;
In order to start the application from the Linux command line, type:[code]$ wolfram[/code]To start Mathematica, type:[code]$ mathematica[/code]&#xD;
If you have any questions about installing the application on your Raspberry Pi, feel free to ask! </description>
    <dc:creator>Alex Newman</dc:creator>
    <dc:date>2013-11-21T17:12:50Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/170725">
    <title>Building a sous-vide controller using Raspberry Pi / Mathematica</title>
    <link>https://community.wolfram.com/groups/-/m/t/170725</link>
    <description>Sous vide is the method of cooking food in airtight bags using a water bath at a precise temperature.
The method is fantastic to get the meat and seafood cooked evenly at the cooking point you love most.

[url=http://modernistcuisine.com/2013/01/why-cook-sous-vide/]http://modernistcuisine.com/2013/01/why-cook-sous-vide/[/url]
[url=http://www.douglasbaldwin.com/sous-vide.html]http://www.douglasbaldwin.com/sous-vide.html
[/url]
Buying an off the shelf sous vide can run for several hundreds of dollars. One of the many ways you can explore the world of modernist cooking is with your raspberry pi / some sensors and extra electronics/mathematica and a crock pot.
  
This initial posting will cover the very basic building blocks necessary for connecting to temperature gauges needed + turning on/off the crock pot.

I hope that through the community postings we can all develop a full fledge solution using the Raspberry Pi that can allow you to monitor the temperature of the water bath, food, setting up the off/on temperatures, chart the cooking process, send SMS text /email when food is done, etc.

Let&amp;#039;s start with the basics.

We&amp;#039;ll need to turn on/off the water bath (crock pot). For that we&amp;#039;ll need to control a relay.
You can build your own circuit. Gaven McDonald&amp;#039;s instructional video is a great starting point to build your own circuit and check how to connect the relay to your Raspberry Pi.
[url=https://www.youtube.com/watch?v=b6ZagKRnRdM]https://www.youtube.com/watch?v=b6ZagKRnRdM[/url]

You can buy a 2-relay module that works for Arduino/Raspberry just like this one.
[url=http://www.sainsmart.com/arduino/arduino-components/relays/arduino-pro-mini.html]http://www.sainsmart.com/arduino/arduino-components/relays/arduino-pro-mini.html[/url]

[url=http://www.sainsmart.com/arduino/arduino-components/relays/arduino-pro-mini.html][img=width: 500px; height: 500px;]/c/portal/getImageAttachment?filename=e11b1280bd72caccef99cdb9d60d4685.jpg&amp;amp;userId=11733[/img][/url]

Opening/Closing the relay is straightforward with Mathematica. Using one of the available pins (ie PIN 17) you can power on /off the crockpot by using the command

[mcode]DeviceWrite[&amp;#034;GPIO&amp;#034;,17-&amp;gt;1][/mcode]
Things get a little bit more challenging with taking temperature readings from the thermocouples.

As BobtheChemist pointed out in his blog[mcode]http://www.bobthechemist.com/index.php/10-stuff/24-thanksgiving-pi[/mcode]
The raspberryPi does not have analog pins in its GPIO (General Purpose Input Output). In his blog entry Bob shows how to overcome this limitation by using a capacitor and measuring how long it takes to charge it.

For this entry, I decided to document the use of an analog to digital converter (ADC). 

Checking out the web I found from several discussions and postings that the MCP 3008 would do the job.

[url=http://www.adafruit.com/products/856]http://www.adafruit.com/products/856
[/url]
We can use this transistor to hook up up to 8 analog sensors into our project. In our case, we&amp;#039;ll only need two. One for the water bath probe and another for the food probe.

The following wire diagram covers how to connect the MCP 3008 to the GPIO (Please focus on the right side of the MCP3008 wiring).
[url=http://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the-raspberry-pi/connecting-the-cobbler-to-a-mcp3008]http://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the-raspberry-pi/connecting-the-cobbler-to-a-mcp3008[/url]

For the thermocouples, you need to watch out on the type of thermocouples you get.

For this specific project the replacement probes for the Maverick ET-73 will work just fine.
[url=http://www.amazon.com/gp/product/B004W8B3PC/ref=oh_details_o00_s00_i00?ie=UTF8&amp;amp;psc=1]http://www.amazon.com/gp/product/B004W8B3PC/ref=oh_details_o00_s00_i00?ie=UTF8&amp;amp;psc=1[/url]

The thermocouples must be connected to the MCP3008 channels CH0 and CH1 in the following manner.

[img=width: 240px; height: 320px;]/c/portal/getImageAttachment?filename=photo.JPG&amp;amp;userId=78214[/img]

We do need to determine the value needed for the fixed resistance. The best value would be equal to the one expected when we reach the cooking temperatures. As I like my steaks medium I chose 60C as the point to use.

Using a thermometer, the thermocouples and a multimeter, I measured the temperature of a ice water glass, hot water and warm water. Using the three points, we can find the function that represents the temperature based on the resistance of the thermocouple.[mcode]temp = {20.6, 42, 83.3} + 273.15
resistance = {220650., 95800., 26340.}
data = Transpose[{Log@resistance, Log@temp}]
lm = LinearModelFit[data, x, x]
lm[{&amp;#034;RSquared&amp;#034;}][/mcode]The model fits very well R^2=0.998

What is the expected resistance at 60C?
[mcode]invdata = Transpose[{Log@temp, Log@resistance}]
Fit[invdata, {1, x}, x]
(*74.3895 - 10.9297 x*)
f[x_] := 74.38949510675315` - 10.929736543045369` x
Exp[f[Log[60 + 273.15]]]
(*54344.9*)[/mcode]Thus I used 56K Resistors for the thermocouples.

Now, to the function needed to read the thermocouples value. We have to probe the analog inputs from the MCP 3008 via the GPIO. 

We can use the library for the MCP 3008 developed by Gabriel Perez-Cerezo
[url=http://gpcf.eu/projects/embedded/adc/]http://gpcf.eu/projects/embedded/adc/[/url]

There are two libraries needed gpio.h and mcp3008.h. 

Dropped them both into /usr/include directory in the Raspberry Pi

The other very important step necessary is exporting the GPIO pins into /sys/class/GPIO, Gabriel also provides the script needed in hist web page. Please make sure to follow his intructions found in the comment section of the script. I forgot to run the [b]update-rc.d -f gpio defaults [/b]command after the installation and spent quite of bit of time after rebooting the equipment several days later. Was getting an error in Mathematica (and a c program to check if the reading was working, kept getting a segmentation fault error) all because the step needed for the script to run at startup was not in place.

Once we have the libraries in place we can address building a function with MathLink to get the readings from the MCP 3008

Please refer to the mathlink developer guide for more details in how it works
[url=http://reference.wolfram.com/mathematica/tutorial/MathLinkDeveloperGuide-Unix.html]http://reference.wolfram.com/mathematica/tutorial/MathLinkDeveloperGuide-Unix.html[/url]

Built the two files needed for the function
adc.tm[code]:Begin:	adc
:Pattern: 	adc[adc_Integer, clock_Integer, in_Integer, out_Integer, cs_Integer]
:Arguments:	{adc, clock, in, out, cs}
:ArgumentTypes:	{Integer, Integer, Integer, Integer, Integer}
:ReturnType:	Integer
:End:


[/code]adc.c
[code]#include &amp;lt;mathlink.h&amp;gt;
#include &amp;lt;mcp3008.h&amp;gt;

int adc(int adc, int clock, int in, int out, int cs) {
return mcp3008_value(adc, clock, in, out, cs);
}

int main(int argc, char *argv[]) {
return MLMain(argc, argv);
}[/code]After creating both files, I proceeded to compile the program with the following command.

This generated the necessary function that can now be invoked from Mathematica or the wolfram engine as follows.
[mcode]Install[&amp;#034;/home/pi/mathematica/adc/adc&amp;#034;];

(*We can now call function adc to read the voltage drop at the thermocouple
The voltage reading will be read by the MCP as a value between 0 (0V)to 1023 (3.3V) *)
(* Analog Channel = 0, ClockPin = 18, In = 23, Out =24, CS = 25 *)
adc[0, 18, 23, 24, 25]

(*The following function translates the voltage reading to temperature in Celsius*)

temp[channel_] := 

 Module[{R2 = 56000, a = -0.0913946, b = 6.80504, R1, 
   x = adc[channel, 18, 23, 24, 25]},
  R1 = (1024 - x) R2/x ; Exp[a Log[R1] + b] - 273.15]

(*Function datapoints is used to collect temperature readings in a matrix of length maxPoints. It also controls the relay
 to turn on the crockpot when the temperature reading is below the setpoint and turn it on when above the set point*)

datapoints[myList_List, fn_, maxLength_Integer, setPoint_Integer] := 

 Module[{x, val = fn},
  x = Append[myList, {DateList[], fn}];
  If[val &amp;lt; setPoint, DeviceWrite[&amp;#034;GPIO&amp;#034;, 17 -&amp;gt; 0], 
   DeviceWrite[&amp;#034;GPIO&amp;#034;, 17 -&amp;gt; 1]];
  If[Length[x] &amp;gt; maxLength, x = Take[x, -maxLength], x]]

data={};

(*Using a Chart to establish the setpoint and graph the temperature trend *)

Manipulate[

 DateListPlot[Refresh[data = datapoints[data, temp[0], 300, setPoint], 
   UpdateInterval -&amp;gt; 15, TrackedSymbols -&amp;gt; {}], Joined -&amp;gt; True, 
  PlotRange -&amp;gt; {Automatic, {20, 100}}, 
  GridLines -&amp;gt; {Automatic, {setPoint}}], {{setPoint, 60}, 30, 80, 1, 
  Appearance -&amp;gt; &amp;#034;Labeled&amp;#034;}]

[/mcode][img=width: 407px; height: 336px;]/c/portal/getImageAttachment?filename=7.png&amp;amp;userId=78214[/img]
This is a link to the video that shows the program running and controlling the relay.
[url=http://youtu.be/4ae42ctVZuk]http://youtu.be/4ae42ctVZuk[/url]

Next challenge will be to use the Web Server functionality of the Raspi to interact with Mathematica so as to control the set point and chart the temperature curve via a web page.
... to be continued.</description>
    <dc:creator>Diego Zviovich</dc:creator>
    <dc:date>2013-12-14T07:37:04Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/163395">
    <title>Remote Kernel on Raspberry Pi</title>
    <link>https://community.wolfram.com/groups/-/m/t/163395</link>
    <description>I am trying to connect to a remote Pi using the RDK. I guess there has to be a way to get the Mathematica kernel running on the Pi - without invoking the GUI frontend (i am running headless over SSH). But I am unable to figure out how to do that - has anybody already got that going? Any help is appreciated.

Arvind</description>
    <dc:creator>Arvind Govindaraj</dc:creator>
    <dc:date>2013-12-02T10:57:26Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/418132">
    <title>Free Wolfram Language on Raspberry Pi tutorial</title>
    <link>https://community.wolfram.com/groups/-/m/t/418132</link>
    <description>*NOTE: the main tutorial notebook is attached at the end of this post and [can be downloaded by clicking here][1].*&#xD;
&#xD;
&#xD;
----------&#xD;
&#xD;
&#xD;
I wanted to share the attached *Mathematica* notebook that I created for teaching kids (ages 9-14) about the Wolfram Language on the Raspberry Pi. It has a simplified (and colorful) interface for students and easy editing tools for teachers to create new content (even those with little or no experience using *Mathematica*). I am extremely grateful for the efforts of Anna Musser who very patiently helped me refine the interface over many iterations and piloted the first workshops using this notebook at Empow Studios!&#xD;
&#xD;
It includes a self-paced tutorial designed for beginning programmers who are young or young-at-heart. It also includes instructions for authoring your own tutorials. The interface is minimally dynamic so the tutorial will run as smooth as possible on the Raspberry Pi model B; if there is interest, then we could build a prettier dynamic interface for more powerful hardware. Please comment below with any improvements/changes that you would like to see and of course please comment or upvote if you find this useful or interesting :)&#xD;
&#xD;
&#xD;
----------&#xD;
## Sample of the attached tutorial:&#xD;
&#xD;
&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
**COMPLETE TUTORIAL NOTEBOOK ATTACHED BELOW**&#xD;
&#xD;
&#xD;
  [1]: https://www.dropbox.com/s/mddbex45h7ynao3/FirstCourseOnRPI.nb?dl=1&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2017-12-05at11.46.57AM.png&amp;amp;userId=11733</description>
    <dc:creator>Kyle Keane</dc:creator>
    <dc:date>2015-01-07T18:16:20Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/246929">
    <title>One pixel thermal imaging camera with Mathematica and Arduino</title>
    <link>https://community.wolfram.com/groups/-/m/t/246929</link>
    <description>Triggered by a leak in my hot water boiler at home I built a thermal imaging camera using an Arduino and interfacing it with Mathematica. I tried to make up for the &amp;#034;one-pixel-resolution&amp;#034; by using Mathematica&amp;#039;s powerful image analysis abilities. This is a work in progress and I would be delighted to get some comments/suggestions from the Community. In this project, I had a lot of help from [url=http://community.wolfram.com/web/bschelter/home]Bjoern Schelter[/url], who has recently joined this Community. If you have the components and use the programs below, you should have a &amp;#034;working&amp;#034; one-pixel thermal camera after 30 minutes or so of DIY. Here&amp;#039;s a sneak peek of what we want to get out (this one is a &amp;#034;selfie&amp;#034;):&#xD;
&#xD;
[img=width: 426px; height: 270px;]/c/portal/getImageAttachment?filename=asdwefasdcsdvvafe2345QT.PNG&amp;amp;userId=11733[/img]&#xD;
&#xD;
I use the following components:[list=1]&#xD;
[*]Arduino Uno R3&#xD;
[*][url=http://www.amazon.co.uk/XINTE-MLX90614ESF-DCI-non-contact-Infrared-Temperature/dp/B00IMU0LXG/ref=sr_1_2?ie=UTF8&amp;amp;qid=1399153918&amp;amp;sr=8-2&amp;amp;keywords=Melexis]MELEXIS / MLX90614ESF-DCI / DS Digital non-contact Infrared Temperature Sensor[/url]  (~ £35 and more or less the same in USD)&#xD;
[*][url=http://www.amazon.co.uk/MG995-Servo-Sensor-Mount-Black/dp/B00EZIYCUW/ref=sr_1_3?ie=UTF8&amp;amp;qid=1399153991&amp;amp;sr=8-3&amp;amp;keywords=Pan+tilt]MG995 Servo Sensor Mount Kit 2 DOF Pan and Tilt Black[/url] (~ £24, similar in USD)&#xD;
[*]Two 4.7 kOhm resistors.&#xD;
[*]One 0.1 uF capacitor.&#xD;
[*]One small breadboard.&#xD;
[*]5V power source.&#xD;
[*]Wires. &#xD;
[/list]The idea is illustrated in this [url=http://www.youtube.com/watch?v=rcTKVOzxCmw]Youtube video[/url]. To my best knowledge, the original idea comes from a [url=http://www.theimagingsource.com/en_US/blog/posts/20090622/]project of Steffen Strobel in the German science competition &amp;#034;Jugend Forscht&amp;#034;[/url]. The main idea is to mount a non-contact temperature sensor on a pan and tilt mechanism (i.e. two servos) on a tripod. An Arduino microcontroller is then used to communicate via the serial port with Mathematica, which is used to control the servos and triggers the measurements. After the data acquisition Mathematica cleans the data and produces some thermal images (see below).&#xD;
&#xD;
We use the following wiring diagram to connect the servos and the temperature sensor to the Arduino.&#xD;
[center][img=width: 300px; height: 203px;]/c/portal/getImageAttachment?filename=ThermoCam.jpg&amp;amp;userId=48754[/img][/center]&#xD;
The resistors are 4.7kOhm and the capacitor is 0.1uF. The sensor part is taken from the [url=http://bildr.org/2011/02/mlx90614-arduino/]bildr.blog[/url], which also shows how to make Arduino talk to the sensor. The Melexis sensor that we chose has a temperature resolution of 0.02 degrees Celsius and a rather narrow field of view, which is important for our application. &#xD;
&#xD;
For the servo part, we use the standard servo.h library; an example of its application can be found [url=http://arduino.cc/en/Tutorial/sweep]here[/url].&#xD;
&#xD;
Here is a photo of the sensor/head of the device.&#xD;
[center][img=width: 320px; height: 240px;]/c/portal/getImageAttachment?filename=photo.JPG&amp;amp;userId=48754[/img][/center]&#xD;
The entire device looks like this.&#xD;
[center][img=width: 240px; height: 320px;]/c/portal/getImageAttachment?filename=7033photo4.JPG&amp;amp;userId=48754[/img][/center]&#xD;
The idea is to use Mathematica to send instructions to the servos and to initiate the measurements. To interface Mathematica with Arduino we use the [url=http://library.wolfram.com/infocenter/Demos/5726/]SerialIO package[/url]. I found [url=http://williamjturkel.net/2011/12/25/connecting-arduino-to-mathematica-on-mac-os-x-with-serialio/]this website by William Turkel[/url] very useful to make SerialIO work on my Mac; following the steps and adapting some directories makes the package work without any problems.&#xD;
&#xD;
At that point, we have everything in place, and only need to put the bits together. We first need to upload this piece of code (also attached at the bottom) to the Arduino.&#xD;
[code]#include &amp;lt;i2cmaster.h&amp;gt;&#xD;
#include &amp;lt;Servo.h&amp;gt; &#xD;
&#xD;
//Servo setup&#xD;
int servoPin1 = 9;&#xD;
int servoPin2 = 10; &#xD;
Servo servo1;  &#xD;
Servo servo2;&#xD;
int angle1 = 40;   // servo start positions in degrees &#xD;
int angle2 = 50;&#xD;
&#xD;
&#xD;
//Melexis setup&#xD;
int sensor = 0;&#xD;
int inByte = 0;&#xD;
&#xD;
&#xD;
void setup()&#xD;
{&#xD;
	Serial.begin(9600);&#xD;
	&#xD;
       // attach pan-tilt servos&#xD;
       servo1.attach(servoPin1);&#xD;
       servo2.attach(servoPin2); &#xD;
&#xD;
&#xD;
       servo1.write(angle1);&#xD;
       servo2.write(angle2);&#xD;
&#xD;
&#xD;
	//Initialise the i2c bus&#xD;
	i2c_init(); &#xD;
	PORTC = (1 &amp;lt;&amp;lt; PORTC4) | (1 &amp;lt;&amp;lt; PORTC5);//enable pullups&#xD;
       establishContact();&#xD;
}&#xD;
&#xD;
&#xD;
void loop()&#xD;
{&#xD;
 if (Serial.available() &amp;gt; 0) &#xD;
  {&#xD;
   inByte = Serial.read();&#xD;
   &#xD;
   int dev = 0x5A&amp;lt;&amp;lt;1;&#xD;
   int data_low = 0;&#xD;
   int data_high = 0;&#xD;
   int pec = 0;&#xD;
&#xD;
&#xD;
   i2c_start_wait(dev+I2C_WRITE);&#xD;
   i2c_write(0x07);&#xD;
&#xD;
&#xD;
   // read&#xD;
   i2c_rep_start(dev+I2C_READ);&#xD;
   data_low = i2c_readAck(); //Read 1 byte and then send ack&#xD;
   data_high = i2c_readAck(); //Read 1 byte and then send ack&#xD;
   pec = i2c_readNak();&#xD;
   i2c_stop();&#xD;
&#xD;
&#xD;
   //This converts high and low bytes together and processes temperature, MSB is a error bit and is ignored for temps&#xD;
   double tempFactor = 0.02; // 0.02 degrees per LSB (measurement resolution of the MLX90614)&#xD;
   double tempData = 0x0000; // zero out the data&#xD;
   int frac; // data past the decimal point&#xD;
&#xD;
&#xD;
 // Serial.print(tempData);&#xD;
 // Serial.write(inByte);&#xD;
   // This masks off the error bit of the high byte, then moves it left 8 bits and adds the low byte.&#xD;
   tempData = (double)(((data_high &amp;amp; 0x007F) &amp;lt;&amp;lt; 8) + data_low);&#xD;
   tempData = (tempData * tempFactor)-0.01;&#xD;
&#xD;
&#xD;
   //inByte = (float)(((data_high &amp;amp; 0x007F) &amp;lt;&amp;lt; 8) + data_low);&#xD;
&#xD;
&#xD;
  float celsius = tempData - 273.15;&#xD;
   sensor=(int)(celsius*100);&#xD;
   //float fahrenheit = (celsius*1.8) + 32;&#xD;
&#xD;
  Serial.print(sensor);&#xD;
  &#xD;
   &#xD;
   // horizontal &amp;#034;H&amp;#034;-&amp;gt; 72; reverse &amp;#034;R&amp;#034;-&amp;gt; 82; vertical &amp;#034;V&amp;#034;-&amp;gt; 86; end &amp;#034;E&amp;#034;-&amp;gt; 69&#xD;
   &#xD;
  if(inByte==72)&#xD;
  {&#xD;
   angle1=angle1+1;&#xD;
   servo1.write(angle1);&#xD;
  }&#xD;
   if(inByte==82)&#xD;
  {&#xD;
   angle1=40;&#xD;
   servo1.write(angle1);&#xD;
  }&#xD;
  if(inByte==86)&#xD;
  {&#xD;
   angle2=angle2+1;&#xD;
   servo2.write(angle2);&#xD;
  }&#xD;
    if(inByte==69)&#xD;
  {&#xD;
   angle1 = 40;   // servo back to start&#xD;
   angle2 = 50;&#xD;
   servo1.write(angle1);&#xD;
   servo2.write(angle2);&#xD;
  }&#xD;
  &#xD;
   delay(15); // 15 works; wait 15 milliseconds before printing again&#xD;
 }&#xD;
&#xD;
&#xD;
}&#xD;
&#xD;
&#xD;
&#xD;
void establishContact() &#xD;
{&#xD;
 while (Serial.available() &amp;lt;= 0) &#xD;
 {&#xD;
   Serial.print(&amp;#039;A&amp;#039;);&#xD;
   delay(100);&#xD;
 }&#xD;
}&#xD;
[/code]&#xD;
The idea is to make Mathematica communicate with the Arduino via the serial connection. The Arduino sketch shows that Ardunio is waiting for instructions, e.g. &amp;#034;H&amp;#034; to move horizontally, &amp;#034;V&amp;#034; to move vertically and &amp;#034;E&amp;#034; to go to the end position. &#xD;
[mcode](*First we load the SerialIO package. See instructions above.*)&#xD;
&#xD;
&amp;lt;&amp;lt; SerialIO`&#xD;
&#xD;
(*We test whether Mathematica&amp;#039;s applications folder is in the Path. On some Macs Mathematica will be in the /Library directory - used in this example- and in others in the /Users/username/Library directory, where &amp;#034;username&amp;#034; needs to be replaced by the correct user name.*)&#xD;
&#xD;
MemberQ[$Path, &amp;#034;/Library/Mathematica/Applications&amp;#034;]&#xD;
&#xD;
(*If this gives True all is fine. If it evaluates to False execute&#xD;
AppendTo[$Path, &amp;#034;/Library/Mathematica/Applications&amp;#034;]&#xD;
*)&#xD;
&#xD;
(*Connect to the Arduino*)&#xD;
&#xD;
myArduino = &#xD;
  SerialOpen[Quiet[FileNames[&amp;#034;tty.usb*&amp;#034;, {&amp;#034;/dev&amp;#034;}, Infinity]][[1]]];&#xD;
SerialSetOptions[myArduino, &amp;#034;BaudRate&amp;#034; -&amp;gt; 9600];&#xD;
While[SerialReadyQ[myArduino] == False, Pause[0.1]];&#xD;
&#xD;
(*Data collection, in this case 40 vertical and 70 horizontal pixels; runtime 2-3 minutes; pauses cannot be reduced much further.*)&#xD;
&#xD;
pixels = {}; SerialRead[myArduino]; For[j = 1, j &amp;lt; 41, j++, &#xD;
 For[i = 1, i &amp;lt; 71, i++, SerialWrite[myArduino, &amp;#034;H&amp;#034;]; &#xD;
  AppendTo[pixels, (SerialRead[myArduino] // ToExpression)/100.]; &#xD;
  Pause[0.1]]; SerialWrite[myArduino, &amp;#034;R&amp;#034;]; &#xD;
 SerialWrite[myArduino, &amp;#034;V&amp;#034;]; SerialRead[myArduino]; &#xD;
 Pause[0.1];]; SerialWrite[myArduino, &amp;#034;E&amp;#034;];&#xD;
&#xD;
(*After the data aquisition close the connection to Arduino*)&#xD;
SerialClose[myArduino]&#xD;
&#xD;
(*Now we can use several different ways to represent the data, note that some point at the beginning/end of the scanned lines are removed; there were too many measurements errors just after the &amp;#034;carriage return&amp;#034;*)&#xD;
&#xD;
ArrayPlot[Partition[Reverse[pixels], 70][[All, 2 ;; -10]], &#xD;
 ColorFunction -&amp;gt; &amp;#034;Rainbow&amp;#034;]&#xD;
&#xD;
(*here&amp;#039;s another colour scheme.*)&#xD;
ArrayPlot[Partition[Reverse[pixels], 70][[All, 2 ;; -10]], &#xD;
&#xD;
(*Occasionally there are some outliers in the measurements; here we clean them out.*)&#xD;
ArrayPlot[&#xD;
 Partition[Reverse[pixels /. x_ /; x &amp;gt; 35. -&amp;gt; 35.], 70][[All, &#xD;
   2 ;; -10]], ColorFunction -&amp;gt; &amp;#034;Temperature&amp;#034;]&#xD;
 ColorFunction -&amp;gt; &amp;#034;Temperature&amp;#034;]&#xD;
&#xD;
(*This last one uses interpolation to make the image smoother.*)&#xD;
&#xD;
ListContourPlot[&#xD;
 Partition[Reverse[Log /@ pixels /. x_ /; x &amp;gt; 35. -&amp;gt; 35.], &#xD;
   70][[-1 ;; 1 ;; -1, 1 ;; -10]], AspectRatio -&amp;gt; 0.9, &#xD;
 ColorFunction -&amp;gt; &amp;#034;Rainbow&amp;#034;, PlotRange -&amp;gt; All, &#xD;
 InterpolationOrder -&amp;gt; 2, Contours -&amp;gt; 60, ContourStyle -&amp;gt; None][/mcode][center][/center]So here&amp;#039;s a photo of my broken boiler and its scan:&#xD;
[center][img=width: 518px; height: 257px;]/c/portal/getImageAttachment?filename=BoilerScan.jpg&amp;amp;userId=48754[/img][/center]&#xD;
Because of the scanning procedure (which just looks at the angle and does not use any projection), the scan is slightly distorted, but it is possible to recognize the main features and even the sticker on the front!&#xD;
&#xD;
It appears that this rather primitive device can also be used to analyse electrical components. Here is an image of my MacBook Pro. [center][img=width: 450px; height: 306px;]/c/portal/getImageAttachment?filename=Laptop1.jpg&amp;amp;userId=48754[/img][/center]&#xD;
 The position of the CPU becomes quite obvious.&#xD;
&#xD;
There are many things that need to be improved: &#xD;
&#xD;
(i) First, there is the projection issue. The scanner does scan angles. It needs to be projected to a 2D plane. One might use an ultrasonic distance sensor to get better results.&#xD;
(ii) The device needs to be calibrated.&#xD;
(iii) A user interface is needed. It would be useful to click on the image and get the temperature reading.&#xD;
(iv) The communication between Mathematica and the Arduino need to be improved. The starting position of 40/50 degrees is hard-coded into the Arduino sketch. It should be done by the Mathematica code.&#xD;
(v) We have not even started to use Mathematica&amp;#039;s features on this. Much image processing could be done. The image should be overlayed to a normal photo of the object that is scanned. Manipulate could be used to change thresholds, i.e. the threshold to cut-off outliers, which is currently set to 35 degrees. &#xD;
(vi) The speed might be improved. I suppose that the scanning time of 3 minutes or so is typical for these devices, but one might improve that a bit. Also, Mathematica could use edge-detection to determine regions where a higher scan density would be helpful to get a better resolution. This only makes sense if the servos could be directed to a certain position much more precisely; alternatively, we could use random positions, which then are precisely determined using an accelerometer or so.&#xD;
&#xD;
There is of course much more to do. In spite of this being work in progress, I wanted to share this project, and hope for helpful comments.&#xD;
&#xD;
I attach the Mathematica notebook. I have a movie of the scanning process and the actual arduino sketch which I cannot upload directly. Here are links to the [url=https://www.dropbox.com/s/sm2prb5w0wrqexp/ThermoCamera_Forum.zip]arduino sketch[/url] and the [url=https://www.dropbox.com/s/wpgpww8a7jhjfn0/Scan.MOV]scanning movie[/url].&#xD;
&#xD;
M.</description>
    <dc:creator>Marco Thiel</dc:creator>
    <dc:date>2014-05-04T00:48:33Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/344278">
    <title>Using your smart phone as the ultimate sensor array for Mathematica</title>
    <link>https://community.wolfram.com/groups/-/m/t/344278</link>
    <description>Many fantastic posts in this community describe how to connect external devices to Mathematica and how to read the data. Connecting Mathematica to an Arduino for example allows you to read and then work with data from all kinds of sensors. In most of the cases, when we speak about connected devices, additional hardware is necessary. Smart phones, on the other hand, are our permanent companions and they host a wide array of sensors that we can tap into with Mathematica. For this post, I will be using an iPhone 5 - but a similar approach can be taken with many other smart phones. [Björn Schelter][1] and myself have worked on this together.&#xD;
&#xD;
The first thing we need in order to be able to read the iPhone is a little App which can be purchased on the iTunes App store: it is called [Sensor Data][2]. When you open the app you see a screen like this one. &#xD;
&#xD;
![enter image description here][3]&#xD;
&#xD;
At the top of the screen you see an IP address and a port number (after the colon!). These numbers will be important to connect to the phone and either download data or stream sensor data directly. If you click on the &amp;#034;start capture&amp;#034; the iPhone&amp;#039;s data will be stored on the phone and can be downloaded into Mathematica. In this post we are rather interested in the &amp;#034;Streaming&amp;#034; function. If you click on the respective button on the bottom you get to a screen like this:&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
There you can choose a frequency for the measurements and start the streaming. In fact we also can choose which sensors we want to use with the Config button. &#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
The following Mathematica code will work when all (!) sensors are switched on. Now we are ready to connect to the iPhone. Switch the streaming on and execute the following commands:&#xD;
&#xD;
    ClearAll[&amp;#034;Global`*&amp;#034;];&#xD;
    For[i = 1, i &amp;lt; 3, i++, Quiet[InstallJava[]]];&#xD;
    Needs[&amp;#034;JLink`&amp;#034;]&#xD;
&#xD;
and then &#xD;
&#xD;
    LoadJavaClass[&amp;#034;java.util.Arrays&amp;#034;];&#xD;
    packet = JavaNew[&amp;#034;java.net.DatagramPacket&amp;#034;, JavaNew[&amp;#034;[B&amp;#034;, 1024], 1024];&#xD;
    socket = JavaNew[&amp;#034;java.net.DatagramSocket&amp;#034;, 10552];&#xD;
    socket@setSoTimeout[10];&#xD;
    listen[] := If[$Failed =!= Quiet[socket@receive[packet], Java::excptn], &#xD;
    record =JavaNew[&amp;#034;java.lang.String&amp;#034;, java`util`Arrays`copyOfRange @@ &#xD;
    packet /@ {getData[], getOffset[], getLength[]}]@toString[] //&#xD;
    Sow];&#xD;
&#xD;
Next we have to define a ScheduledTask to read the sensors:&#xD;
&#xD;
    RemoveScheduledTask[ScheduledTasks[]];&#xD;
    results = {}; &#xD;
    RunScheduledTask[AppendTo[results, Quiet[Reap[listen[]][[2, 1]]]]; If[Length[results] &amp;gt; 1200, Drop[results, 150]], 0.01];&#xD;
&#xD;
We also need to define a streaming function:&#xD;
&#xD;
    stream := Refresh[ToExpression[StringSplit[#[[1]], &amp;#034;,&amp;#034;]] &amp;amp; /@ Select[results[[-1000 ;;]], Head[#] == List &amp;amp;], UpdateInterval -&amp;gt; 0.01]&#xD;
&#xD;
Alright. Now comes the interesting part. Using &#xD;
&#xD;
    (*Compass*)&#xD;
    While[Length[results] &amp;lt; 1000, Pause[2]]; Dynamic[AngularGauge[Refresh[stream[[-1, 30]], UpdateInterval -&amp;gt; 0.01], {360, 0}, &#xD;
    ScaleDivisions -&amp;gt; None, GaugeLabels -&amp;gt; {Placed[&amp;#034;N&amp;#034;, Top], Placed[&amp;#034;S&amp;#034;, Bottom], Placed[&amp;#034;E&amp;#034;, Right], Placed[&amp;#034;W&amp;#034;, Left]}, ScaleOrigin -&amp;gt; {{5 Pi/2, Pi/2}, 1}, ScalePadding -&amp;gt; All, ImageSize -&amp;gt; Medium], SynchronousUpdating -&amp;gt; False]&#xD;
&#xD;
we can measure the bearing of our iPhone. The resulting compass moves as we move the iPhone:&#xD;
&#xD;
![enter image description here][6]&#xD;
&#xD;
We can also read the (x-,y-,z-) accelerometers&#xD;
&#xD;
    (*Plot Ascelerometers*)&#xD;
    While[Length[results] &amp;lt; 1000, Pause[2]]; Dynamic[Refresh[ListLinePlot[{stream[[All, 2]], stream[[All, 3]], stream[[All, 4]]}, PlotRange -&amp;gt; All], UpdateInterval -&amp;gt; 0.1]]&#xD;
&#xD;
which gives plots like this one:&#xD;
&#xD;
![enter image description here][7]&#xD;
&#xD;
The update is a bit bumpy, because the data is only sent every second or so from the iPhone; the measurements, however, are taken with a frequency of up to 100Hz. We can also represent the FFT of the streamed data like so:&#xD;
&#xD;
    (*Plot FFT of accelorometers*)&#xD;
    While[Length[results] &amp;lt; 1000, &#xD;
     Pause[2]]; Dynamic[&#xD;
     Refresh[ListLinePlot[&#xD;
       Log /@ {Abs[Fourier[Standardize[stream[[All, 2]]]]], &#xD;
         Abs[Fourier[Standardize[stream[[All, 3]]]]], &#xD;
         Abs[Fourier[Standardize[stream[[All, 4]]]]]}, &#xD;
       PlotRange -&amp;gt; {{0, 200}, {-5, 2.5}}, ImageSize -&amp;gt; Large], &#xD;
      UpdateInterval -&amp;gt; 0.1]]&#xD;
&#xD;
Adding a &amp;#034;real time&amp;#034; scale is also quite straight forward:&#xD;
&#xD;
(*Measurements with time scale*)&#xD;
&#xD;
    While[Length[results] &amp;lt; 1000, Pause[2]];&#xD;
    starttime = IntegerPart[stream[[2, 1]]];&#xD;
    Dynamic[Refresh[&#xD;
      ListLinePlot[&#xD;
       Transpose[{(stream[[Max[-300, -Length[stream]] ;;, 1]] - &#xD;
           starttime), stream[[Max[-300, -Length[stream]] ;;, 2]]}], &#xD;
       PlotRange -&amp;gt; All, ImageSize -&amp;gt; Large], UpdateInterval -&amp;gt; 0.01]]&#xD;
&#xD;
Well, then. We can also plot our iPhone&amp;#039;s position in space&#xD;
&#xD;
    (*3d Motion*)&#xD;
    &#xD;
    While[Length[results] &amp;lt; 1000, Pause[2]]; Dynamic[&#xD;
     Refresh[ListLinePlot[{stream[[All, 5]], stream[[All, 6]], &#xD;
        stream[[All, 7]]}, PlotRange -&amp;gt; All], UpdateInterval -&amp;gt; 0.1]]&#xD;
    &#xD;
    While[Length[results] &amp;lt; 1000, Pause[2]]; Dynamic[&#xD;
     Graphics3D[{Black, &#xD;
       Rotate[Rotate[&#xD;
         Rotate[Cuboid[{-2, -1, -0.2}, {2, 1, 0.2}], &#xD;
          stream[[-1, 7]], {0, 0, 1}], -1*stream[[-1, 6]], {0, 1, 0}], &#xD;
        stream[[-1, 5]], {1, 0, 0}]}, &#xD;
      PlotRange -&amp;gt; {{-3, 3}, {-3, 3}, {-3, 3}}, Boxed -&amp;gt; True], &#xD;
     UpdateInterval -&amp;gt; 0.1, SynchronousUpdating -&amp;gt; False]&#xD;
&#xD;
This looks like so:&#xD;
&#xD;
![enter image description here][8]&#xD;
&#xD;
Last but not least we can write a little GUI to access all different sensors. (This does run a bit slow though!)&#xD;
&#xD;
(*GUI all sensors*)&#xD;
&#xD;
    sensororder = {&amp;#034;Timestamp&amp;#034;, &amp;#034;Accel_X&amp;#034;, &amp;#034;Accel_Y&amp;#034;, &amp;#034;Accel_Z&amp;#034;, &amp;#034;Roll&amp;#034;, &#xD;
       &amp;#034;Pitch&amp;#034;, &amp;#034;Yaw&amp;#034;, &amp;#034;Quat.X&amp;#034;, &amp;#034;Quat.Y&amp;#034;, &amp;#034;Quat.Z&amp;#034;, &amp;#034;Quat.W&amp;#034;, &amp;#034;RM11&amp;#034;, &#xD;
       &amp;#034;RM12&amp;#034;, &amp;#034;RM13&amp;#034;, &amp;#034;RM21&amp;#034;, &amp;#034;RM22&amp;#034;, &amp;#034;RM23&amp;#034;, &amp;#034;RM31&amp;#034;, &amp;#034;RM32&amp;#034;, &amp;#034;RM33&amp;#034;, &#xD;
       &amp;#034;GravAcc_X&amp;#034;, &amp;#034;GravAcc_Y&amp;#034;, &amp;#034;GravAcc_Z&amp;#034;, &amp;#034;UserAcc_X&amp;#034;, &amp;#034;UserAcc_Y&amp;#034;, &#xD;
       &amp;#034;UserAcc_Z&amp;#034;, &amp;#034;RotRate_X&amp;#034;, &amp;#034;RotRate_Y&amp;#034;, &amp;#034;RotRate_Z&amp;#034;, &amp;#034;MagHeading&amp;#034;, &#xD;
       &amp;#034;TrueHeading&amp;#034;, &amp;#034;HeadingAccuracy&amp;#034;, &amp;#034;MagX&amp;#034;, &amp;#034;MagY&amp;#034;, &amp;#034;MagZ&amp;#034;, &amp;#034;Lat&amp;#034;, &#xD;
       &amp;#034;Long&amp;#034;, &amp;#034;LocAccuracy&amp;#034;, &amp;#034;Course&amp;#034;, &amp;#034;Speed&amp;#034;, &amp;#034;Altitude&amp;#034;, &#xD;
       &amp;#034;Proximity&amp;#034;};&#xD;
    While[Length[results] &amp;lt; 1000, Pause[2]]; Manipulate[&#xD;
     Dynamic[Refresh[&#xD;
       ListLinePlot[{stream[[All, Position[sensororder, a][[1, 1]]]], &#xD;
         stream[[All, Position[sensororder, b][[1, 1]]]], &#xD;
         stream[[All, Position[sensororder, c][[1, 1]]]]}, &#xD;
        PlotRange -&amp;gt; All, ImageSize -&amp;gt; Full], &#xD;
       UpdateInterval -&amp;gt; 0.01]], {{a, &amp;#034;Accel_X&amp;#034;}, &#xD;
      sensororder}, {{b, &amp;#034;Accel_Y&amp;#034;}, sensororder}, {{c, &amp;#034;Accel_Z&amp;#034;}, &#xD;
      sensororder}, ControlPlacement -&amp;gt; Left, &#xD;
     SynchronousUpdating -&amp;gt; False]&#xD;
&#xD;
This gives a user interface which looks like this:&#xD;
&#xD;
![enter image description here][9]&#xD;
&#xD;
In the drop down menu we can choose three out of all sensors. These are all available sensors:&#xD;
&#xD;
&amp;gt; &amp;#034;Timestamp&amp;#034;, &amp;#034;Accel_X&amp;#034;, &amp;#034;Accel_Y&amp;#034;, &amp;#034;Accel_Z&amp;#034;, &amp;#034;Roll&amp;#034;, &amp;#034;Pitch&amp;#034;, &amp;#034;Yaw&amp;#034;,&#xD;
&amp;gt; &amp;#034;Quat.X&amp;#034;, &amp;#034;Quat.Y&amp;#034;, &amp;#034;Quat.Z&amp;#034;, &amp;#034;Quat.W&amp;#034;, &amp;#034;RM11&amp;#034;,  &amp;#034;RM12&amp;#034;, &amp;#034;RM13&amp;#034;,&#xD;
&amp;gt; &amp;#034;RM21&amp;#034;, &amp;#034;RM22&amp;#034;, &amp;#034;RM23&amp;#034;, &amp;#034;RM31&amp;#034;, &amp;#034;RM32&amp;#034;, &amp;#034;RM33&amp;#034;, &amp;#034;GravAcc_X&amp;#034;,&#xD;
&amp;gt; &amp;#034;GravAcc_Y&amp;#034;, &amp;#034;GravAcc_Z&amp;#034;, &amp;#034;UserAcc_X&amp;#034;, &amp;#034;UserAcc_Y&amp;#034;,   &amp;#034;UserAcc_Z&amp;#034;,&#xD;
&amp;gt; &amp;#034;RotRate_X&amp;#034;, &amp;#034;RotRate_Y&amp;#034;, &amp;#034;RotRate_Z&amp;#034;, &amp;#034;MagHeading&amp;#034;, &amp;#034;TrueHeading&amp;#034;,&#xD;
&amp;gt; &amp;#034;HeadingAccuracy&amp;#034;, &amp;#034;MagX&amp;#034;, &amp;#034;MagY&amp;#034;, &amp;#034;MagZ&amp;#034;, &amp;#034;Lat&amp;#034;,   &amp;#034;Long&amp;#034;,&#xD;
&amp;gt; &amp;#034;LocAccuracy&amp;#034;, &amp;#034;Course&amp;#034;, &amp;#034;Speed&amp;#034;, &amp;#034;Altitude&amp;#034;, &amp;#034;Proximity&amp;#034;&#xD;
&#xD;
There are certainly any things that can and should be improved. The main problem seems to be that the data, even if sampled at 100Hz, is sent to the iPhone only every second or so. So it is not really real time. I hope that someone who is better at iPhone programming than I am - I am really rubbish at it- could help and write an iPhone program to stream the data in a more convenient way: one by one rather than in packets. &#xD;
&#xD;
There are many potential applications for this. Here are some I could come up with:&#xD;
&#xD;
 1. You can carry the iPhone around and measure your movements (acceleration). Attached to your hand you can measure your tremor. &#xD;
 2. The magnetometer is really cool. You can use it to find metal bars in the walls an also electric cables. &#xD;
 3. You can collect GPS data for all sorts of applications; there are ideas to use this for the detection of certain diseases. For example if it takes you longer than usual to find your car when you come from shopping that might hint at early stages of dementia --- or sleep deprivation.&#xD;
 4. When you put the phone on a machine, like a running motor, you can measure the vibrations. When you perform a frequency analysis you can check whether the motor runs alright.&#xD;
 5. Using the accelerometers I was able to measure my breathing (putting the phone on my chest).&#xD;
 &#xD;
I think that there might also be quite some potential for using the Wolfram Cloud here. Deploying a program in the cloud and reading from your phone is certainly quite interesting. The problem is that this particular app only works via WiFi. It would be nice to have one that works via 3G. &#xD;
&#xD;
So, in summary, it might be quite useful to use the iPhone&amp;#039;s sensors. The advantage is that nearly everyone carries a smartphone with them all the time. Making more of your smart phone&amp;#039;s sensors with Mathematica seems to be a nice playground for applications. I&amp;#039;d love to hear about your ideas...&#xD;
&#xD;
Cheers,&#xD;
&#xD;
Marco&#xD;
&#xD;
PS: When you are done with the streaming you should execute these commands:&#xD;
&#xD;
    (*Remove Scheduled Tasks and close link*)&#xD;
    RemoveScheduledTask[ScheduledTasks[]]; socket@close[];&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com/web/bschelter&#xD;
  [2]: https://itunes.apple.com/gb/app/sensor-data/id397619802?mt=8&#xD;
  [3]: /c/portal/getImageAttachment?filename=sensorwelcome.PNG&amp;amp;userId=48754&#xD;
  [4]: /c/portal/getImageAttachment?filename=sensorstreaming.PNG&amp;amp;userId=48754&#xD;
  [5]: /c/portal/getImageAttachment?filename=Allsensors.PNG&amp;amp;userId=48754&#xD;
  [6]: /c/portal/getImageAttachment?filename=Compass.gif&amp;amp;userId=48754&#xD;
  [7]: /c/portal/getImageAttachment?filename=Accelerometer.gif&amp;amp;userId=48754&#xD;
  [8]: /c/portal/getImageAttachment?filename=Iphonemovement.gif&amp;amp;userId=48754&#xD;
  [9]: /c/portal/getImageAttachment?filename=ScreenShot2014-09-15at23.52.46.png&amp;amp;userId=48754</description>
    <dc:creator>Marco Thiel</dc:creator>
    <dc:date>2014-09-15T23:53:14Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/157486">
    <title>Checking the weather with the Wolfram Language + Raspberry Pi</title>
    <link>https://community.wolfram.com/groups/-/m/t/157486</link>
    <description>This post shows how to use a weather station module with the Wolfram Language on a Raspberry Pi. 
To recreate this experiment you will need the following hardware (in addition to the Raspberry Pi itself):
[list]
[*][url=http://www.web4robot.com/PiWeather.html]Raspberry Pi Weather Station Board[/url]
[/list]

[img=width: 512px; height: 384px;]/c/portal/getImageAttachment?filename=3-weather_community.jpg&amp;amp;userId=11733[/img]

First configure your Raspberry Pi for I2C interface support as described in the [url=http://www.web4robot.com/files/PiWeatherCodeExamples.zip]ReadMe.pdf[/url] from the manufacturer.
Next turn off your Raspberry Pi and connect the Weather Station board to the 26 pin interface. Turn your Pi back on and check that the device is detected:
[code]
&amp;gt; sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 4e --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[/code]

The Weather Station requires root privilege for access so the Wolfram Language or Mathematica needs to be started as root for this experiment.
In a terminal start the Wolfram Language using the following command (as root):
[code]&amp;gt; sudo wolfram
Wolfram Language (Raspberry Pi Pilot Release)
Copyright 1988-2013 Wolfram Research
Information &amp;amp; help: wolfram.com/raspi
In[1]:= 
[/code]
First we open the device:
[mcode]In[1]:= obj = DeviceOpen[&amp;#034;RaspberryPiWeatherStation&amp;#034;]
Out[1]= DeviceObject[{RaspberryPiWeatherStation, 1}]
[/mcode]
Next we can read the current temperature as measured by the board:
[mcode]In[2]:= DeviceRead[obj, &amp;#034;Temperature&amp;#034;]
Out[2]= 25 degrees Celsius
[/mcode]
Or the relative humidity:
[mcode]In[3]:= DeviceRead[obj, &amp;#034;Humidity&amp;#034;]
Out[3]= 30 percent
[/mcode]
And also the barometric pressure:
[mcode]In[4]:= DeviceRead[obj, &amp;#034;Pressure&amp;#034;]
Out[4]= 993 hectopascals
[/mcode]</description>
    <dc:creator>Arnoud Buzing</dc:creator>
    <dc:date>2013-11-21T17:15:55Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1028536">
    <title>Mathematica 11.0.1 now available for the Raspberry Pi</title>
    <link>https://community.wolfram.com/groups/-/m/t/1028536</link>
    <description>Hi all,&#xD;
&#xD;
Mathematica 11.0.1 is now available for the Raspberry Pi on Raspbian. If you already have Mathematica installed on your Raspberry Pi, you can update with the following:&#xD;
&#xD;
    sudo apt-get update &amp;amp;&amp;amp; sudo apt-get upgrade wolfram-engine&#xD;
&#xD;
If you don&amp;#039;t already have Mathematica installed you can run the following commands to install it:&#xD;
&#xD;
    sudo apt-get update &amp;amp;&amp;amp; sudo apt-get install wolfram-engine&#xD;
&#xD;
New features for the Raspberry Pi include :&#xD;
&#xD;
 - Neural Network features including constructing custom nets : http://reference.wolfram.com/language/guide/NeuralNetworks.html&#xD;
 - Audio processing features including out of core streaming of large sounds as well as advanced audio processing : http://reference.wolfram.com/language/guide/AudioProcessing.html&#xD;
 - Travel based path plan functions including path finding from one city to another : http://reference.wolfram.com/language/guide/LocationsPathsAndRouting.html&#xD;
 - Channel based communication for sending and receiving messages : http://reference.wolfram.com/language/guide/Channel-BasedCommunication.html&#xD;
 - Powerful and easy scripting through WolframScript : http://reference.wolfram.com/language/ref/program/wolframscript.html&#xD;
 - And many more : http://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn11.html&#xD;
&#xD;
Additionally, with the new release of WolframScript on the Raspberry Pi, you can install WolframScript standalone and run it without a local kernel against the cloud using the `-cloud` option. This means you can use the Wolfram Language through WolframScript on the Raspberry Pi without having wolfram-engine installed by running it against the cloud. See the documentation page for WolframScript for more details.</description>
    <dc:creator>Ian Johnson</dc:creator>
    <dc:date>2017-03-09T21:02:49Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1057588">
    <title>Parallel Mathematica Environment on the RaspberryPi using OOP</title>
    <link>https://community.wolfram.com/groups/-/m/t/1057588</link>
    <description>My project, Parallel Mathematica Environment on the RaspberryPi using OOP, is a sample application of **Object Oriented Programming for the Mathematica** cluster computing, implemented with a Mac and three RaspberryPi Zero connected with a USB hub and three USB cables.&#xD;
&#xD;
Basic idea is to deploy a constructed instance image to calculating servers (RaspberryPi) and send messages to the instance. [OOP on the Mathematica is already developed and shown][1] in this community, and further detail is shown on [slidesshare][2] titled of &amp;#034;OOP for Mathematica.&amp;#034;&#xD;
![enter image description here][3]&#xD;
&#xD;
&#xD;
----------&#xD;
&#xD;
&#xD;
&#xD;
Preparing for RaspberryPi Zero is as follows using SSH connection from a Mac, &#xD;
&#xD;
 - naming each Zero as raspberypi,raspberrypi1,raspberrypi2,...&#xD;
 - set the server program &amp;#034;init&amp;#034; to each RaspberryPi, init is,&#xD;
&#xD;
        $ cat init&#xD;
        While[True,&#xD;
        Run[nc -l 8000&amp;gt;input];&#xD;
        temp=ReleaseHold[&amp;lt;&amp;lt;input];&#xD;
        temp &amp;gt;&amp;gt;output;&#xD;
        Run[nc your-mac-hostname.local 8002&amp;lt;output]&#xD;
        ]&#xD;
        &#xD;
&#xD;
where, socket numbers must be identical.&#xD;
&#xD;
 - Run Mathematica manually, and wait the booting Mathematica up.&#xD;
&#xD;
        $ wolfram &amp;lt;init&amp;amp;&#xD;
&#xD;
Checking each RaspberryPi is useful as,&#xD;
&#xD;
    $ nc -l 8002 &amp;gt;output|nc raspberrypi.local 8000 &amp;lt;&amp;lt;EOF&#xD;
    &amp;gt; 10!&#xD;
    &amp;gt; EOF&#xD;
    $ cat output&#xD;
    3628800&#xD;
&#xD;
&#xD;
----------&#xD;
&#xD;
Cluster controller program on a Mac is,&#xD;
&#xD;
 - set directory&#xD;
&#xD;
        SetDirectory[NotebookDirectory[]];&#xD;
&#xD;
 - setup socket communication process&#xD;
&#xD;
        com1=&amp;#034;nc -l 8002 &amp;gt;output1 |nc raspberrypi.local 8000 &amp;lt;input1&amp;#034;;&#xD;
        com2=&amp;#034;nc -l 9002 &amp;gt;output2 |nc raspberrypi1.local 9000 &amp;lt;input2&amp;#034;;&#xD;
        com3=&amp;#034;nc -l 9502 &amp;gt;output3 |nc raspberrypi2.local 9500 &amp;lt;input3&amp;#034;;&#xD;
&#xD;
 - set object property&#xD;
&#xD;
        obj={&#xD;
           &amp;lt;|&amp;#034;name&amp;#034;-&amp;gt;node1,&amp;#034;comm&amp;#034;-&amp;gt;com1,&amp;#034;in&amp;#034;-&amp;gt;&amp;#034;input1&amp;#034;,&amp;#034;out&amp;#034;-&amp;gt;&amp;#034;output1&amp;#034;,&amp;#034;p&amp;#034;-&amp;gt;{2000,3500}|&amp;gt;,&#xD;
           &amp;lt;|&amp;#034;name&amp;#034;-&amp;gt;node2,&amp;#034;comm&amp;#034;-&amp;gt;com2,&amp;#034;in&amp;#034;-&amp;gt;&amp;#034;input2&amp;#034;,&amp;#034;out&amp;#034;-&amp;gt;&amp;#034;output2&amp;#034;,&amp;#034;p&amp;#034;-&amp;gt;{3501,4000}|&amp;gt;,&#xD;
           &amp;lt;|&amp;#034;name&amp;#034;-&amp;gt;node3,&amp;#034;comm&amp;#034;-&amp;gt;com3,&amp;#034;in&amp;#034;-&amp;gt;&amp;#034;input3&amp;#034;,&amp;#034;out&amp;#034;-&amp;gt;&amp;#034;output3&amp;#034;,&amp;#034;p&amp;#034;-&amp;gt;{4000,4500}|&amp;gt;};&#xD;
&#xD;
 - define calculation server class, where is a sample Mersenne prime number calculation&#xD;
&#xD;
        new[nam_]:=Module[{ps,pe},&#xD;
           mersenneQ[n_]:=PrimeQ[2^n-1];&#xD;
           setv[nam[{s_,e_}]]^:={ps,pe}={s,e};&#xD;
           calc[nam]^:=Select[Range[ps,pe],mersenneQ]&#xD;
           ];&#xD;
&#xD;
 - construct instances&#xD;
&#xD;
        Map[new[#name]&amp;amp;,obj];&#xD;
&#xD;
 - deploy instances to calculation servers&#xD;
&#xD;
        Map[Save[#in,#name]&amp;amp;,obj];&#xD;
        Map[Run[#comm]&amp;amp;,obj];&#xD;
&#xD;
 - send message to each instance&#xD;
&#xD;
        Map[Put[Hold@setv[#name[#p]],#in]&amp;amp;,obj];&#xD;
        Map[Run[#comm]&amp;amp;,obj];&#xD;
&#xD;
 - start calculation&#xD;
&#xD;
        Map[Put[Hold@calc[#name],#in]&amp;amp;,obj];&#xD;
        proc=Map[StartProcess[{$SystemShell,&amp;#034;-c&amp;#034;,#comm}]&amp;amp;,obj]&#xD;
&#xD;
 - wait for the process termination (mannualy in this sample code)&#xD;
&#xD;
        Map[ProcessStatus[#]&amp;amp;,proc]&#xD;
         {Finished,Finished,Finished}&#xD;
&#xD;
 - gather the results&#xD;
&#xD;
        Map[FilePrint[#out]&amp;amp;,obj];&#xD;
         {2203, 2281, 3217}&#xD;
        {}&#xD;
        {4253, 4423}&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com/groups/-/m/t/897081?p_p_auth=o5qxZhNR&#xD;
  [2]: https://www.slideshare.net/kobayashikorio/oop-for-mathematica&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=2017-04-10.jpg&amp;amp;userId=897049</description>
    <dc:creator>Hirokazu Kobayashi</dc:creator>
    <dc:date>2017-04-10T01:15:22Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/196759">
    <title>Reading Temperature Sensors in the Wolfram Language on the RPi</title>
    <link>https://community.wolfram.com/groups/-/m/t/196759</link>
    <description>These sensors are pretty cool--they are [url=http://www.adafruit.com/products/374]cheap to buy[/url] and surprisingly sensitive to small changes in temperature. Here&amp;#039;s a first attempt I made to interact with the sensors in the Wolfram Language.&#xD;
&#xD;
For this setup I used DS18B20 temperature sensors and hooked them up to the Raspberry Pi breadboard according to Adafruit&amp;#039;s [url=http://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing/overview]setup guide[/url]. The board should look like the following diagram (make sure the sensor is hooked up to a 3.3V pin--not a 5V pin or you could fry the sensor):&#xD;
&#xD;
[center][img=width: 300px; height: 481px;]https://learn.adafruit.com/system/assets/assets/000/003/775/medium800/learn_raspberry_pi_summary.jpg[/img][/center]&#xD;
Once hooked up and connected to your Pi, run the following commands in the terminal:&#xD;
&#xD;
[code]sudo modprobe w1-gpio&#xD;
sudo modprobe w1-therm[/code]&#xD;
The temperatures are read from the sensor by &amp;#034;reading&amp;#034; the file that&amp;#039;s created in the devices directory. You can locate the file with the following commands:&#xD;
&#xD;
[code]cd /sys/bus/w1/devices&#xD;
ls[/code]&#xD;
This will show you the contents of your devices folder, where there should be a file titled 28-xxxx, where the xxxx is the serial number unique to your sensor. Once you&amp;#039;ve got that number, enter:&#xD;
&#xD;
[code]cd 28-xxxx (the xxxx should be replaced with the serial number unique to your sensor)&#xD;
cat w1_slave[/code]&#xD;
Two lines of data should return back to you--if the first line ends with &amp;#034;YES&amp;#034; then the 5-digit number at the end of the second line is the temperature, to be read as xx.xxx degrees Celsius.&#xD;
&#xD;
And now that we know that the temperature sensor is working, and we know how to find it, we can copy the file path and import it using the Wolfram Language.&#xD;
&#xD;
[mcode]Import[&amp;#034;/sys/bus/w1/devices/28-000004fe0343/w1_slave&amp;#034;][/mcode]&#xD;
Since this still returns a really long string of data that we don&amp;#039;t need, we can single out the temperature and then convert the string into a computable expression.&#xD;
&#xD;
[mcode]temp:=N[ToExpression[StringTake[Import[&amp;#034;/sys/bus/w1/devices/28-000004fe0343/w1_slave&amp;#034;],-5]]/1000][/mcode]&#xD;
So now when we read the file, we just get the temperature back!&#xD;
&#xD;
[mcode]temp&#xD;
(*22.312*)&#xD;
[/mcode]&#xD;
For kicks, I set up a scheduled task to plot the ambient temperature of my office every 60 seconds for 6 hours. Unsurprisingly, the temperature only fluctuated a few tenths of a degree...!&#xD;
&#xD;
[mcode]t={}&#xD;
RunScheduledTask[(deg=temp;AppendTo[t,deg]),{60,360}];&#xD;
Dynamic[ListLinePlot[t,Joined-&amp;gt;True,PlotRange-&amp;gt;Automatic]]&#xD;
[/mcode]&#xD;
And here&amp;#039;s what the graph looked like after a little bit of time--it truly is a sensitive device (the &amp;#034;large&amp;#034; dip down to 22.1 was me touching the sensor with my cold hands!):&#xD;
&#xD;
[center][img=width: 360px; height: 228px;]/c/portal/getImageAttachment?filename=temperaturereading3.jpg&amp;amp;userId=108162[/img][/center]Any suggestions for what to do next?</description>
    <dc:creator>Allison Taylor</dc:creator>
    <dc:date>2014-02-06T21:04:23Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/456947">
    <title>How to Make a Time Lapse Video With Your Raspberry Pi and Data Drop</title>
    <link>https://community.wolfram.com/groups/-/m/t/456947</link>
    <description>![Wolfram Pi Flowers][9]&#xD;
&#xD;
&#xD;
----------&#xD;
&#xD;
I will explain how to make the time-lapse animation you can see above.&#xD;
&#xD;
**1)** Set-up your [camera module][1]. I sticked mine on a hard drive, see the first image on [my previous Data Drop post][2].&#xD;
&#xD;
![setup][3]&#xD;
&#xD;
**2)** Take a test shot to check that the exposure is acceptable.&#xD;
&#xD;
    DeviceRead[&amp;#034;RaspiCam&amp;#034;,{320, 240}]&#xD;
&#xD;
**3)** Adjust the resulting image with [ImageAdjust][4].&#xD;
&#xD;
    ImageAdjust[DeviceRead[&amp;#034;RaspiCam&amp;#034;,{320, 240}]]&#xD;
![Test shot][5]&#xD;
&#xD;
**4)** Create a new databin, and take note of its short ID:&#xD;
&#xD;
    CloudConnect[&amp;#034;email-wolframID&amp;#034;,&amp;#034;password&amp;#034; ];&#xD;
    bin=CreateDatabin[];&#xD;
    bin[&amp;#034;ShortID&amp;#034;]&#xD;
&amp;#034;3GgU-jf4&amp;#034;&#xD;
&#xD;
**5)** Setup a [ScheduledTask][6] that adds a snapshot to your databin every 360 seconds (6minutes):&#xD;
&#xD;
    intervalometer=RunScheduledTask[DatabinAdd[Databin[&amp;#034;3GgU-jf4&amp;#034;], ImageAdjust[DeviceRead[&amp;#034;RaspiCam&amp;#034;,{320, 240}]]],360]&#xD;
&#xD;
**6)** Water your plant and wait.&#xD;
&#xD;
**7)** Check that your databin is being filled correctly [http://wolfr.am/3GgU-jf4][7]&#xD;
&#xD;
![databin][8]&#xD;
&#xD;
**8)** Compile the animated gif:&#xD;
&#xD;
    frames = Values[Databin[&amp;#034;3GgU-jf4&amp;#034;]]; &#xD;
    Export[&amp;#034;resurrected_plant.gif&amp;#034;, Join[frames, Reverse[frames]]]&#xD;
&#xD;
**9)** Enjoy!&#xD;
&#xD;
![Wolfram Pi Flowers][9]&#xD;
&#xD;
**10)** To stop your scheduled task, use the function [StopScheduledTask][10]:&#xD;
&#xD;
    StopScheduledTask[intervalometer]&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com/groups/-/m/t/157704&#xD;
  [2]: http://community.wolfram.com/groups/-/m/t/453169&#xD;
  [3]: /c/portal/getImageAttachment?filename=setupPlant.png&amp;amp;userId=56204&#xD;
  [4]: http://reference.wolfram.com/language/ref/ImageAdjust.html&#xD;
  [5]: /c/portal/getImageAttachment?filename=FlowerFrames.jpg&amp;amp;userId=56204&#xD;
  [6]: http://reference.wolfram.com/language/ref/RunScheduledTask.html&#xD;
  [7]: http://wolfr.am/3GgU-jf4&#xD;
  [8]: /c/portal/getImageAttachment?filename=databin_filled.png&amp;amp;userId=56204&#xD;
  [9]: /c/portal/getImageAttachment?filename=Wplant.gif&amp;amp;userId=56204&#xD;
  [10]: http://reference.wolfram.com/language/ref/StopScheduledTask.html</description>
    <dc:creator>Bernat Espigulé</dc:creator>
    <dc:date>2015-03-11T11:50:05Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/181641">
    <title>An experiment in Moment of Inertia with Raspberry Pi / Arduino</title>
    <link>https://community.wolfram.com/groups/-/m/t/181641</link>
    <description>Wanted to share with my kids the classical experiment on a rolling object down an incline plane using legos, arduino and Mathematica for the Raspberry Pi.

Using a window valance and some lego technic pieces we proceeded to build the inclined plane platform.

[img=width: 300px; height: 400px;]/c/portal/getImageAttachment?filename=inclinedplane1.JPG&amp;amp;userId=78214[/img]

Using legos was great to allow to attach both leds and photorresistors to the inclined plane. It also allowed us to set up build a platform from where to attach a servo motor and a protractor to measure the angle of inclination.
[img=width: 400px; height: 533px;]/c/portal/getImageAttachment?filename=inclinedplane2.JPG&amp;amp;userId=78214[/img]

We&amp;#039;ll detect when the ball reaches a certain point of the platform by the the disminution of the LED light received at the photoresistors.
[img=width: 300px; height: 400px;]/c/portal/getImageAttachment?filename=8270photo(1).JPG&amp;amp;userId=78214[/img]

The adafruit web site is a very good site to explain the details on how to connect the photoresistors and leds to the Arduino.
[url=http://learn.adafruit.com/adafruit-arduino-lesson-2-leds/leds]http://learn.adafruit.com/adafruit-arduino-lesson-2-leds/leds[/url]
[url=http://learn.adafruit.com/photocells/using-a-photocell]http://learn.adafruit.com/photocells/using-a-photocell[/url]

As the readings of the photocells require of analog inputs, we decided to use a spare arduino we had at our disposal, and to have more fun, use XBEE modules to connect the arduino to the raspberry pi.
[img=width: 300px; height: 225px;]/c/portal/getImageAttachment?filename=6471photo(2).JPG&amp;amp;userId=78214[/img]

The following is the code at the Arduino.[code]
#include &amp;lt;Servo.h&amp;gt; 
int servoPin = 9;
int LightSensor[4]={A1,A2,A3,A4};
int current[4]={0,0,0,0};
double timers[4]={0,0,0,0};
int previous[4]={0,0,0,0};

Servo servo;  
int i=0; 
double factor=0.7;
double timer = 0; 
int inByte =0;

void setup() 
{ 
  Serial.begin(19200);
  servo.attach(servoPin); 
  servo.write(0);
  delay(2000);
  for (i=0;i&amp;lt;4;i++){
    previous[i]=analogRead(LightSensor[i]);
  }
} 
void loop() 
{ 
if(Serial.available()&amp;gt;0){

  inByte=Serial.read();

 if (inByte==65) {
    servo.write(90);
    timer=millis();
    trackBall();
    for (i=0;i&amp;lt;4;i++){
      Serial.println(timers[i]);
    }
    servo.write(0);
  }
}
}

void trackBall(){
 int m =0;
  while (m&amp;lt;4){
    current[m]=analogRead(LightSensor[m]);
    if (current[m]&amp;lt;factor*previous[m]){
      timers[m]=millis()-timer;
      m++;
  }
  }
}[/code]
Mathematica code and results to follow
[mcode]serial = DeviceOpen[&amp;#034;Serial&amp;#034;, {&amp;#034;/dev/ttyUSB0&amp;#034;, &amp;#034;BaudRate&amp;#034; -&amp;gt; 19200}]
lengths = {0., 0.175, 0.43, 

   0.69} ;(*Distance between light sensors in meters*)
data = {};(*List to capture the time between sensors*)
ping := Module[{}, DeviceWriteBuffer[serial, {&amp;#034;A&amp;#034;}]; Pause[3]; 

  ToExpression[StringSplit[FromCharacterCode[DeviceReadBuffer[serial]]]]/1000]
(*Function pings sends an &amp;#034;A&amp;#034; to the arduino to release the ball and \

collect timing*)
Button[&amp;#034;Collect Data&amp;#034;, data = Append[data, ping]]
Dynamic[tdata = Transpose@data;

 dataPoints = 

  Flatten[Table[{tdata[[i, j]], lengths[[i]]}, {i, 

     Length[lengths]}, {j, Length[data]}], 1];

 lm = Fit[dataPoints, {1, x, x^2}, x];

 Plot[lm, {x, -0.3, 1.2}, 

  Epilog -&amp;gt; {Red, PointSize[Large], Point[dataPoints]}, 

  AspectRatio -&amp;gt; 1, PlotLabel -&amp;gt; lm]][/mcode]Using a hollow ball, we can work out the gravity value
[img=width: 440px; height: 500px;]/c/portal/getImageAttachment?filename=Untitled.png&amp;amp;userId=78214[/img]

Using a golf ball
[img=width: 500px; height: 482px;]/c/portal/getImageAttachment?filename=InclinedPlane.png&amp;amp;userId=78214[/img]

A couple of videos of the experiment in action
[url=https://www.youtube.com/watch?v=4eRZ48N3vM8]https://www.youtube.com/watch?v=4eRZ48N3vM8[/url]
[url=https://www.youtube.com/watch?v=eLVPpEcyw_0]https://www.youtube.com/watch?v=eLVPpEcyw_0[/url]
[url=https://www.youtube.com/watch?v=53WaEcRWY_0]https://www.youtube.com/watch?v=53WaEcRWY_0[/url]</description>
    <dc:creator>Diego Zviovich</dc:creator>
    <dc:date>2014-01-08T01:09:54Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/416746">
    <title>Mathematica RDK does not connect to the Raspberry Pi</title>
    <link>https://community.wolfram.com/groups/-/m/t/416746</link>
    <description>Hello dear Mathematica community, &amp;lt;BR&amp;gt;&#xD;
I installed Mathematica 10 on my Mac a few days ago and wanted to connect it to my Raspberry Pi, but it failed. I also have the same problem as described in some other posts here.&#xD;
&#xD;
From my Mac I can ssh to my RasPi and launch there Wolfram, and make it add 1+1. But I can&amp;#039;t figure out how to get a connection to the RasPi from Mathematica on my Mac using the RDK.&#xD;
In the setup mask of the RDK (Configure Pi Connection) I entered&#xD;
Network machine of Pi: IP address of the WLAN connection of my RasPi (as said, this one works for connecting via ssh)&#xD;
Login of Pi: pi&#xD;
(Every time I will retry this first setup step, a new kernel appears in the Evaluation-&amp;gt;Kernel Configuration Options menu, even if the IP is the same. Is this just a bug and has never been tested by Wolfram??)&#xD;
In my point of view there is not much that the user can do there wrong, it should work out of the box.&#xD;
&#xD;
When I try to connect to my RasP and evaluate the Pi Test &amp;amp; Example notebook I am asked to enter my password for my pi login, I have to wait then quite a while, then I get the following two errors:&#xD;
&#xD;
    The child process 594 reports: sh: Private: command not found&#xD;
    The kernel Raspberry Pi failed to connect to the front end. (Error = MLECONNECT). &#xD;
        You should try running the kernel connection outside the front end.&#xD;
&#xD;
When I enter &#xD;
&#xD;
    Options[FrontEnd,EvaluatorNames] &#xD;
&#xD;
on my local desktop I get &#xD;
&#xD;
    In[2]:=Options[FrontEnd, EvaluatorNames]&#xD;
    Out[2]= {EvaluatorNames -&amp;gt; {&amp;#034;Local&amp;#034; -&amp;gt; {&amp;#034;AutoStartOnLaunch&amp;#034; -&amp;gt; True}, &#xD;
      &amp;#034;Raspberry Pi&amp;#034; -&amp;gt; {&amp;#034;RemoteMachine&amp;#034; -&amp;gt; True, &amp;#034;TranslateReturns&amp;#034; -&amp;gt; True, &#xD;
      &amp;#034;AutoStartOnLaunch&amp;#034; -&amp;gt; False, &amp;#034;Executable&amp;#034; -&amp;gt; &amp;#034;/usr/bin/wolfram&amp;#034;, &#xD;
      &amp;#034;HostName&amp;#034; -&amp;gt; &amp;#034;192.168.178.22&amp;#034;, &amp;#034;RemoteLogin&amp;#034; -&amp;gt; &amp;#034;pi&amp;#034;}}}&#xD;
&#xD;
I googled, and found out that others seem to have the problem too, but couldn&amp;#039;t find anything that would solve my connection problem. &#xD;
I would be very happy if someone could help me with this issue.&#xD;
&#xD;
Kind Regards &#xD;
Björn</description>
    <dc:creator>Björn Forster</dc:creator>
    <dc:date>2015-01-05T16:54:34Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/157817">
    <title>Does Mathematica for Raspberry Pi have the full standard Mma functionality?</title>
    <link>https://community.wolfram.com/groups/-/m/t/157817</link>
    <description>I saw the annoucement of [url=http://www.wolfram.com/raspberry-pi/]Mathematica for Raspberry Pi[/url] today.

I was wondering if this version of Mathematica has all the functionality that is available in the commercial version of Mathematica.  Or is it just a subset?  (Mathematica 9 is much bigger than just [url=http://community.wolfram.com/groups/-/m/t/157340?p_p_auth=lZD0ficP]429 MB[/url].)  I&amp;#039;m interested in kernel functionality mostly.  I understand the the Predictive Interface is disabled to improve performance.

I would try it out, but I do not have a Raspberry Pi at this moment...</description>
    <dc:creator>Szabolcs Horvát</dc:creator>
    <dc:date>2013-11-21T19:44:46Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1179035">
    <title>Mike Foale&amp;#039;s Machine Learning Flight System</title>
    <link>https://community.wolfram.com/groups/-/m/t/1179035</link>
    <description>## Introduction ##&#xD;
A few weeks ago, I had the privilege of speaking with Michael Foale -- astronaut, astrophysicist, entrepreneur, and Mathematica fan -- about his recent work with the Wolfram Language on the Raspberry Pi.  As an experienced pilot, Mike thought he could use the Wolfram Language&amp;#039;s machine learning capabilities to alert pilots to abnormal or unsafe flying conditions.  Using a collection of sensors attached to a Pi, the Wolfram Language&amp;#039;s Classify function would constantly analyze things like altitude, velocity, roll, pitch, and yaw to determine whether the pilot might be about to lose control of the plane.  You can read [Mike&amp;#039;s User story here][1], his experience with [Mathematica on the Space Station Mir here][2]. and the full code for Mike&amp;#039;s Imminent Loss Of Control Identification system, or ILOCI, [is here][3].&#xD;
&#xD;
## Getting the Initial Data ##&#xD;
Mike decided that the Raspberry Pi would be a good base for this project because of how easy it is to connect various sensors to the device.  In his case, there were 3 sensors he wanted to read from:  an accelerometer, an aero sensor attached to the tail, and a flex sensor attached to the rudder.  All of these are attached via GPIO pins, which the Wolfram Language can communicate through.  In Mike&amp;#039;s case, he wrote a MathLink driver in C to do this, but since he began this project we have been pushing to make GPIO communication easier.  Now, the Wolfram Language can read from sensors with [the DeviceOpen and DeviceRead functions][4].  If Mike were to re-do this project, that would have saved him quite a bit of time and debugging!&#xD;
&#xD;
![Left: Prototype Pi and sensor setup.  Right: ILOCI attached to a small plane for a test flight.][5]&#xD;
&#xD;
Before the Classify function can tell whether current flying conditions are normal or not, it must first learn what normal is.  To do this, Mike took his Pi setup on a test-flight where he occasionally forced his plane to stall, or come close to stalling (please, do not try this for yourself!).  After landing, he manually separated the sensor readings into &amp;#034;in family&amp;#034; and &amp;#034;out of family&amp;#034; moments -- that is, normal flying conditions and moments where loss of control is imminent.&#xD;
&#xD;
## Importing the Data ##&#xD;
For Mike&amp;#039;s flights, he had the Pi save data from an initial test flight to a CSV file and had Mathematica import that file to train his Classify function on.  For example:&#xD;
&#xD;
    datafile = FileNameJoin[{&amp;#034;&amp;#034;,&amp;#034;home&amp;#034;,&amp;#034;pi&amp;#034;,&amp;#034;Documents&amp;#034;,&amp;#034;training.dat&amp;#034;}];&#xD;
    data = Import[datafile];&#xD;
&#xD;
For convenience&amp;#039;s sake, I&amp;#039;ve embedded this same data in a notebook attached to this post, so that you can test and manipulate this data on your own as well.  This data, saved under the variable &amp;#034;data&amp;#034;, was divided up by Mike into the &amp;#034;in family&amp;#034; and &amp;#034;out of family&amp;#034; periods mentioned earlier:&#xD;
&#xD;
    noloc1 = Take[data, {3500, 3800}];  (* Ground, engine off *)&#xD;
    noloc2 = Take[data, {3900, 4200}]; (* Ground, engine on *)&#xD;
    noloc3 = Take[data, {4500, 4600}]; (* Takeoff, climbing at 60 knots *)&#xD;
    noloc4 = Take[data, {4800, 4900}]; (* Climbing, 70 knots *)&#xD;
    noloc5 = Take[data, {5000, 5200}]; (* Climbing, 50 knots *)&#xD;
    noloc6 = Take[data, {6200, 6300}]; (* Gliding, 42 knots *)&#xD;
    noloc7 = Take[data, {6900, 7100}]; (* Climbing, 60 to 70 knots *)&#xD;
    noloc8 = Take[data, {9200, 9400}]; (* Landing *)&#xD;
    noloc9 = Take[data, {9300, 9400}]; (* Rolling out*)&#xD;
    loc1 = Take[data, {6450, 6458}]; (* Straight stall *)&#xD;
    loc2 = Take[data, {6480, 6484}]; (* Left stall *)&#xD;
    loc3 = Take[data, {6528, 6534}]; (* Right stall *)&#xD;
    loc4 = Take[data, {6693, 6700}]; (* Right Yaw *)&#xD;
    loc5 = Take[data, {6720, 6727}]; (* Left Yaw *)&#xD;
&#xD;
You might notice that the list above doesn&amp;#039;t cover the entire dataset.  That&amp;#039;s because some of the data is kept aside for verification, to ensure the Classify function is recognizing &amp;#034;in family&amp;#034; and &amp;#034;out of family&amp;#034; moments correctly.  This is a very important part of training any artificially intelligent program!  Below are some plots of the above datasets, just to get a visual feel for what the Pi is &amp;#034;seeing&amp;#034; during a flight.&#xD;
&#xD;
    ListLinePlot[Transpose[noloc4], &#xD;
     PlotLegends -&amp;gt; {&amp;#034;AccelerationZ&amp;#034;, &amp;#034;AccelerationY&amp;#034;, &amp;#034;AccelerationX&amp;#034;, &#xD;
       &amp;#034;RudderDeflection&amp;#034;, &amp;#034;ElevatorDeflection&amp;#034;, &amp;#034;TailYawRelative&amp;#034;, &#xD;
       &amp;#034;TailAngleAttackRelative&amp;#034;, &amp;#034;TailAirspeedRelative&amp;#034;}, Frame -&amp;gt; True]&#xD;
&#xD;
![Sensor readings while climbing at 70 knots][6]&#xD;
&#xD;
    ListLinePlot[Transpose[loc1], &#xD;
     PlotLegends -&amp;gt; {&amp;#034;AccelerationZ&amp;#034;, &amp;#034;AccelerationY&amp;#034;, &amp;#034;AccelerationX&amp;#034;, &#xD;
      &amp;#034;RudderDeflection&amp;#034;, &amp;#034;ElevatorDeflection&amp;#034;, &amp;#034;TailYawRelative&amp;#034;, &#xD;
      &amp;#034;TailAngleAttackRelative&amp;#034;, &amp;#034;TailAirspeedRelative&amp;#034;}, Frame -&amp;gt; True]&#xD;
&#xD;
![Sensor readings while stalled][7]&#xD;
&#xD;
These plots give us a good idea of what happens at some specific instances, but what does the flight as a whole look like?   Recall from above that takeoff begins around datapoint 4500, the first stall around 6450, landing around 9200, and the rollout ends around 9400.  According to Mike, the rudder movement around 11000 is simply moving the rudder to steer the aircraft back into the hangar.&#xD;
&#xD;
    ListLinePlot[Transpose[data], &#xD;
     PlotLegends -&amp;gt; {&amp;#034;AccelerationZ&amp;#034;, &amp;#034;AccelerationY&amp;#034;, &amp;#034;AccelerationX&amp;#034;, &#xD;
      &amp;#034;RudderDeflection&amp;#034;, &amp;#034;ElevatorDeflection&amp;#034;, &amp;#034;TailYawRelative&amp;#034;, &#xD;
      &amp;#034;TailAngleAttackRelative&amp;#034;, &amp;#034;TailAirspeedRelative&amp;#034;}, Frame -&amp;gt; True, &#xD;
     ImageSize -&amp;gt; Large]&#xD;
&#xD;
![Sensor readings from whole flight][8]&#xD;
&#xD;
## Training the Classifier Data ##&#xD;
After separating the data, Mike created Rules to label these moments as &amp;#034;Normal&amp;#034;, &amp;#034;Stall Response&amp;#034;, &amp;#034;Yaw Response Left&amp;#034;, and &amp;#034;Yaw Response Right&amp;#034;; respectively &amp;#034;N&amp;#034;, &amp;#034;D&amp;#034;, &amp;#034;L&amp;#034;, and &amp;#034;R&amp;#034;.  These Rules teach Classify which patterns belong to which label, so that later on Classify can tell what the appropriate label is for incoming, unlabeled data.  Note that the ConstantArray functions simply repeat the data 10 times so the &amp;#034;out of family&amp;#034; moments are not overshadowed by the &amp;#034;in family&amp;#034; ones.&#xD;
&#xD;
    normal = Join[noloc1, noloc2, noloc3, noloc4, noloc5, noloc6, noloc7, noloc8];&#xD;
    normalpairs = Rule[#1, &amp;#034;N&amp;#034;] &amp;amp; /@ normal;&#xD;
&#xD;
    down = Flatten[ConstantArray[Join[loc1, loc2, loc3], 10], 1];&#xD;
    downpairs = Rule[#1, &amp;#034;D&amp;#034;] &amp;amp; /@ down;&#xD;
&#xD;
    left = Flatten[ConstantArray[loc4, 10], 1];&#xD;
    leftpairs = Rule[#1, &amp;#034;L&amp;#034;] &amp;amp; /@ left;&#xD;
&#xD;
    right = Flatten[ConstantArray[loc5, 10], 1];&#xD;
    rightpairs = Rule[#1, &amp;#034;R&amp;#034;] &amp;amp; /@ right;&#xD;
&#xD;
Finally, with the data segmented and labeled, Mike created a ClassifierFunction able to take live data from the sensors, then quickly tell the pilot when something is wrong and how to correct it.&#xD;
&#xD;
    classify = Classify[Join[normalpairs, downpairs, leftpairs, rightpairs], Method -&amp;gt; {&amp;#034;NeuralNetwork&amp;#034;, PerformanceGoal -&amp;gt; &amp;#034;Quality&amp;#034;}]&#xD;
    ClassifierInformation[classify]&#xD;
&#xD;
![Output of the ClassifierInformation function][9]&#xD;
&#xD;
Let&amp;#039;s use this ClassifierFunction on a couple of the data points that we set aside earlier, to be sure the ClassifierFunction is correct, and to show how a ClassifierFunction is used.&#xD;
&#xD;
    nolocVerify = Take[data, {4600, 4700}];&#xD;
    locVerify = Take[data, {6587, 6595}];&#xD;
&#xD;
    classify[nolocVerify]&#xD;
&#xD;
    classify[locVerify]&#xD;
&#xD;
![Results of Mike&amp;#039;s classifier function on untrained data][10]&#xD;
&#xD;
Recall that the ClassifierFunction returns one of 4 labels for each data point:  &amp;#034;N&amp;#034; for normal, &amp;#034;L&amp;#034; for left yaw response, &amp;#034;R&amp;#034; for right yaw response, and &amp;#034;D&amp;#034; for down response.  Mike&amp;#039;s ClassifierFunction perfectly recognizes the first verification set, and comes close to being perfect on the second set.  Not bad, given how little data he had to train it with!&#xD;
&#xD;
This use-case gives a pretty good idea of how the ClassifierFunction works, but for a more in-depth example you can watch [this video from Wolfram Research][11].&#xD;
&#xD;
## Using the ClassifierFunction on Real Data ##&#xD;
At the moment I am neither a pilot nor the owner of an airplane, so performing a live test of Mike&amp;#039;s ClassifierFunction would be a bit challenging.  Fortunately, the Wolfram Language makes it easy to take Mike&amp;#039;s recorded data and re-run it as though the ClassifierFunction were receiving this data in real time.  First, we need to import the data that Mike recorded in his test flight.  We actually did this already, when we called Import on the file containing the data.  Next we&amp;#039;ll import the timing data from the test flight.  This is the absolute time in seconds and microseconds from the beginning and end of the flight, so subtracting the beginning time from the end time gives us the total time of the flight.  With the times and the data known, we can determine how often the Pi read in measurements on the test flight.  We will use that frame time to &amp;#034;replay&amp;#034; the test flight accurately.  Mike&amp;#039;s ILOCI system records timing information that we can Import from, but again I&amp;#039;ll include it here for the sake of convenience:&#xD;
&#xD;
    timing = {1466861802, 255724, 1466867826, 498879, 11660};&#xD;
    dataseconds = timing[[3]] - timing[[1]];&#xD;
    datausecs = timing[[4]] - timing[[2]];&#xD;
    frametime = (dataseconds + datausecs*1.0*^-6)/(Length[data] - 1)&#xD;
&#xD;
Now, let&amp;#039;s use that frame length to create an animated output of the ClassifierFunction.  This goes through the whole dataset and runs at the same rate as the Pi did.  If we were actually flying an airplane, this would show us what the Pi thinks about our current environment, whether our motion is &amp;#034;in-family&amp;#034; or &amp;#034;out-of-family&amp;#034;.&#xD;
&#xD;
    Animate[&#xD;
     classify[ data[[frame]] ],&#xD;
     {frame, 1, Length[data], 1},&#xD;
     AnimationRate -&amp;gt; (1/frametime),&#xD;
     FrameLabel -&amp;gt; {{None, None}, {None, &amp;#034;Full Flight Playback&amp;#034;}}&#xD;
    ]&#xD;
&#xD;
This would take a little over 90 minutes to run, and the non-normal readings go by fairly quickly, so let&amp;#039;s focus in on some of the more interesting sections.  First, let&amp;#039;s see the straight stall that was reserved for verification.  Again, the ClassifierFunction was not trained using this set -- it is brand new as far as the Classifier is concerned.&#xD;
&#xD;
    Animate[&#xD;
     classify[ data[[frame]] ],&#xD;
     {frame, 6580, 6595, 1},&#xD;
     AnimationRate -&amp;gt; (1/frametime),&#xD;
     FrameLabel -&amp;gt; {{None, None}, {None, &amp;#034;Stall Playback&amp;#034;}}&#xD;
    ]&#xD;
&#xD;
![Animate of the stall playback][12]&#xD;
&#xD;
Notice that the Classifier constantly reads the situation and updates it&amp;#039;s classification accordingly.  Next let&amp;#039;s look at one of the verification sets where everything was normal.  It should read as &amp;#034;N&amp;#034; for the entire set:&#xD;
&#xD;
    Animate[&#xD;
     classify[ data[[frame]] ],&#xD;
     {frame, 6300, 6400, 1},&#xD;
     AnimationRate -&amp;gt; (1/frametime),&#xD;
     FrameLabel -&amp;gt; {{None, None}, {None, &amp;#034;Normal Playback&amp;#034;}}&#xD;
    ]&#xD;
&#xD;
![Animate of the normal playback][13]&#xD;
&#xD;
## Conclusion ##&#xD;
If we go back and count, there is about 60 lines of code. That&amp;#039;s all that was needed to create plots, animations, and a neural net-based Classifier that might one day save lives.  This is what makes the Wolfram Language such a powerful choice for projects like this -- quick prototyping and a plethora of built-in functions allows users to create some truly unique projects, regardless of experience or expertise.  We hope that this will inspire you to start experimenting with your own ideas with the Wolfram Language!&#xD;
&#xD;
&#xD;
  [1]: http://www.wolfram.com/mathematica/customer-stories/training-a-neural-network-to-think.html&#xD;
  [2]: http://www.wolfram.com/mathematica/customer-stories/astronaut-places-a-customer-service-call-to-wolfram-research-from-space-station-mir.html&#xD;
  [3]: https://github.com/cfoale/ILOCI&#xD;
  [4]: http://reference.wolfram.com/language/guide/UsingConnectedDevices.html&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=PiAndPlaneSetup.png&amp;amp;userId=313765&#xD;
  [6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=LinePlot1.png&amp;amp;userId=313765&#xD;
  [7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=LinePlot2.png&amp;amp;userId=313765&#xD;
  [8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=LinePlot3.png&amp;amp;userId=313765&#xD;
  [9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ClassifierInfo.png&amp;amp;userId=313765&#xD;
  [10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ClassifierResults.png&amp;amp;userId=313765&#xD;
  [11]: https://youtu.be/ce6UptPYKxI?t=20m40s&#xD;
  [12]: http://community.wolfram.com//c/portal/getImageAttachment?filename=StallPlayback.gif&amp;amp;userId=313765&#xD;
  [13]: http://community.wolfram.com//c/portal/getImageAttachment?filename=NormalPlayback.gif&amp;amp;userId=313765</description>
    <dc:creator>Brett Haines</dc:creator>
    <dc:date>2017-09-07T18:16:06Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/433430">
    <title>Mathematica and Raspberry Pi 2</title>
    <link>https://community.wolfram.com/groups/-/m/t/433430</link>
    <description>Will the free version of Mathematica work on the newly announced Raspberry Pi 2?</description>
    <dc:creator>Daniel Jensen</dc:creator>
    <dc:date>2015-02-02T15:45:46Z</dc:date>
  </item>
</rdf:RDF>

