Thursday, September 8, 2011

Vernier Sensors and Arduino (or Teensy) for Data Logging

I've been thinking for a while about inexpensive data logging with Vernier educational sensors and a microcontroller development board. I played around with the TI MSP430 LaunchPad for a while, since it is only $4.30, but it's not quite as beginner-friendly as the Arduino. I eventually settled on the Arduino-compatible Teensy for its low price ($16) and small size.

Vernier does a good job of documenting sensor pinouts and calibration values in each sensor's manual, so I knew that this was a fairly easy project.

Unfortunately the sensors use a BT631A connector, which is difficult to find outside of the UK. I ordered this BT to RJ11 adaptor from DealExtreme, but unfortunately it's only 6P4C and we need 6P6C (6 conductors). All six pins are used by the sensor, but we really only need pins 2, 5, and 6. I'll try ordering something from UXCell or Vernier, but for now I've just used some breadboarding wires stuck into the back of the connector.

The required connections from the sensor are
pin 2 to ground (GND)
pin 5 to +5V (VCC)
pin 6 to an analog in (A0)
(I haven't gotten around to trying out the auto-ID function, but that's not an extremely useful function for my purposes anyway.)

Since this my first real microcontroller project, I followed the tutorials on the Teensy site regarding connecting something to the analog input. I modified some example code by Tom Igoe and came up with:

 Analog input, serial output
 Reads an analog input pin and prints the results to the serial monitor.
 The circuit:
 Vernier probe pin 2: Ground (GND)
 Vernier probe pin 5: +5 V (VCC)
 Vernier probe pin 6: Sensor output (A0)

 created 2011-09-08 by David Hay (misterhay)
 Some code borrowed from example by Tom Igoe

 This code is Creative Commons Attribution (

// Constants, used to give names to the pins used
const int analogInPin = A0;  // Analog input pin that the probe is attached to
const int ledPin = 11; // The Teensy on-board LED is on pin 11

// Variables
int sensorValue = 0;        // value read from the probe

// The setup, which runs once when the sketch starts
void setup()
  Serial.begin(38400);     // initialize serial communications at 38400 bps,
                           // not that this matters since it runs at USB speed
  pinMode(ledPin, OUTPUT);  // set the digital pin as an output

// The actual loop that does the sampling and output to the serial monitor
// This will continue to run as long as the Teensy is plugged in
// Use the Arduino Serial Monitor or some fancy GUI to see the output
void loop()
  // read the analog in value:
  sensorValue = analogRead(analogInPin);           
  // print the results to the serial monitor:

  // wait 10 milliseconds for the analog-to-digital converter to settle

Watch the output in a serial monitor program on your computer, and paste it into a spreadsheet program for graphing. Eventually I'll build a GUI for adjusting sample rates and number of sensors and maybe some live graphing, add some calibration, and put it in a better enclosure.


MrMoScienceLand said...

Thanks for this post. I was just given an Arduino Uno and I have a ton of old DIN Vernier probes to work with. We are wanting to create a passive solar greenhouse that is used for research projects and incorporates digital data collection that can be automatically published to the web for use by anyone who wishes to use it. Your advice on how to proceed or other resources to explore would be most appreciated!

Mr. Hay said...

@MrMoScienceLand You're in luck that the older DIN connectors are much easier to obtain than BT connectors. You can search for female midi connectors, or just get something like this at SparkFun

The pinouts for the DIN plugs are on that same Vernier sensor page.

As to automatically getting the data onto the web from the computer, maybe check out

Let me know if you're intending to blog about your progress, I'd be interested to see how it works out.

MrMoScienceLand said...

Would I need the DIN adapter or could I jus remove the 3 wires and wire the directly to the arduino? Thanks for the quick reply and the extra resources!

keen101 said...

would it be possible to do the reverse? I have a ti-84 calculator that i would love to be able to make my own DIY sensors and have them be compatible with the vernier software and auto graph the data.

Would you know how to do that?

keen101 [at] gmail [dot] com

Mr. Hay said...

You might be able to use, or perhaps even emulate, the Vernier EasyLink interface. I'm not sure about the protocols that it uses for communicating with the calculator, but you should be able to use it with 5 V sensors that are similar to the compatible Vernier ones.

I haven't spent much time with the TI-84, or with calculator programming in general, but I'd suggest checking out, which may be the start of what you need.

Good luck, and let us know how it goes.