I'm Sensing Something

I’ve been interested in having small weather station for my house - so I know exactly what the weather at my house would be. At first, the big turnoff was the cost of the pre-packaged solutions, which are an uneconomical “all-or-nothing” approach. After digging into it a bit more, I found something cool - I found 1-Wire weather stations.

I’ve seen ‘1-Wire’ listed in Linux kernel configuration dialogs, but never really knew what they were for. Now I do know.

It’s apparently a new hobby project.

1-Wire is a bus protocol developed by Dallas Semiconductor (Now Maxim-IC). 1-Wire is an extremely low-power serial bus that is very well suited to sensor applications - in fact, Dallas introduced an inexpensive 1-Wire weather station to get people interested in 1-Wire. Maxim-IC no longer produces it; it’s made by AAG Electronica. 1-Wire is a serial bus whose distinguishing characteristic is that it uses one wire for data - different devices are identified by a 64-bit serial number guaranteed to be unique. Dallas serves as the clearinghouse for 1-Wire devices (and hence, device serial numbers). Many (most? all?) 1-Wire devices are extremely low-power, and can be powered “parasitically” from the 1-Wire bus.

A typical 1-Wire network actually has two wires - the “common” or ground wire, and the signal (or “1-Wire”). Devices are daisy-chained along, and both ring and start topologies are possible. In the end, it appears that as long as you have the same common wire and the same 1-Wire. 1-Wire can handle wire runs of over 1,000 feet, and can power up to a hundred devices using parasitic power - with the power being the small amount provided by a desktop RS-232 serial port.

That said, 1-Wire isn’t limited to the signal and ground. Typical 1-Wire networks use CAT-5; phone cable doesn’t perform as well. This tells me the twist in CAT5 is effective for 1-Wire. It also makes it awfully convenient to do a number of things - CAT5 is used for network wire in general, so it’s easy to find/use. Since cat-5 has four twisted pairs - or eight wires - it opens up a range of possibilities. The most common pin-out I’ve seen is used by the Serial or USB interfaces designed by Maxim-IC, and in turn, used by other interfaces - such as the LinkUSBi, which is the device I bought.

Maxim-IC’s interfaces use RJ-12 connectors, and have the following pinout:
  1. 5VDC Output
  2. Power Ground
  3. One Wire Data
  4. One Wire Ground
  5. USB Suspend Output
  6. No Connection

iButtonLink makes an enhanced adapter that has a few compelling features:
  • A 1-foot cable - less mechanical strain on the USB port
  • More power than is available via RS-232
  • Supports Fox-Bus (A new one-wire protocol that has higher speed and better noise resistance - meaning long lines & fast connection speeds).
  • Emulates the Maxim Interfaces
  • Supposedly more reliable than Maxim-IC interfaces.

The LinkUSB (and sibling LinkUSBi) has the following pinout (on RJ-45, or 8 conductor)
  1. Ground
  2. +5DC Power
  3. Power Ground
  4. 1-Wire Data
  5. One Wire Ground
  6. Auxiliary
  7. No Connection
  8. No Connection

(You’ll note pins 2-7 more or less map to that on the 6-conductor Maxim-IC interface.)

The extra power (on the +5 DC line) allows more devices to be powered simultaneously, and allows for higher sensor refresh rates.

An example of sensors produced by Maxim:
Temperature Sensors
  • Concrete Temperature Sensors
  • SHA-1 Authenticator
  • Real-Time Clocks
  • Battery Protection
  • Battery Management
  • Battery Monitors
  • Battery “fuel gauges”
  • Memory (EEPROM, SRAM, Add-only/logging)
  • ESD Protection
  • Serial Numbers
  • Thermostats
  • Humidity Gauges
  • Barometers
  • Switches

In addition to the components, Maxim makes a one-wire product line called the ‘iButton.’ An iButton is a small metal container that contains a sensor package (and sometimes battery). They are ruggedized devices, and have some neat applications - such as an iButton that contains a clock, a humidity sensor, and a battery. You can set the iButton to perform a “mission” - and sample data according to parameters you define. So you can set up an iButton to log data, put it in a place, leave it for days/weeks/months, retrieve it, and read the data back. Combining things like temperature & humidity are a bit of a neat idea - I can see it being particularly useful for shipping, or my big hobby: R/C Helicopters.

I can easily see a use case for my helicopters: Attach a Thermocron (clock+temp logger) iButton to my helicopter’s engine, and measure the engine’s temperature through the flight. When I’m done, I plug the Thermocron into my reader, and bam, telemetry on my computer. Thermocrons are pretty tough, so it’s hard to imagine damaging one in a crash. It’s far easier to imagine physically losing the Thermocron. While cool, I doubt I’ll have a need for a Hygrocron (Temperature+Humidity+clock logger). Of course, I might get a Hygrocron just to take with me on vacations & camping…

