Creating a weather station with Linux

Long ago I decided that I wanted to keep track of local weather. This is somewhat related to my desire to keep an eye on my raised bed gardens during the summer and partially due to my desire to have fun electronics projects to keep me doing “fun things”. I had already started with 1-wire and had a few devices that I either purchased or made myself.

As a first pass, I decided to see if I could get all my sensors working under Linux before attempting the Arduino weather station  conversion.  That said, It would have been easier if I had decided to use Windows and follow Tim Bitson’s examples from his “Weather Toys” book. The book provides guidance for MacOS and Windows only. That’s really not a show stopper though as I was able to get everything working.

Step 1: Install Linux

Install Ubuntu Linux workstation version 9.10 LTS (I tried newer versions but they have some annoying issues)

Step 2: Installing JavaVM and RXTX

Note: A version of Java is installed by default, It’s just not the one I want.

I installed the full suite of latest SUN JAVA (not default OPENJDK and note that the SUN install requires enabling partner repositories – Google for instructions about enabling and then the JAVA install is simple)

Install RXTX with the command

sudo apt-get install librxtx-java

(It does all the tricky bits for you)

Step 3: OneWire support for JAVA

Download OneWireAPI “http://files.dalsemi.com/auto_id/public/owapi_1_10.zip
Extract contents  to a convenient location and get setup to copy files.
Copy the file OneWireAPI.jar to /usr/share/java/OneWireAPI.jar

The Java Libraries get installed to /usr/share/java. This is default behavior for librxtx-java install, so I used the same solution for OnewireAPI (manually copied)

Step 4: NETBEANS

In my case, this is version 6.8, installed from Synaptic Installer or you could use:

sudo apt-get install netbeans

Netbeans will create a project directory by default in your home folder. Your code goes here.

Libraries:
When defining the library settings for NETBEANS, it’s as simple as the two entries in the “libraries” section, as shown in the book.
a) /usr/share/java/OneWireAPI.jar
b) /usr/share/java/RXTXcomm.jar

Step 5: Grab WEATHERTOYS code.

Here

General Notes

I use the AAG TAI603B interface (USB-SERIAL & 1 Wire Power Injector with home made Hobby Boards adapter) and this is automatically recognized as a device by this version of Linux. In my case, it is a serial device, coded as:

public static final String ONE_WIRE_SERIAL_PORT = "/dev/ttyUSB0";

and seen by the API as:

public static final String ADAPTER_TYPE = "DS9097U";

You can find the ports available with the following command:

sudo dmesg | grep tty

You will likely see something like:

"/dev/ttys0" or  "/dev/ttyUSB0"

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.