Monitoring/controlling with Linux on the cheap

Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum

Help Support Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

GatorDad

Well-Known Member
Joined
Mar 29, 2011
Messages
220
Reaction score
5
Location
Brandon
There are numerous controller solutions on the market. Some of them are really, really nice, but, they aren't cheap either. With this economy and a kid in college, it has to be cheap (or free) before I will consider it. While I don't have a pile of cash sitting around (thanks to UF), I do have a few old POS laptops that have nothing to do but reminisce of days gone by. Rather than collect dust, I'm putting one (or more) of them to work.

This article requires the following:
  • A working install of Linux.

  • A working knowledge of Linux. You don't need to be an expert, but you do need to understand mounting file systems and what not. This is not a tutorial on how to use Linux. :)

  • A 1-wire adapter. I'm using the serial port version (DS9097U-XXX), but there are USB versions that work with this also. I recommend buying at least two (to have one for "play").

  • 1-wire temperature sensors and switches. I'm using DS18S20 for temperature sensors, and DS2406 for switching. You can buy them most anywhere (Jameco, Digi-Key, etc). Make sure you order the TO-92 packaging unless you have ninja soldering skills. If you don't want to make your own sensors/switches, you can order them pre-assembled from numerous sources (here, here, here). That (assembled) 8 relay board from Hobby Boards for ~$70 is one heck of a deal.

  • You can get a few free ones from Maxim: here. Enter the part number (DS18S20), click GO, then select the "Sample Now" button on the items you're interested in. Do the same for the DS2406 and any other 1-wire device you want a free sample of. Not all items are available for sample so poke around. Don't be greedy - accept the default quantity of 2 and be happy.


I did this on a fresh install of Fedora 14. However, these procedures should work on most any distribution. Before you install anything though, check to make sure it's not already installed by your distribution (no need to have it twice).

All source that was downloaded was extracted into /usr/src as typical.

Download and install FUSE: http://fuse.sourceforge.net/
Follow the directions in the INSTALL file. From the command line:

Code:
    # ./configure
    # make
    # make install

Download and install owfs: http://sourceforge.net/projects/owfs/files/owfs/2.8p8/
Follow the directions in the INSTALL file. From the command line:

Code:
    # ./configure --prefix=/opt/owfs
    # make install

You can run owfs in a number of different ways (google it), but I choose to run the client/server model. Since I want all this mess started and mounted on startup, I edit my /etc/rc.local file to achieve that as such:
Code:
    #
    # fire up the 1-wire stuff
    #
    /opt/owfs/bin/owserver -d /dev/ttyS0 -F -p 1961
    /opt/owfs/bin/owfs -s localhost:1961 -m /mnt/1wire -F --allow_other

Adjust the /dev/ttyS0 term to match the serial port your 1-wire adapter is plugged into (/dev/ttyS0 is serial port #1, etc). You can use any port you want - I chose 1961 because that's my birthyear.

Now you are ready to attach some 1-wire devices. As mentioned above, you can buy them, or, you can make them yourself. I can't say how "hard" it is - only you can decide that. I'd say it's about "medium" on the hard scale. I'm not that good with a soldering iron - I can manage, but I don't do a pretty job of it. It works, but it ain't pretty. :)

Use these schematics for making your own:click

The DS18S20 temperature sensors are very easy to hook up and use. Two pins to ground, the other to the 1-wire bus line. The DS2406 is a bit more involved, but doable. I used this schematic for my DS2406 switches as I already had those parts laying around here. Aside from the DS2406, these parts are CHEAP. Once you have that circuit working, attach the +/- 5 volts output to a SSR rated to handle your intended load.

Once you have the 1-wire devices connected, cd to the mount point of your 1-wire. For me it's /mnt/1wire:

Code:
[root@x24 1wire]# cd /mnt/1wire/

