# Analyzing Arduino Sensor Data in a STEM high school classroom

Posted 1 year ago
937 Views
|
0 Replies
|
3 Total Likes
|

My name is Matthew Green and I team-teach at Riverpoint Academy (RA) with Rick Biggerstaff. RA is a public STEM high school for 9th - 12th graders. This year, Rick and I are creating, and teaching, a new course that we call Computational Laboratory, or CompLab for short.

We describe our course like this:

“In CompLab, students will develop the skills necessary to make and defend precise arguments through the use of data. Our focus will be on observable and quantifiable relationships involving movement or change. Through personal and collaborative projects, students will use Computational Thinking and technology to make informed and justifiable decisions.”

## Putting Mathematica, Arduino, and Processing together

data = Import[
"/Users/matt/CircuitPlayground-master/SaveSensorData/values.csv"]
data = Select[data, Length[#] == 8 &];
data = Dataset[Map[AssociationThread[First[data], #] &, Rest[data]]]
ListLinePlot[Normal[data[All, "x"]]]
ListLinePlot[Normal[data[All, "y"]]]
ListLinePlot[Normal[data[All, "z"]]]


It’s day fourteen of CompLab and we’ve just released an activity to our students that brings Arduino data into Mathematica so they can begin to analyze it in their first attempt to make and defend a claim with data. Up until now students have spent no less than one hour in Mathematica, just poking around. This will be their first attempt at connecting our CompLab tech stack (Mathematica, Arduino and Processing) to their study of rhetoric. As you can see from this first activity, our expectations of claim and justification are small, but that’s intentional. At Riverpoint Academy we’re all about giving students the chance to incubate skills needed as they move forward. We noticed last semester that many students struggled with even making a claim, so we thought it made sense to isolate that skill from the rest of the details of rhetoric at this time. This was especially important because managing the tech stack is a big challenge for many of our students this early in the course.

Mathematica is perfectly capable of communicating directly with microcontrollers like Arduino, so why not do that? Well, we will, just not yet. (Skip to the final section to read more) Our reasons for not starting there are pedagogical. Many of our students are apprehensive about reading and writing code, and we have found that Processing is a fantastic way to get started. Processing then gives purpose to Arduino and together they create the need for deeper analysis of Arduino data. We’ve seen that once students see what’s possible with the Wolfram Language, they are hooked.

## How we got started

Many of our students are new to programming and we need to bring them up to speed quickly so we can engage in some deep Computational Rhetoric work.

In our first activity, we asked students to create a Piet Mondrian inspired piece using Processing (Java). We then introduced them to Rhetoric and then some Logical Fallacies. Next we asked them to create a Drawing Program in Processing (Chapter 8), which created the opportunity to introduce a special little Arduino, the Adafruit Circuit Playground. We are using the Circuit Playground and its many sensors so that students have the opportunity to use data they have collected from their environment to control output on screen. If our only goal were Physical Computing, we would be quite content with what’s possible when you put Arduino and Processing together… but we're interested in exploring data more deeply

## How Mathematica will take center stage

(* connect to the device as serial *)
playground =
DeviceOpen["Serial", {"/dev/cu.usbmodem14511", "BaudRate" -> 9600}]

(* make list to hold data *)
Dynamic[dataList];
StringSplit[
FromCharacterCode[
{"\t", "\r"}]

(* getter functions *)
GetXVals[list_] := ToExpression /@ Downsample[Flatten[dataList], 8]
GetYVals[list_] :=
ToExpression /@ Downsample[Drop[Flatten[dataList], 1], 8]
GetZVals[list_] :=
ToExpression /@ Downsample[Drop[Flatten[dataList], 2], 8]
GetLeftButton[list_] :=
ToExpression /@ Downsample[Drop[Flatten[dataList], 3], 8]
GetRightButton[list_] :=
ToExpression /@ Downsample[Drop[Flatten[dataList], 4], 8]
GetLightSensor[list_] :=
ToExpression /@ Downsample[Drop[Flatten[dataList], 5], 8]
GetSoundSensor[list_] :=
ToExpression /@ Downsample[Drop[Flatten[dataList], 6], 8]
GetTempSensor[list_] :=
ToExpression /@ Downsample[Drop[Flatten[dataList], 7], 8]


We’ve done a bit of work to create our own Wolfram Language interface to the Circuit Playground. As long as this sketch is running on the attached Circuit Playground, you can collect live data from it, via the WL Serial interface. We chose to make our own serial connection to take advantage of the awesome Circuit Playground sensor functions defined here. We traded low-level control for easy access to lots of sensor data.

Our CompLab work culminates in a Computational Essay, inspired by Stephen’s post, but more directed at the traditional Argumentative Claim standards for our lower and upper students. We’ve co-opted the name Computational Rhetoric, by which we intend “Rhetoric” to be “X” in Stephen’s belief that there should be a “Computational X.” That is, we are exploring Rhetoric in a computational way, using uniquely powerful tools like Mathematica to get and make sense of data to write, present and speak convincingly. We’ve told our students that we will define Computational Rhetoric thusly, “using data, and data visualizations to write, speak, and present in a convincing way.”

Though we plan to significantly edit this activity, we share it as an example of where we are headed with our CompLab students. The Wolfram Language makes it possible for our students to pull together subjects that are often kept separate in the traditional high school. CompLab students study Physics, Rhetoric and Computer Science in a coherent and interconnected way because it gives purpose and context for each skill and concept.

## If you’ve made it this far…

Thanks for reading! I’d love to hear your thoughts and ideas for improvement.