Friday, April 28, 2006

Door Sensor

It has been raining on and off for the past 24 hours. So far we have about .70 inches. We are quite dry so I hope we get about 2 more inches of gentle rain.

At any rate I figured it was about time to add a sensor to let the system know when the door was open or closed. It would be a bad thing to turn on the fans when the door was closed. It would also be nice if the system could alert me that I needed to open or close the door for temperature control. Yup some things are still quite manual.

The obvious choice would be to use a reed switch, neither I or the local Radio Shack have one. I was thinking about using a limit switch but the door is a bit sloppy and the switches I have do not look moisture proof. I settled on using an old mercury switch salvaged from a blower fan. These are simple devices. When the mercury cover the contacts the circuit is closed.


The sensor mount is little more then two bits of wood attached to a strap hinge. The switch is attached to one of the sticks with electrical tape.

When the door is opened the heavy end swings down causing the mercury to run away from the contacts.

When the door closes it pushes the sticks in which tilts the mercury switch and contact is made.


The tape is used to position the switch an angle that will cause the desired murcury flow.

That is all.

Wet bulb humidity sensor


Robert Graham describes (with pictures) how to measure humidity with a couple of DS18S20 sensors, a fan and some PVC pipe. Here on the Wet Bulb Humidity page.

This "modern" way requires a humidity sensor and another sensor (DS2438) to meaure voltage and temperature. See this.

A more complex experiment on the subject can be found at Thermistor Psychrometer Lab.



Philip Gladstone's version of a shade. This one is made of plastic bowls costing less then $1 each.

Tuesday, April 25, 2006

Graphing


I spent some time working on the graphing. Added background color and a line for freezing and another where cooling starts (hardcoded at 80 for now).

Sunday, April 23, 2006

ZedGraph and using time for the X axis.

The article regarding ZedGraph is

A flexible charting library for .NET


ZedGraph uses a variation of the C# DateTime type called XDate.
The current scheam is to leave all dates in C# DateTime type and
the convert them to XDate for graphing.

In mysql the date/time field is
of type datetime and has a default value of 0000-00-00 00:00:00

In C# use the type DateTime.

DateTime timeStamp;

To format it for the mysql query use.

timeStamp.ToString("yyyy-MM-dd HH:mm:ss")
see Parsing Dates and Times in .NET
The code to get the timeStamp back into a C# DateTime type is

MyCommand.CommandText = "SELECT * FROM Temperature ORDER BY idx";
OdbcDataReader MyDataReader;
MyDataReader = MyCommand.ExecuteReader();
while (MyDataReader.Read())
{
string a = MyDataReader.GetString(4); // where the datetime value is in the 5th position
System.IFormatProvider frmt = new System.Globalization.CultureInfo("en-US", true);
DateTime dt = DateTime.ParseExact(a, "yyyy-MM-dd HH:mm:ss", frmt);
....
}

To get ZedGraph setup to use time on the x axis.

// get a reference to the GraphPane
GraphPane myPane = zg1.GraphPane;

// Set the Titles
myPane.Title = "Temperature Data";
myPane.XAxis.Title = "Time";
myPane.YAxis.Title = "Temperature";
myPane.XAxis.Type = AxisType.Date;

There are other options regarding what one can set for x-axis and time but the one line is all you should need if you are feeding it time in the XDate format.