Get a directory listing:
Code:
    [root@x24 1wire]# ls -l
    total 0
    drwxrwxrwx. 1 root root  8 Apr 20 11:39 10.26CC4F000800
    drwxrwxrwx. 1 root root  8 Apr 20 11:39 10.E1B64F000800
    drwxrwxrwx. 1 root root  8 Apr 20 11:39 12.50547D000000
    drwxrwxrwx. 1 root root  8 Apr 20 11:39 12.6A497D000000
    drwxr-xr-x. 1 root root  8 Apr 20 00:59 alarm
    drwxr-xr-x. 1 root root  8 Apr 20 00:59 bus.0
    drwxr-xr-x. 1 root root  8 Apr 20 00:59 settings
    drwxrwxrwx. 1 root root  8 Apr 20 11:39 simultaneous
    drwxr-xr-x. 1 root root  8 Apr 20 00:59 statistics
    drwxr-xr-x. 1 root root 30 Apr 20 00:59 structure
    drwxr-xr-x. 1 root root  8 Apr 20 00:59 system
    drwxr-xr-x. 1 root root  8 Apr 20 00:59 uncached
    [root@x24 1wire]#
The entries that begin with "10" and "12" are four 1 wire devices that I have hooked up at the time of this writing. Devices that begin with "10" are DS18S20 and those that begin with "12" are DS2406. Those are the "family" id values (the rest of that number is it's address).

The directory structure of a DS18S20:
Code:
    [root@x24 1wire]# cd 10.26CC4F000800/
    [root@x24 10.26CC4F000800]# ls -l
    total 0
    -r--r--r--. 1 root root  16 Apr 20 00:59 address
    -r--r--r--. 1 root root 256 Apr 20 00:59 alias
    -r--r--r--. 1 root root   2 Apr 20 00:59 crc8
    drwxrwxrwx. 1 root root   8 Apr 20 11:42 errata
    -r--r--r--. 1 root root   2 Apr 20 00:59 family
    -r--r--r--. 1 root root  12 Apr 20 00:59 id
    -r--r--r--. 1 root root  16 Apr 20 00:59 locator
    -r--r--r--. 1 root root   1 Apr 20 11:42 power
    -r--r--r--. 1 root root  16 Apr 20 00:59 r_address
    -r--r--r--. 1 root root  12 Apr 20 00:59 r_id
    -r--r--r--. 1 root root  16 Apr 20 00:59 r_locator
    -r--r--r--. 1 root root  12 Apr 20 00:59 temperature
    -rw-rw-rw-. 1 root root  12 Apr 20 11:42 temphigh
    -rw-rw-rw-. 1 root root  12 Apr 20 11:42 templow
    -r--r--r--. 1 root root  32 Apr 20 00:59 type
    [root@x24 10.26CC4F000800]#

To read the temperature, "cat temperature":
Code:
    [root@x24 10.26CC4F000800]# cat temperature
         66.9875
    [root@x24 10.26CC4F000800]#

In the above example, the temperature is 66.9875 degrees (in my fermentation fridge). Here's how you get to that value in a bash script:
Code:
     #
     # the device name of the DS18S20 temperature sensor
     #
     fermilabDev="/mnt/fermiTemp/temperature"

     #
     # read (and log) the temperature of the fridge
     #
     fermilabTemp=$(cat $fermilabDev | tr -d ' ')
     logger -t fermilab "$fermilabTemp degrees"

The DS2406 shows up a bit differently in the file system:
Code:
    [root@x24 1wire]# cd 12.6A497D000000/
    [root@x24 12.6A497D000000]# ls -l
    total 0
    -r--r--r--. 1 root root  16 Apr 20 00:59 address
    -r--r--r--. 1 root root 256 Apr 20 00:59 alias
    -r--r--r--. 1 root root  12 Apr 20 11:48 channels
    -r--r--r--. 1 root root   2 Apr 20 00:59 crc8
    -r--r--r--. 1 root root   2 Apr 20 00:59 family
    -r--r--r--. 1 root root   1 Apr 20 11:48 flipflop.A
    -r--r--r--. 1 root root   3 Apr 20 11:48 flipflop.ALL
    -r--r--r--. 1 root root   1 Apr 20 11:48 flipflop.B
    -r--r--r--. 1 root root  12 Apr 20 11:48 flipflop.BYTE
    -r--r--r--. 1 root root  12 Apr 20 00:59 id
    -rw-rw-rw-. 1 root root   1 Apr 20 11:48 latch.A
    -rw-rw-rw-. 1 root root   3 Apr 20 11:48 latch.ALL
    -rw-rw-rw-. 1 root root   1 Apr 20 11:48 latch.B
    -rw-rw-rw-. 1 root root  12 Apr 20 11:48 latch.BYTE
    -r--r--r--. 1 root root  16 Apr 20 00:59 locator
    -rw-rw-rw-. 1 root root 128 Apr 20 00:59 memory
    drwxrwxrwx. 1 root root   8 Apr 20 11:48 pages
    -rw-rw-rw-. 1 root root   1 Apr 20 11:48 PIO.A
    -rw-rw-rw-. 1 root root   3 Apr 20 11:48 PIO.ALL
    -rw-rw-rw-. 1 root root   1 Apr 20 11:48 PIO.B
    -rw-rw-rw-. 1 root root  12 Apr 20 11:48 PIO.BYTE
    -r--r--r--. 1 root root   1 Apr 20 11:48 power
    -r--r--r--. 1 root root  16 Apr 20 00:59 r_address
    -r--r--r--. 1 root root  12 Apr 20 00:59 r_id
    -r--r--r--. 1 root root  16 Apr 20 00:59 r_locator
    -r--r--r--. 1 root root   1 Apr 20 00:59 sensed.A
    -r--r--r--. 1 root root   3 Apr 20 00:59 sensed.ALL
    -r--r--r--. 1 root root   1 Apr 20 00:59 sensed.B
    -r--r--r--. 1 root root  12 Apr 20 00:59 sensed.BYTE
    -rw-rw-rw-. 1 root root  12 Apr 20 11:48 set_alarm
    drwxrwxrwx. 1 root root   8 Apr 20 11:48 T8A
    drwxrwxrwx. 1 root root   8 Apr 20 11:48 TAI8570
    -r--r--r--. 1 root root  32 Apr 20 00:59 type
    [root@x24 12.6A497D000000]#

To turn the DS2406 switch "on", you do this:
Code:
    [root@x24 12.6A497D000000]# echo "1">PIO.A
and to turn it off:
Code:
    [root@x24 12.6A497D000000]# echo "0">PIO.A

The TO-92 package of the DS2406 has only one switch line, so PIO.B is not usable on this device.
 
To make your life easier, you may want to create sym links to the 1-wire devices. Repeating the above directory structure:

Code:
    [root@x24 1wire]# ls -l
    total 0
    drwxrwxrwx. 1 root root  8 Apr 20 11:39 10.26CC4F000800
    drwxrwxrwx. 1 root root  8 Apr 20 11:39 10.E1B64F000800
    drwxrwxrwx. 1 root root  8 Apr 20 11:39 12.50547D000000
    drwxrwxrwx. 1 root root  8 Apr 20 11:39 12.6A497D000000
    drwxr-xr-x. 1 root root  8 Apr 20 00:59 alarm
    drwxr-xr-x. 1 root root  8 Apr 20 00:59 bus.0
    drwxr-xr-x. 1 root root  8 Apr 20 00:59 settings
    drwxrwxrwx. 1 root root  8 Apr 20 11:39 simultaneous
    drwxr-xr-x. 1 root root  8 Apr 20 00:59 statistics
    drwxr-xr-x. 1 root root 30 Apr 20 00:59 structure
    drwxr-xr-x. 1 root root  8 Apr 20 00:59 system
    drwxr-xr-x. 1 root root  8 Apr 20 00:59 uncached
    [root@x24 1wire]#

The sym links make it easier to refer to the 1-wire devices in your scripts/programs using a logical name, rather than some goofy alpha-numeric that means nothing us humans:

Code:
    [root@x24 mnt]# cd /mnt
    [root@x24 mnt]# ls -l
    total 0
    drwxr-xr-x. 1 root root  8 Apr 20 00:59 1wire
    lrwxrwxrwx. 1 root root 21 Apr 20 00:14 fermiOutsideTemp -> 1wire/10.E1B64F000800
    lrwxrwxrwx. 1 root root 21 Apr 20 00:10 fermiSwitch -> 1wire/12.6A497D000000
    lrwxrwxrwx. 1 root root 21 Apr 14 10:38 fermiTemp -> 1wire/10.26CC4F000800
    lrwxrwxrwx. 1 root root 21 Apr 20 01:05 switch1 -> 1wire/12.50547D000000
    [root@x24 mnt]#


Now, all you need to do is write some scripts (in whatever language you're comfortable with) that does something useful with the above.

Enjoy, and YMMV. :)
 
Excellent! I have started using a 1-wire sensor system with windows and it would be nice to have a Linux option.

I applied for a "free" DS2406 recently and they wanted to charge me $75 for a kit?? Not sure I did it right, but will try again. I kind of made it look like I was interested for my wife's company, who does electronic R&D...

I may play with this info and see what I can do. Might be bugging you for some script help in the future!
 
Homercidal,

You did nothing wrong last time - they sell a developer kit too. The link above is to a different area (as you have already found out).

The nice thing about using owfs is that it exposes 1-wire devices as a file system, which, takes almost all the work out of playing with those devices - no bit twiddling. It's frightening simple once it's all setup. Last I checked, owfs wasn't quite ready for prime-time on Windows - it might be worth a checking into though.

Scripting... with owfs, anything that can interface with the file system, can do 1-wire. Bash, python, perl, php, etc. For example, my ferm fridge (Fermilab) is controlled by a simple bash script that gets fired up once every 2 mins by cron. I'm currently working on expanding this control mechanism to a HERMS system, but I'm not done with that yet...
 
I have done a bit of bash scripting in college. I don't think I still have the Unix reference book, but I'll check. LOTS of information on scripting online though.

After seeing how it's done a little bit, it's starting to make some sense and really does seem very simple. I'm mostly interested in using it for controlling, since my temp monitor is already basically set up and working well. What I can see happening is using this to not just control a ferm chamber, but maybe 2 or more AND sending the temps to a file for reference.

I should get all my friends to order samples for me...
 
Here is some PHP code that plays with the device names I used in the examples above. You can run it from the command line, or from a web server. If your language of choice can open, read, write and close a file, it can do 1-wire via owfs:

PHP:
<?php

    // display the temperature
    displayTemp();        
    
    // toggle the switch
    setSwitch("1");
    sleep(1);
    setSwitch("0");
    
    exit;
    
    

function displayTemp() {
    //
    // the device name of the temp probe
    //
    $devTemp = "/mnt/fermiTemp/temperature";
    
    //
    // open the temperature device
    //
    $fp = fopen($devTemp,"r");
    if ($fp == null) {
        echo "error opening $devName\n";
        exit;
    }
    
    //
    // read the temperature
    //
    $temp = trim(fread($fp,1024));
    
    //
    // close the file handle
    //
    fclose($fp);
    
    //
    // display the temperature
    //
    echo "The temp is: $temp\n";
}
    
    
function setSwitch($state) { 
    //
    // the device name of the DS2406 switch
    //
    $devSwitch = "/mnt/fermiSwitch/PIO.A";
    
    //
    // open the temperature device
    //
    $fp = fopen($devSwitch,"w");
    if ($fp == null) {
        echo "error opening $devSwitch\n";
        exit;
    }
    
    //
    // set the switch state
    //
    if (fwrite($fp,$state) === FALSE) {
        echo "error writing to $devSwitch\n";
        exit;    
    }
    
    //
    // close the file handle
    //
    fclose($fp);
    
    //
    // display the temperature
    //
    echo "The switch is set to: $state\n";
}

?>
 
Nice, I've played with Linux since slack 1, the wife doesn't like it so I can't keep it on the main system and the backup is pooched right now. Linux is the way to go, now all you need is a gui.
 
Your average SSR attached to a DS2406 (or similar). See the links above for vendors who sell pre-assembled 1-wire relay boards (or google it). You attach the relay board to your 1-wire network, connect your A/C device to the relay, then control it via a script... or a program, or whatever.

What could you use to control the outlets /
heating / cooling / etc thought a PC?
 
Nice, I've played with Linux since slack 1, the wife doesn't like it so I can't keep it on the main system and the backup is pooched right now. Linux is the way to go, now all you need is a gui.

Sounds like you are the man! Can't wait to see what your GUI looks like!
 
You may be able to find things like FUSE in your distro's package repositories. I'd highly recommend only compiling from source if it's not in the repos (or pre-packaged in 3rd party repos) or if you need a very specific dev version.

The package managers are your friend!

-chuck
 
Already covered near the top of the first post... but worth repeating in any case. Most can handle a pkg manager - not everyone feels comfortable compiling from source - which is why I documented that process. :)

