Monthly Archives: November 2011

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 “
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)


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.

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.


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"

Barometric Pressure

While looking at low cost pressure sensors in the Mouser Electronics catalog, I located the FREESCALE MPXAZ6115A as a possible sensor for my project. The sensor has the following statistics;

Device: MPX6115, MAX PSI 16.7, MAX kPa 115.

Since barometric pressure here hovers at around 100kPa or so, this sensor would do just fine. The analog output of the sensor is relative to the min/max pressure range of the sensor.

According to my initial tests, the sensor would output about 4.06 volts at 100kPa.

The built-in analog input on the Arduino would also keep the circuit simple and after a few tests I was able to determine the offset value I needed to get correct readings for the localized barometric pressure.
In my case… testing showed that the magic number is 0.13.

// Nominal Transfer Value:
// Vout = VS x (0.009 x P – 0.095)
// ± (Pressure Error x Temp. Factor x 0.009 x VS)
// VS = 5.1 ± 0.25 Vdc

float Vin;
float P;

void setup()

void loop()
Vin = (5.0/1024.0) * analogRead(0);
Vin = Vin + 0.13;     // Offset Adjustment
 Serial.println(" Volts");

 Serial.println(" kPa");

Vin = (P * 0.2952999);
 Serial.println(" Inches of Mercury");

I’m using a LADYADA Boarduino on a solder-less breadboard for testing. The sensor hookup is dead simple with only one exception that makes it tricky. The part I selected is designed to be surface mounted.

I decided to create a carrier board using the board layout software I prefer called SprintLayout from ABACOM in Germany. Other than 5V power and ground connections, the Vout from the carrier board goes directly to the Arduino Analog(0) pin.

To create the PCB board, I use the GOOTIE toner transfer method to apply the layout on the PCB for etching. (google search “gootie PCB” for more info)

Having developed a dislike for the chemical etchant that Radio Shack sells; Ferric Chloride, I have also adopted the etchant that
Gootie describes.

It is based on the swimming pool chemical Muratic Acid and Hydrogen Peroxide in a 1 to 2 ratio. It’s fast, non-opaque and does not require heating or excessive agitation.

Note: I also recently picked up a used GBC Creative Laminator at the local Goodwill for $14.00. It does an excellent job of applying the toner to the copper on the PCB to be etched. Using an hand iron was OK, but the results were not always predictable.

My method of making PCB’s at home.


Here is the Layout: