All of our new bins have at least one StorMax temperature cable in them. Normally we read them using by going to each bin and plugging in a handheld reader which, after a few seconds, shows us the temperature at each of the sensors in the cable. Typically there are between 5 and 8 of them. The cables plug into the reader with only two wires. That got me wondering how they work. The old cables have a DB-25 plug that we plugged into. They likely have one wire for each sensor, and they probably are analog sensors. Likely diodes. So I can understand how to read those. Just apply voltage across each wire to ground and measure the voltage drop. But these new cables are different. Then I started getting into microelectronics with Arduino. And that's where I learned what these cables actually are. It's no mystery, and it's easy to interface with.
Dallas Semiconductor 1wire
Dallas Semiconductor developed a very ingenious system for linking multiple, digital devices together in a bus that consists of only one wire, used for writing, reading, and powering the devices. Well, and a ground. So two wires. But really all the magic happens over one wire, so they called it the 1wire system. Although it is proprietary, it's well-documented, well understood, and 1-wire compatible devices (from Dallas Semiconductor, or maybe others under license) are cheap and plentiful.
Turns out, this is exactly what the temperature cables are. And for the temperature-only cables the sensor is typically from the DS18x20 family of digital sensors. So reading the temperatures is quite easy using a well-known digital protocol for enumerating the devices on the bus, and querying their temperatures. Since each little IC (the size of a transister package) is a full little computer, it does full calibrated temperature readout. It just tells you what the temperature is with now fuss. Pretty slick.
Also 1wire can, though it's not a fast bus, stretch out for hundreds of feet. So you can, after learning which sensors are on what cable, hook all the cables together into one big bus and read them from one point. MaxStor's reader can read sets of bins, and even do tracking of temperatures over time, all on the device. But wouldn't it be nice to get e-mail updates and SMS alerts from the bins? I thought so too. And so did a number of people, including MaxStor, and other competitors.
Reading the Cables
So to interface with these cables, it's a simple matter, if you have one additional piece of information. Each DS18x20 sensor has 2 bytes of scratch memory that can be read or written to. MaxStor uses these bytes to store a bin number (I think), and also a sensor number. These bytes happen to coincide with what the data sheet calls "temphigh" and "templow." So to determine where the sensor is in the cable that you are reading, check the "templow" field.
So to interface with the cable, either use a digital circuit to generate and read the pulses on the data wire, say using Arduino with a handy OneWire library, or use an off-the-shelf DS4940R USB to 1wire adapter (sometimes called an "iButton reader". With the USB adapter, one can plug into Linux and use either the built-in kernel 1wire driver, or use a userspace driver called OWFS. OWFS can actually layer on top of the kernel driver, but I haven't played with that yet.
With OWFS, you can do a quick temperature readout with the following code, modified from from the OWFS source code. Note that this code will not print the temperatures out in order, but it will output the sensor position. This is just to illustrate the concept:
#! /usr/bin/env python
"""
::BOH
$Id: temperature.py,v 1.3 2013/03/24 01:23:30 alfille Exp $
Copyright (c) 2004 Peter Kropf. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
::EOH
Find all temperature sensors (DS18S20) and print out their current
temperature reading.
"""
import sys
import ow
def temperature( ):
root = ow.Sensor( '/' )
for sensor in root.find( family = '28' ):
print sensor._path, sensor.templow, sensor.temperature
if __name__ == "__main__":
if len( sys.argv ) == 1:
print 'usage: temperature.py u|serial_port_path|server_url'
sys.exit( 1 )
else:
ow.init( sys.argv[ 1 ] )
temperature( )
For a quick and dirty run you'd run it like this:
sudo python temperature.py u
Normally, if you run the owfs server as part of your Linux system startup, then you can run the python code as a non-root user.
Pi and the Cloud
Now that we can read the cables with a cheap Raspberry Pi, the possibilities now become much greater. The Pi can interface with a WiFi or 3g dongle and periodically transmit temperature information to a server somewhere. There you can plot graphs, dispatch e-mails and alerts, etc.
And of course locally you can do a lot on the Pi too. E-mails and text messages can come directly from the Pi. If your bins were within WiFi range of your office, you could query the pi directly to see temperature charts. Pi could run a web server for this purpose. Also the Pi, possibly in conjunction with an AVR board or shield like the GertDuino, interface with physical hardware. Maybe triggering relays to start fans. Additional sensors could be added to sense air temperature and humidity and then use that to decide how and when to aerate. And of course if you added the humidity and temperature cables in the bin you could create your own fully automatic system to hydrate grain using only the air outside and nothing illegal.
There are lots of possibilities and lots of companies starting to get into the act, offering their own solutions. Personally the do it myself has appeal, but if I could come up with something actually novel using this hardware that might be an interesting diversification project.
