That said, I'm not a fan of 3'rd party repos. Too many problems. It's easier (and IMHO safer) to compile from source. If your distro doesn't have (or provide it), don't screw around with anything other than the original source.


You may be able to find things like FUSE in your distro's package repositories. I'd highly recommend only compiling from source if it's not in the repos (or pre-packaged in 3rd party repos) or if you need a very specific dev version.

The package managers are your friend!

-chuck
 
Ok, now how am I supposed to get going with a USB adapter?? I can't even tell which device is the 1-wire stick! I got FUSE installed and I installed OWFS, although the how-to online is very crappy, as per usual with linux. They are missing pretty much the entire installation area.
 
LOL. Frequently, but not this time. :) You missed it in the docs: http://owfs.sourceforge.net/owfs.1.html#sect12

Where I'm using "-d /dev/ttyS0" above, use "-u" (or "--usb") instead. See docs for further details.

Also recall that you can use "dmesg" to display boot info (like what devices are discovered). In this case, "dmesg | grep -i usb" might be useful.


They are missing pretty much the entire installation area.
 
Well, to be fair, that is not an installation guide as much as a quick reference. I'm sure I can make sense of it after a bit of studying. I did the dmesg thing a few times, but it's messy and I can't seem to find anything about the 1-wire device. I better check when I get home to see that I even plugged it in. I did use the dmesg to mount the USB stick to install owfs.

