Using Vernier LabQuest sensors on the Raspberry Pi

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 ~
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

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

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
cd VernierPi
mcc -o vernier vernier.c -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"]

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];
AngularGauge[Dynamic@out, {low, high}]

Here’s what my notebook looks like.  I have a CO_2 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.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.