pkgsrc/misc/open2300-mysql/MESSAGE
2005-09-28 14:15:48 +00:00

64 lines
2.9 KiB
Text

===========================================================================
$NetBSD: MESSAGE,v 1.4 2005/09/28 14:15:49 rillig Exp $
Before you can use this program, you need to configure the MySQL
connection in the open2300.conf file. The mysql user used by the
program only needs "insert" priviledges.
You need to creat a table 'weather' in the configured database.
The program code suggests the following table structure:
CREATE TABLE `weather` (
`timestamp` bigint(14) NOT NULL default '0',
`rec_date` date NOT NULL default '0000-00-00',
`rec_time` time NOT NULL default '00:00:00',
`temp_in` decimal(2,1) NOT NULL default '0.0',
`temp_out` decimal(2,1) NOT NULL default '0.0',
`dewpoint` decimal(2,1) NOT NULL default '0.0',
`rel_hum_in` tinyint(3) NOT NULL default '0',
`rel_hum_out` tinyint(3) NOT NULL default '0',
`windspeed` decimal(3,1) NOT NULL default '0.0',
`wind_angle` decimal(3,1) NOT NULL default '0.0',
`wind_direction` char(3) NOT NULL default '',
`wind_chill` decimal(2,1) NOT NULL default '0.0',
`rain_1h` decimal(3,1) NOT NULL default '0.0',
`rain_24h` decimal(3,1) NOT NULL default '0.0',
`rain_total` decimal(4,1) NOT NULL default '0.0',
`rel_pressure` decimal(4,1) NOT NULL default '0.0',
`tendency` varchar(7) NOT NULL default '',
`forecast` varchar(6) NOT NULL default '',
UNIQUE KEY `timestamp` (`timestamp`)
) TYPE=MyISAM;
Not that the actual field names are not used, but the structure
needs to be compatible. This alternative structure (for newer MySQL
versions) works as well:
CREATE TABLE `weather` (
`timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
`rec_date` date NOT NULL default '0000-00-00',
`rec_time` time NOT NULL default '00:00:00',
`temp_in` float NOT NULL default '0',
`temp_out` float NOT NULL default '0',
`dewpoint` float NOT NULL default '0',
`rel_hum_in` int(11) NOT NULL default '0',
`rel_hum_out` int(11) NOT NULL default '0',
`windspeed` float NOT NULL default '0',
`wind_angle` float NOT NULL default '0',
`wind_direction` enum('N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW') NOT NULL default 'N',
`wind_chill` float NOT NULL default '0',
`rain_1h` float NOT NULL default '0',
`rain_24h` float NOT NULL default '0',
`rain_total` float NOT NULL default '0',
`rel_pressure` float NOT NULL default '0',
`tendency` enum('Steady','Rising','Falling') NOT NULL default 'Steady',
`forecast` enum('Rainy','Cloudy','Sunny') NOT NULL default 'Rainy',
PRIMARY KEY (`timestamp`)
)
ENGINE=MyISAM DEFAULT CHARSET=latin1
COMMENT='Weather as reported by WS 2300';
The program will not output anything, unless errors occur. This
makes it easy to use it in cron jobs.
===========================================================================