I just think it's "odd" that there is a link to the INSTALL page and here is what it says:

Installing OWFS can be the hardest part of the whole process. Once you get it working, you'll be amazed at how robust and flexible the system can be.

Take heart. Everyone has (eventually) gotten it to work and we have all the tricks gathered here.



Yep, that's the whole INSTALL page! That is from the owfs.org site, not the sourceforge site. I haven't looked through there yet.
 
I completely agree with you. This is why I wrote the topic up - it gave me fits installing and I've been doing this 30+ years (linux since 94). Getting owfs up and running can be a challenge, but as the docs say, once you're over that hurdle, it's really easy after that.

Being new here, what's the rules about editing a previous post? Should I edit my first post to include these usb parms? It might save someone a lot of heartache... eh?


Well, to be fair, that is not an installation guide as much as a quick reference. I'm sure I can make sense of it after a bit of studying. I did the dmesg thing a few times, but it's messy and I can't seem to find anything about the 1-wire device. I better check when I get home to see that I even plugged it in. I did use the dmesg to mount the USB stick to install owfs.

I just think it's "odd" that there is a link to the INSTALL page and here is what it says:

Installing OWFS can be the hardest part of the whole process. Once you get it working, you'll be amazed at how robust and flexible the system can be.

Take heart. Everyone has (eventually) gotten it to work and we have all the tricks gathered here.



