Tuesday, February 23, 2010

LEGO Temperature Sensor - Splicing it into Retail

For various reasons, LEGO only sells the temperature sensor through it's educational channel. That's fine... but how can the average user, with only the Retail software, use them? That's been a problem I've had a lot of folks email about, asking how I use it under NXT-G and if I can "share my secret".

Well, how about Steve Hassenplug just hosts my secrets? Look about half-way down this page, at the "Temperature Block" and the "I2C blocks" below it

Inside the LEGO temperature sensor is a Texas Instruments chip (a TMP275 chip to be exact), which can be controlled like any other I2C device. That's handy, and there are 3rd party add-on blocks that will let you let you read a byte via I2C, or write a byte via I2C, or even read a series of bytes (multi-byte read) via I2C. Steve has also been kind enough to host copies of these right under the My Block I drew up to read the sensor. Note that you need to configure the sensor before reading it - I normally configure it for highest resolution. To see how this block works (and how to configure it), take a look at the program fragments above, from my Brickshelf gallery.

Please let me know how well this works, and if there are any problems I need to address. You will need to have both of the I2C blocks installed into NXT-G, as well as have the My Block in your program, and configure the sensor correctly with a single I2C write... but it should make it a little easier for Retail set users to enjoy this fun sensor.

--
Brian Davis

No comments:

Post a Comment