After reading up, I’ve decided what I want to do: Instrument up my home Big time; maximize energy efficiency, track energy usage.

My idea:
  • Temperature sensors in each ‘section’ of my attic
  • Temperature for my HVAC room (ie. where the combustion gas has to be)
  • Temperature for my living room
  • Temperature for my basement
  • Temperature of the garage
  • Fish Tank Temperature
  • Water Heater temp
  • HVAC Inlet Temperature
  • HVAC Exhaust temperature (I figure where it leaves the HVAC unit and into the ductwork)
  • HVAC Heat Exchanger
  • HVAC Evaporator temp (outside)
  • HVAC combustion exhaust Temperature.
  • Water inlet temperature (Track seasonal changes; see how cold it is when the utility gives it to me)
  • Dryer Exhaust (So I know how often & how long the dryer is used)
  • Temperature outside (of course - probably in a couple locations)
  • Humidity (Outside, and in my living room)
  • Barometric pressure (generally the same inside or out - I’m thinking the garage or maybe attic.
  • Wind Speed
  • Wind Direction
  • Precipitation
  • UV Strength (ie. UV Index, Sunburn index)
  • Lightning Strike Detector
  • Solar Energy Strength
  • Soil Moisture (so I water only as much as I need to in this desert)
And others, I’m sure...

So, I chose a 1-Wire interface (the aforementioned LinkUSBi), and got a few sensors to play with:
  • An iButtonLink T-Sense temp sensor (ie. a pre-built, ready to go temperature sensor)
  • A couple of Maxim-IC temp sensors - The DS18B20, to be exact.
  • An iButton Thermocron - an iButton device that measures temperature vs time. For my helicopters, among other things.

I wanted to read the data on my iButton device; so I downloaded Maxim’s OneWireViewer software to do this.

  • Problem #1: All of their instructions are for Windows based machines. This is mostly a gripe, since I’m more computer literate than most.
  • Useful thing #1: Their software is in Java, so it will run on Linux or OS X.
  • Problem #2: Java doesn’t directly support serial devices; there’s a java.comm library, but it’s not readily available (Oracle doesn’t offer it as a download). It’s also officially “deprecated” functionality.
  • Useful thing #2: RxTx is a cross-platform Java+JNI library that effectively replaces java.comm. This lets me access the serial port using Java.
  • Problem #3: RxTx, while actively developed, hasn’t been had a “stable” release for about four years now. The stable release fails to work quite miserably for OS X Lion; I haven’t tried it on Linux yet, but I figure it’ll probably “just work.”
  • Useful thing #3: RxTx is still developed. The development tree is available via CVS.
  • Problem #4: Initially, it was a PITA to figure out how to compile the software
  • Useful Thing #4 The latest tree has an Xcode project that works. I was able to compile the software I needed.

So, after building the development version using Xcode, I finally had the software I needed: A JNI library to interface Java to the serial port, the RXTX library, and the two jar files from Maxim-IC. After a little script-fu, I finally was able to read my iButton device! Huzzah! The OneWireViewer is also able to read normal 1-Wire devices, so I was able to test out my other hardware as well.

Finally, Maxim provides a few SDK’s for 1-Wire devices:

Additionally, there’s the big book of recipes, which I haven’t read yet: Weather Toys, by Tim Bitson, and its accompanying website: www.weathertoys.net. I’m looking forward to reading this one.

Finally a few link resources of things I’ve stumbled upon:
  • Hobby-Boards This is a web store that sells 1-wire sensors, interfaces, hubs, and more. They also host a lot of useful information about setting up a 1-wire network, as well as a few noteworthy kits: An entry-level weather station, a “pro” weather station, a rain gauge, Temperature, Pressure, Humidity, and solar intensity sensors (Many are combo sensors), a UV Index sensor, a soil moisture sensor, and a lightning sensor.
  • iButtonLink A vendor that makes the “Link” series of 1-wire adapters, including the LinkUSBi that I purchased. The “Link” adapters are also capable of using a newer complementary 1-wire protocol called Fox-Bus. iButtonLink also sells NIST-traceable sensors, iButtons (and NIST traceable iButtons), cables, interfaces, Temperature, Humidity, Light Level, Electrical Current, Voltage, Flow sensors. I’m pretty impressed with their devices - the T-Sense line is high performance and fairly weatherproof set of sensors, and reasonably priced. They even have what appear to be waterproof sensors.
  • One Wire Weather: An open-source project providing services for 1-Wire weather stations, including uploading data to WeatherUnderground. OWW is written mostly in C, and focuses on weather reporting.
  • Thermd: Another open-source project for 1-Wire devices, and can also upload data to WeatherUnderground. Thermd bills itself as temperature, power, and environmental monitoring, and is written in Perl.