Yep, that's the whole INSTALL page! That is from the owfs.org site, not the sourceforge site. I haven't looked through there yet.
 
It's fine now AFAIC. I found that i had not plugged the adapter in before I left for work, so that is way my dmesg wasn't showing anything. I'm sitting with the wife as she watches DWTS, so hopefully I can concentrate on what i need to do.
 
A few PHP classes I'm using that may be useful to someone else out there.

I've named this file "ow.php".

Code:
<?php
//
//  Copyright 2011, Chris Curran
//
//    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 3 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, see <http://www.gnu.org/licenses/>.
//


//
// 1-wire base class
//
class OneWireT {
    public $devName;        //the device name
    public $devMode;        //the device mode (r, w, rw)

    private $fp;            //file pointer


    public function __construct($name, $mode) {
        $this->devName = $name;
        $this->devMode = $mode;

        $this->fp = @fopen($name,$mode);
    }

    protected function read() {
        rewind($this->fp);
        return trim(@fread($this->fp,1024));
    }

    protected function write($data) {
        rewind($this->fp);
        return @fwrite($this->fp, $data, strlen($data));
    }
}


//
// 1-wire base reader class
//
class OneWireReaderT extends OneWireT {

    public function __construct($name) {
        parent::__construct($name,"r");
    }

