Wolfram Language

Channel Framework

Collect Data from Arduino Yun

Create a channel for publishing data from an Arduino Yun device and start listening on the channel.

In[1]:=
Click for copyable input
channel = CreateChannel["yun", Permissions -> "Public"]
Out[1]=
In[2]:=
Click for copyable input
listener = ChannelListen[channel]
Out[2]=

Open an Arduino Yun device.

In[3]:=
Click for copyable input
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]:=
Click for copyable input
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]:=
Click for copyable input
DeviceClose[yun]

Visualize the data as it comes in.

In[6]:=
Click for copyable input
Dynamic[ListLinePlot[ ToExpression /@ Reverse[Take[Reverse[#["Values"]], UpTo[100]]], PlotRange -> {0, 5}] & /@ listener["TimeSeries"]]
Out[6]=

Related Examples

de es fr ja ko pt-br zh