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:

Step 2 – Install dependencies and build

Make sure you have the correct dependencies.

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.

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.

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:

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.

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

co2display

 

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

Published by

BoB

The guy who runs this show.

Leave a Reply

Your email address will not be published. Required fields are marked *