    public function read() {
        return parent::read();
    }
}


//
// 1-wire base writer class
//
class OneWireWriterT extends OneWireT {

    public function __construct($name) {
        parent::__construct($name,"w");
    }

    public function write($data) {
        return parent::write($data);
    }
}

//
// 1-wire base reader/writer class
//
class OneWireReadWriteT extends OneWireT {

    public function __construct($name) {
        parent::__construct($name,"r+");
    }

    public function read() {
        return parent::read();
    }

    public function write($data) {
        return parent::write($data);
    }
}


//
// 1-wire class to handle switches
//
class OneWireSwitchT extends OneWireReadWriteT {
    private $state = 0;

    public function __construct($name) {
        parent::__construct($name);
        $this->state = $this->read();
    }

    public function on() {
        $this->state = 1;
        return $this->write("1");
    }

    public function off() {
        $this->state = 0;
        return $this->write("0");
    }

    public function getState() {
        return $this->state;
    }

}



//
//
// 1-wire class to the DS18x20 temperature sensors
//
//
class OneWire1820 extends OneWireReaderT {

    public function __construct($name) {
        parent::__construct("$name/temperature");
    }

}



//
//
// 1-wire class to the DS2406 switch (port A)
//
//
class OneWire2406a extends OneWireSwitchT {

    public function __construct($name) {
        parent::__construct("$name/PIO.A");
    }

}

//
//
// 1-wire class to the DS2406 switch (port B)
//
// Note: the TO-92 packaging of the DS2406 does not have a "B" port.
//
class OneWire2406b extends OneWireSwitchT {

    public function __construct($name) {
        parent::__construct("$name/PIO.B");
    }

}

?>


A sample program:
Code:
<?php

    require_once("ow.php");

    //
    // if running from cmd line, use "\n" for newlines.
    // if running from browser, use "<br>" for newlines.
    //
    $nl = ( isset($_SERVER['SERVER_ADDR']) ) ? "<br>":"\n";


    //
    // create an instance to our temperature sensor
    //
    $tempObj = new OneWire1820("/mnt/fermiTemp");

    // display the temperature
    echo $tempObj->read(), $nl;


    //
    // create an instance to our switch
    //
    $switchObj = new OneWire2406a("/mnt/fermiSwitch");

    //
    // turn it on, wait one second, then turn it off
    //
    echo "turning switch on$nl";
    $switchObj->on();
    sleep(1);
    echo "turning switch off$nl";
    $switchObj->off();
    echo "$nl";

?>
 
You may be able to find things like FUSE in your distro's package repositories. I'd highly recommend only compiling from source if it's not in the repos (or pre-packaged in 3rd party repos) or if you need a very specific dev version.

The package managers are your friend!

-chuck

Even though FUSE was noted as INSTALLED after I loaded Slackware, I could not get this to work. I eventually found time to install a newer version and the install process got it working. I am literate enough in linux to get things working, but smart enough in it to get something installed to actually RUN like it's supposed to.

Now am working on understanding the symlinks better. But I can get a readout from the adapter and sensor, so I'm most of the way there. Only have to remember how to program scripts. ;)
 
Over-simplifying, "symlinks" are to unix based systems as "shortcuts" are to Windows.

To create a symbolic link (symlink), use the command line tool "ln" as such:

Code:
#ln -s <real_name> <symbolic_name>

For example, if your temp sensor was "/mnt/1wire/10.26CC4F000800" and you wanted to create a symlink so you could refer to it as "/mnt/tempSensor1":

Code:
 ln -s /mnt/1wire/10.26CC4F000800 /mnt/tempSensor1
 
Only have to remember how to program scripts. ;)

BTW, you don't HAVE to use bash scripts. Any language (scripting or otherwise) that can interact with the file system (open, read, write & close files) can be used. The above PHP code for example. That can be run from the command line - or from cron. PHP isn't for web servers *only* - it's a damn useful utility language too. :)
 
Awesome writeup, thanks for posting this. I see some more linux tinkering in my future.
 
