Collect Data from Arduino Yun
Create a channel for publishing data from an Arduino Yun device and start listening on the channel.
In[1]:=
channel = CreateChannel["yun", Permissions -> "Public"]
Out[1]=
In[2]:=
listener = ChannelListen[channel]
Out[2]=
Open an Arduino Yun device.
In[3]:=
yun = DeviceOpen[
"Arduino", {"/dev/tty.usbmodem1421", "BoardType" -> "Yun"}]
Out[3]=
Configure the device to send values of the analog pins A0 through A2 to the channel every 0.5 second.
In[4]:=
DeviceConfigure[yun,
"Upload" -> {"BootFunction" -> <|"Code" -> "ChannelSend",
"Pins" -> {"A0", "A1", "A2"}, "Scheduling" -> 0.5,
"Channel" -> channel|>}]
Out[4]=
Close the device, unplug it, attach an accelerometer to the analog pins, and put the Yun out in the field.
In[5]:=
DeviceClose[yun]
Visualize the data as it comes in.
In[6]:=
Dynamic[ListLinePlot[
ToExpression /@ Reverse[Take[Reverse[#["Values"]], UpTo[100]]],
PlotRange -> {0, 5}] & /@ listener["TimeSeries"]]
Out[6]=