In the previous iteration of my website, I had some details about installing the Vernier Go software development kit on the Raspberry Pi and then using Mathematica to visualize the results. Here is an updated set of instructions which is a little more straightforward.

## Step 1 – get the software

I have tested this setup with version 2.53, which you can obtain by using `wget`

:

cd ~ wget http://www2.vernier.com/download/GoIO-2.53.0.tar.gz tar zxvf GoIO-2.53.0.tar.gz

## Step 2 – Install dependencies and build

Make sure you have the correct dependencies.

sudo aptitude install build-essential automake1.9 dpkg-dev libtool libusb-1.0-0-dev sudo apt-get install git uuid-dev cd GoIO-2.53.0 ./build.sh

The `apt-get`

command isn’t necessary for this step; however, if you want to use my *Mathematica* code on Github, you’ll need `git`

, and any software work you do with *Mathematica* will require `uuid-dev`

. The build step takes about 5-10 minutes.

## Step 3 – Check

To make sure the system is working properly, you can build and run an example program called GoIO_DeviceCheck. Before executing the last command, make sure that the GoIO! interface is connected to a USB port on your RPi and that you have a sensor connected.

cd ~/GoIO-2.53.0/GoIO_DeviceCheck ./build.sh ./GoIO_DeviceCheck

You should now get a single reading from your sensor.

## Step 4 – Using sensors with Mathematica

This step is optional. You have all the tools in place to operate the Vernier sensors with your programming language of choice (well, choosing among C++ and C++ interfaces with your language of choice). If you’d like to use the sensors from within Mathematica, here is one implementation. Please note, that improvements to the code must be made. In particular, there seems to be a communication problem where the sensor is not read, but an unreasonably large value is returned. I propose a workaround, but this issue needs to be resolved. The following commands will pull my sample Mathematica code from Github and compile the library.

cd ~ git clone https://github.com/bobthechemist/VernierPi cd VernierPi mcc -o vernier vernier.c vernier.tm -I/usr/include/GoIO -lGoIO

There is no attempt to put this file in a local directory, so if you wish to use it, you must either run Mathematica from within the same directory (in this case, ~/VernierPi) or use a full path name in the Mathematica code below. Once you start Mathematica (or if you are using the command line interface `wolfram`

) you can run the following code:

link = Install["/home/pi/VernierPi/vernier"] getDeviceInfo[] getSimpleMeasurement[]

It’s possible that the first time you run `getDeviceInfo[]`

some garbage will be returned. As I mentioned previously, there is something not quite right with communication between the library and Mathematica, and I haven’t yet found the solution. The code below creates a simple display.

link = Install["/home/pi/VernierPi/vernier"]; (* set up some limits. Low and high for visualization and crazy to indicate that the reading is probably an error *) low = 200; high = 5000; crazy = 10^6; (*initialize the output variable*) out = getSimpleMeasurement[]; (*The current version of the vernier link doesn't always read the sensor properly;the function below ignores bad readings*) f := Module[{t}, t = getSimpleMeasurement[]; If[t > crazy, out, t]]; task = CreateScheduledTask[out = f, 2]; StartScheduledTask@task; AngularGauge[Dynamic@out, {low, high}]

Here’s what my notebook looks like. I have a sensor attached and I breathed on it.

In another post, I’ll show how we can collect data and do some fun stuff with it.

Hello,

This is Dave Vernier of Vernier Software & Technology. I would love to talk with you about your use of Mathematica and our Go!Link.

We found out about your Mathematica code right after it was released and it prompted me to contact Mathematica, get a subscription, and start using it. I got to know Arnoud (I bet you know him). Anyway, your code got me started with Mathematica and it worked well. I thank you for that. I did all my Mathematica stuff on Windows and Mac, and never really tried the Raspberry Pi. I think I assumed it would just be too slow, and we thought of Go!Link as sort of old technology.

At the time, we were just starting to develop our line of Bluetooth/USB, Go!Direct sensors and I was very excited about the idea of using them with Mathematica. I sent Arnoud a bunch of sensors and he had somebody work with them using Mathematica, but we never really got anything working.

Over the years we have heard of people using your code and our sensors and Mathematica. Last month I was contacted by a teacher in Cambodia, who is very excited about using the Raspberry Pi and Go!LInk and our sensors in science classes there. She is even doing a talk at a major science teacher conference there (she sent me her presentation). She makes the point that schools in Cambodia have almost no money and no computers, and the Raspberrry Pi is just about the only option. She has some of our old, wired sensors and some Go!links and she has them up and running. They are included in the talk.

This has inspired me to explore this more. It really is a great low-cost option, with the Mathematica include with the Raspberry Pi. Since many U.S. teachers are now switching to our new Go Direct sensors, There will be quite few of those sensors that work with Go!Link available used or as give aways.

Anyway, I am very impressed with what you have done and I have some questions:

– Is there a way we could make software setup easier. For example, could we make up Raspberry Pi operating systems on an SD card with the stuff installed or with a batch file that installed them? Right now, I think it is too much for the average teacher.

– is there any chance I could hire you to try to make our Go!Direct sensors work with Mathematica and the Raspberry Pi?

Dave Vernier