Over-simplifying, "symlinks" are to unix based systems as "shortcuts" are to Windows.

To create a symbolic link (symlink), use the command line tool "ln" as such:

Code:
#ln -s <real_name> <symbolic_name>

For example, if your temp sensor was "/mnt/1wire/10.26CC4F000800" and you wanted to create a symlink so you could refer to it as "/mnt/tempSensor1":

Code:
 ln -s /mnt/1wire/10.26CC4F000800 /mnt/tempSensor1

Yeah it seems simple until I try it! Here is what went wrong:

I always start up my linux with the alias command so that I get the directory listing the way I want:

alias ddir='ls -a -l --color |more'

Works great except that when viewing certain directories from another location, nothing is returned. It makes it seem as though the directory is empty. I worked through the entire command until I hit the |more. Then it screwed up.

So I took that out of the command, deciding that I can simply add |more whenever I really needed it (which honestly is not that often).


Hopefully I will have time to play with this more today. I don't mind Bash scripts. I think that is what I used to use a lot of in college. But PHP would be a more useful language to learn.
 
OK, but understand this isn't symlinks. Bash alias handling is a different animal all together. For this alias to work as you desire you're going to need to hack parameter passing to the alias (function, finger, etc).


Yeah it seems simple until I try it! Here is what went wrong:

I always start up my linux with the alias command so that I get the directory listing the way I want:

alias ddir='ls -a -l --color |more'

Works great except that when viewing certain directories from another location, nothing is returned. It makes it seem as though the directory is empty. I worked through the entire command until I hit the |more. Then it screwed up.

So I took that out of the command, deciding that I can simply add |more whenever I really needed it (which honestly is not that often).


Hopefully I will have time to play with this more today. I don't mind Bash scripts. I think that is what I used to use a lot of in college. But PHP would be a more useful language to learn.
 
Hey, what would you recommend as a Graphical display to show the temps and switch state, and for adjusting the settings of the temp controller? I'm looking into using PHP as a scripting language.

EDIT: currently looking at PHP-GTK as a way of incorporating the GTK graphical interface within PHP. Looks like the perfect compliment to PHP scripting. I don't know where I'll find time to actually start programming this stuff, but I think this could be a very useful method of setting up a graphical interface for a control panel.
 
If you're using the Linux machine as a standalone controller, you can develop a simple Python GUI for display and control using Tk or WxPython. If you want to network things, use PHP on the Linux (server side). On the client side, use Ajax and JavaScript to dynamically update a webpage.
 
Most of my background is in the "down on bare metal" stuff, so I don't have a lot of experience with GUI libs and what-not. I'm not sure if I'd use PHP (or any server side scripting) to do much eye-candy on the user side (browser). I'd look for a javascript lib that could be used to display your data using some fancy slider/range/toggle widgets. Get the data from a PHP script via ajax (or create the js on the fly with a PHP script).

I have built a number of web apps using the above model (PHP server side, JS client side, access via ajax). I used YUI for those projects, but YUI is probably better suited to "business" type apps rather than utility types - it doesn't have any fancy gui widgets (that I know of) that could be used to display ranges or states so you'd have to roll-your-own, in which case it'd be easier (and probably wiser) to go find something already done and use that instead.

jQuery is also making a lot of noise out there, but I've never used it.
 
on second thought... Just use whatever PHP GUI lib you're comfortable with. I often get anal about design and scalability, and none of that is important here. Do what feels good. :)
 
If you're using the Linux machine as a standalone controller, you can develop a simple Python GUI for display and control using Tk or WxPython. If you want to network things, use PHP on the Linux (server side). On the client side, use Ajax and JavaScript to dynamically update a webpage.

I peeked briefly at Python, but it seems rather complicated. Do you have any links to some good beginner information?
 
on second thought... Just use whatever PHP GUI lib you're comfortable with. I often get anal about design and scalability, and none of that is important here. Do what feels good. :)

At this point I have no real opinion. I just need something that will display the sensor information and allow me to adjust the setpoints of a script or program to tweak the controller.

It's been many years since I've done ANY programming, and what I did was some Pascal stuff, and a bunch of COBOL/RPG for business reporting mostly. There was a class on Unix that did some cool scripting, mostly in BASH shell.

I'm really just starting out with Linux, scripting, compiling, etc. Maybe I need to try a little bit of everything suggested in order to know what would be easy and work well.

I really just want a simple graphical interface for the user, and the ability to update a webpage on my Slackware server. I assumed that PHP-GTK would provide both. I think PHP has a method of creating a simple web page and updating on a web server?

I'm also thinking that this could work for monitoring a brewing session, not just as a fermentation monitor system. For a brewing controller, I don't see the need to involve a network. I could pick up a small, cheap LCD monitor or old laptop and build it right into a control panel. Or simply attach said laptop to the brew rig when brewday comes around.

Kind of excited to be working in GUI interface. I've never made a "window" program before that I can remember...
 
Designing a GUI is a great way to bog down a simple project. At least for now, skip the GUI, and go with some simple scripts. Bash is easy. PHP works just as well.

Write one script that will echo all sensor data and relay states to stdout (a single instantaneous data dump, not a loop).

Write as many other scripts (or one script that takes command line arguments) as you need for control. Make it so that you can type something like this:
Code:
homer heat on
homer pump on
homer heat off

Use the watch command in one terminal window to continuously run your data dump script. Use another terminal window to call your control script(s) from the command line. You could even schedule your scripts to run at particular times using the "at" command.

This solution is easily networked since you can execute an ssh (or other remote login) shell from almost any computer.

Down the road, these scripts can become the basis for a simple GUI.
 
Designing a GUI is a great way to bog down a simple project. At least for now, skip the GUI, and go with some simple scripts. Bash is easy. PHP works just as well.

I couldn't agree more.... a better use of time would be to go fishing, or drink beer. Or both. :)


Write one script that will echo all sensor data and relay states to stdout (a single instantaneous data dump, not a loop).

Another option is to write that info to the system log file (from bash):
Code:
logger -t fermilab "$fermilabTemp degrees"

The above line will write a entry to the system log file with a tag of "fermilab". If the temp read (stored in the variable $fermilabTemp) was 68.000 degrees, the entry would read "68.000 degrees". Writing to the log file also provides a "history" of your operating temps.

To view the log file entries, in another terminal window use the "tail" command as such:
Code:
[root@x24 ~]# tail -f /var/log/messages |grep fermilab
May 16 13:22:02 x24 fermilab: 66.7625 degrees
May 16 13:23:02 x24 fermilab: 66.7625 degrees
May 16 13:24:03 x24 fermilab: 66.875 degrees
May 16 13:25:02 x24 fermilab: 66.875 degrees
May 16 13:26:02 x24 fermilab: 66.875 degrees
May 16 13:27:03 x24 fermilab: 66.9875 degrees
May 16 13:28:02 x24 fermilab: 66.9875 degrees
May 16 13:29:02 x24 fermilab: 66.9875 degrees
May 16 13:30:03 x24 fermilab: 66.9875 degrees
May 16 13:31:02 x24 fermilab: 67.1 degrees
May 16 13:32:02 x24 fermilab: 67.1 degrees

This runs the "tail" command in "forever" mode, piping it's output into grep, which will filter out only log file records that have the word "fermilab" in it. The advantage to using "tail" is that it doesn't run continuously (low resource use).

You could even schedule your scripts to run at particular times using the "at" command.

Since you're going to want to run the scheduled task more than once, "cron" is a better tool:

http://www.ibm.com/developerworks/linux/library/l-job-scheduling/index.html

I use cron to handle my fermentation fridges. It's a simple script that gets called once every minute. It checks the temps and turns a switch on or off. It writes a few entries to the system log file. That's it. Simple.

I'm also thinking that this could work for monitoring a brewing session,

Certainly. I'm working on a HERMS system that will be driven by this project. Damned day job keeps getting in my way though...

For a brewing controller, I don't see the need to involve a network. I could pick up a small, cheap LCD monitor or old laptop and build it right into a control panel. Or simply attach said laptop to the brew rig when brewday comes around

Just pick up an old laptop - they're cheaper than dirt these days. I bought a 5 lot of IBM x24's last year off ebay for ~$300.
 
Back
Top