Message Boards Message Boards

6
|
23419 Views
|
6 Replies
|
9 Total Likes
View groups...
Share
Share this post:

Adding Vernier (analog) sensors to the Raspberry Pi

***Note: I have updated this thread with newer installation instructions. I've kept the original post untouched just for reference.***

My latest experiement has been to read from the vast array of analog sensors that are made available from Vernier.  The company distributes an SDK that makes a lot of the device interaction straightforward, although compiling the SDK on a Raspberry Pi required a little bit of work which I described in a bit more detail here [dead link removed].  As with some of the other projects I've played around with, I find it easiest to interact with hardware devices through MathLink and a bit of c code, so I made a few functions that grab device information and make a measurement (in this case, an average of up to 25 measurements within 1 second).  

What makes this approach interesting, in my opinion, is that it utilizes what Vernier calls the Go!Link interface with provides a USB connection from the Vernier probe to the (in this case) Raspberry Pi.  The Go!Link allows one to make hot-swapable devices; with a Dynamic call to the MathLink functions, I get.


Here is a simple interface where I'm swapping out a thermometer, barometer and a CO2 sensor.  The SDK knows the identity of the sensor, the units it uses and has calibration information already set up so getting the sensors up and running in Mathematica was easy (the tricky part was the MathLink code).

Naturally, we can make dynamic plots of sensor readings as well:



Here I'm using Clock to poll a light sensor every 2 seconds and then shining a light source on the sensor.  The 0-value readings are not conditions of no light, but rather times when the sensor reading failed.  At the moment, I'm not sure if that's a Mathematica or c problem.
POSTED BY: BoB LeSuer
6 Replies

Recently, I was contacted by a student who expressed interest in this project. I've updated the installation process to make it easier and created a new post on my website highlighting the process. Since I've run in to website stability problems in the past, here's a rehash of the steps.

Step 1 – get the software

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

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

Step 3 – Check

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

Step 4a – Build Library

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

Step 4b – Check that library works

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

Step 4c – Create 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 the notebook looks like with a carbon dioxide sensor attached. I'm exhaling on the sensor.

enter image description here

POSTED BY: BoB LeSuer
Posted 10 years ago
Hello,
I have succeded in the making of "vernier" on Raspberry Pi after buiding the Vernier SDK, in which I did not add the line in a configure.in and Makefile.am, respectively.
The procedure is the same as my previous post. Thank you.
 link=Install["/home/pi/vernier/vernier"]
 LinkObject["'/home/pi/vernier/vernier'", 847, 5]
 
 Column[{
   Row@StringSplit[getDeviceInfo[],","][[{4,5}]],
   getSimpleMesurement[]
 }]
 Stainless Temp(C)
 11.221
POSTED BY: Yoshihiro Sato
Posted 10 years ago
Hello,
Thank you.I have succeeded in measuring the cooling of hot water using Vernier and LM73 sensor, which I described in a bit more detail here.
http://mmays.hatenablog.com/entry/2014/03/07/155351
Yoshihiro Sato
POSTED BY: Yoshihiro Sato
Posted 11 years ago
To build and install the GoIO library on Ubuntu12.04, my procedure is the following.
Compiling results in error. Would you give me a suggestion to resolve this problem ?
Yoshihiro Sato
 $ cat /etc/lsb-release
 DISTRIB_ID=Ubuntu
 DISTRIB_RELEASE=12.04
 DISTRIB_CODENAME=precise
 DISTRIB_DESCRIPTION="Ubuntu 12.04.4 LTS"
 $ arch
 x86_64
 --------
 ~/Vernier$ ls
GoIO  GoIO-2.53.0.tar.gz  vernier.c  vernier.tm
~/Vernier$ cd GoIO
$ sudo apt-get install aptitude
$ sudo aptitude install build-essential
$ sudo aptitude install automake1.9
$ sudo aptitude install dpkg-dev
$ sudo aptitude install libtool
$ sudo aptitude install libusb-1.0-0-dev
-----
$ sudo ./build.sh
$ cd ./GoIO_DeviceCheck
$ sudo ./build.sh
$ ./GoIO_DeviceCheck
GoIO_DeviceCheck version 1.1
This app is linked to GoIO lib version 2.53 .
active kernel driver on device 2:3
Flushed 48 bytes when device (0x6ec9f0) opened.
Successfully opened Go! Link device 2:3 .
Sensor id = 10(Stainless Temp)
25 measurements received after about 1 second.
Average measurement =   19.019 (C) .
-----
This shows the successful instal of GoIO libraey.
==========================================================
$ sudo find / -name libGoIO.so -print
/usr/lib/libGoIO.so
$ ls /usr/include/GoIO
GMiniGCDDSMem.h  GSkipCommExt.h  GoIO_DLL_interface.h GSensorDDSMem.h  GVernierUSB.h
-----
$ cd ..
$ ls
GoIO  GoIO-2.53.0.tar.gz  vernier.c  vernier.tm
$ mcc -o vernier vernier.c vernier.tm -I/usr/include/GoIO -lGoIO
vernier.o: In function `getlibraryversion':
vernier.c:(.text+0x3f): undefined reference to `GoIO_Init'
vernier.c:(.text+0x52): undefined reference to `GoIO_GetDLLVersion'
vernier.c:(.text+0x80): undefined reference to `GoIO_Uninit'
vernier.o: In function `getdeviceinfo':
vernier.c:(.text+0xd0): undefined reference to `GoIO_Init'
  .........
  .........
collect2: ld stops with status 1
POSTED BY: Yoshihiro Sato
Yoshihiro, The `-I/user/include/GoIO` portion of the mcc command will make sure that the GoIO directory is in the include path and the -lGoIO ensures that the GoIO library is linked, so the command is correct as written.  If you are having problems, then I would look at the installation of the GoIO library.  I was able to install GoIO-2.53.0 on Ubuntu 12.04 without any problems by following the instructions provided by Vernier.  If you are still struggling, provide some more details about the error and hopefully we can work something out.
POSTED BY: BoB LeSuer
Posted 11 years ago
I am interested in your "Vernier sensors on the Raspberry Pi(with a little mix of Mathematica)".
My first plan is compiling on Ubuntu 12.04, and then it is on Raspberry Pi.

This is the first plan on Ubuntu 12.04.
I have downloaded GoIO, vernier.c, and vernier.tm.
I can use mcc compiler on my pc.
$ mcc
Wolfram Mathematica MathLink Template Compiler
Usage: Use --help argument for more informations.
I want to compile vernier.c using your description.
mcc -o vernier vernier.c vernier.tm -I/usr/include/GoIO -lGoIO
However, I don't understand this note.
Note it is important to make sure that the GoIO library is linked and that the /usr/include/GoIO directory is include in the search path.
My working directory is the following.
$ls
GoIO-2.53.0  GoIO-2.53.0.tar.gz  vernier.c  vernier.tm
Would you please give me an explanation using Linux commands ?
Yoshihiro Sato
POSTED BY: Yoshihiro Sato
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract