## On Windows? Try ATMEL as another option?

The Atmel Studio works hand in hand with the Arduino IDE. I have just compiled the exact same code as on the Mac, on my Windows 8.1 laptop, uploaded it to the Arduino Uno board – and it works straight out of the box. I can monitor it by using Coolterm in Receive mode.
Advantages? Atmel Studio uses Libraries that are unavailable to the Arduino, like the AVR libraries, ie. avr/io.h and avr/interrupt.h, and avr/pgmspace.h

Probably other stuff too.
I don’t know why the sketch compiles – and works !!!! – as it is on the Arduino IDE, even with those libraries missing? on the OSX-Mac, but it does. It also compiles and works as it is, on the Windows, AtmelStudio setup. Interesting.

Atmel Studio 6 – The Studio to Design All Embedded Systems
Installation Instructions
1.1 System requirements
1.1.1 Supported operating systems
● Windows XP (x86) with Service Pack 3 – all editions except Starter Edition
● Windows Vista (x86 & x64) with Service Pack 1 – all editions except Starter Edition
● Windows 7 (x86 and x64)
● Windows 8 / 8.1 (x86 and x64)
● Windows Server 2003 (x86 & x64) with Service Pack 2
● Windows Server 2003 R2 (x86 and x64)
● Windows Server 2008 (x86 and x64) with Service Pack 2
● Windows Server 2008 R2 (x64

## Works for Sparkfun Weather Shield… brilliant. Windows only I think

http://wmrx00.sourceforge.net/

# Weather Station Data Logger

for WMR88, WMR100, WMR200, RMS300 and Radio Shack 63-256 Weather Stations

## Calculating Altitude, using BOSCH formula, and Constants for Sealevel.

This is from the BOSCH Data Sheet.

And this is the code implementation, using the standard measurements for SeaLevel, Pressure and Temperature as defined by NIS
Atmospheric properties
At SSL some atmospheric properties are:[1]

Pressure, P = 101.325 kPa = 2116 lbf/ft2
Density, \rho = 1.225 kg/m3 = 0.002377 slug/ft3
Temperature, T = 288.16 K = 518.69 °R = 15.01 C
=============
So you can use 20C or 15.01 … I doubt it makes much difference. Just don’t take your house into the air to any great height…

The WeatherShield output shows me an Altitude of 18.08, which oddly enough is about right. Surprises even me!

80,27,27,16.8,49,-,WSW,8.0,W  ,3.8,1011.70,18.08,22.5
...........................................^^^^^
/* The formula given by BMP183 Bosh mfg, is
altitude = 44330*(1-(p/p0)^(1/5.255)) which if used with the CONSTANTS, should determine a true altitude.
*/

//Implementation in the weather shield code. The variable is Pzero by the way. P0, not uppercase PO
const float P0 = 1013.25; // seaLevel,
ut = bmp180_get_value(BMP180_TEMPERATURE, 5);
t = (bmp180_get_temperature(ut));
up = bmp180_get_value(BMP180_PRESSURE_3, 26);
p = bmp180_get_pressure(up);

//float T = t/10;
float T = 15.01; // standard sea level temperature
float P = p/100; // atmospheric pressure in hpa
float h, altitude; //height in meters

//h = (((float)pow((P0/P), 0.190223F) - 1.0F) * (T + 273.15F)) / 0.0065F;
// altitude = h;
altitude = 44330.0*(1.0-((pow((P/P0), (1.0/5.255)))));  //BOSCH code

## Some thoughts and finding on Altitude as Weather Enthusiasts might find interesting.

Mostly from Wiki pages

Calculates the altitude (in meters) from the specified atmospheric
pressure (in hPa), sea-level pressure (in hPa), and temperature (in �C)

@param seaLevel Sea-level pressure in hPa
@param atmospheric Atmospheric pressure in hPa
@param temp Temperature in degrees Celsius

National Institute of Standards and Technology (NIST), uses a temperature of 20 °C (293.15 K, 68 °F)
and an absolute pressure of 101.325 kPa (14.696 psi, 1 atm).

Standard sea level (SSL) (also known as sea level standard (SLS)) defines a set of conditions for
physical calculations. The term “standard sea level” is used to indicate that values of properties
are to be taken to be the same as those standard at sea level, and is done to define values for use in general calculations.

Atmospheric properties
At SSL some atmospheric properties are:[1]

Pressure, P = 101.325 kPa = 2116 lbf/ft2
Density, \rho = 1.225 kg/m3 = 0.002377 slug/ft3
Temperature, T = 288.16 K = 518.69 °R = 15.01 C

Pressure altimeter
Digital barometric pressure sensor for altitude measurement in consumer electronic applications
Altitude can be determined based on the measurement of atmospheric pressure. The greater the altitude the lower the pressure.
When a barometer is supplied with a nonlinear calibration so as to indicate altitude, the instrument is called a pressure
altimeter or barometric altimeter. A pressure altimeter is the altimeter found in most aircraft, and skydivers use wrist-mounted
versions for similar purposes. Hikers and mountain climbers use wrist-mounted or hand-held altimeters,

The calibration of an altimeter follows the equation

z=cT log(P0/P) where c is a constant, T is the absolute temperature, P is the pressure at altitude z, and Po is the pressure at sea level.
The constant c depends on the acceleration of gravity and the molar mass of the air.
However, one must be aware that this type of altimeter relies on “density altitude” and its readings can vary by hundreds of feet owing to a
sudden change in air pressure, such as from a cold front, without any actual change in altitude.

Or to put it another way. If you have a stationary – ie, in the house – weather station, and you suddenly notice your altitude is dramatically increasing, look out the window
there is probably a hurricane heading toward you…. low pressure = higher altitude. Otherwise, your recorded altitude will only vary according to local air pressure
variations, and generally, won’t change much

*/
/**************************************************************************/
/* Hyposometric formula: */
/* */
/* ((P0/P)^(1/5.257) - 1) * (T + 273.15) */
/* h = ------------------------------------- */
/* 0.0065 */
/* */
/* where: h = height (in meters) */
/* P0 = sea-level pressure (in hPa) */
/* P = atmospheric pressure (in hPa) */
/* T = temperature (in �C) */

const float P0 = 1013.25; // seaLevel,
ut = bmp180_get_value(BMP180_TEMPERATURE, 5);
t = (bmp180_get_temperature(ut));
up = bmp180_get_value(BMP180_PRESSURE_3, 26);
p = bmp180_get_pressure(up);

//float T = t/10; //current temperature. Test both, varies very little
float T = 15.01; //Temp standard for sealevel
float P = p/100; // atmospheric pressure in hpa
float h, altitude; //height in meters

h = (((float)pow((P0/P), 0.190223F) - 1.0F) * (T + 273.15F)) / 0.0065F;
altitude = h;

This is producing an Altitude that currently varies by about 5 meters at my place over a few days.

## as3935-lightning-sensor-board

https://www.tindie.com/products/TAUTIC/as3935-lightning-sensor-board/

## Converting and creating LaCrosse history.dat files

http://www.lissproductions.org/wuhu_manual/the-wuhu-software-manual/wuhu-history-data-file-format/

# WUHU History data file format

There are two historical files that WUHU maintains.

## “WUHU History.dat” is for internal use by WUHU.

It’s basically an image of the memory in case of power failure. It contains every reading your station has made in the past X hours where X is set in your general settings. You can specify up to 1 week of data that can be kept in memory. This setting effects how much data you can chart and display statistics for.

## “History.dat”

For use with other programs, always use the history.dat file output by WUHU.

Here is the format of the history.dat file that is output by WUHU. This matches the file format output by the Heavyweather Pro application. The HW Pro application supports WS-36XX stations. We use the HW Pro application to graph the history files output by WUHU.

This format was chosen because it contains more fields than the old HW Beta 2.0 format.

New records are added to the end of the file, there is no header or trailing record.

The [X] field denotes the number of bytes in the field.

1. 00 Double [8] Timestamp days from 12/30/1899 00:00:00 (GMT)
2. 08 Float [4] Abs Pressure hectopascals (millibars)
3. 12 Float [4] Relative Pressure hectopascals (millibars)
4. 16 Float [4] Wind Speed meters/second
5. 20 ULong [4] Wind Direction see below
6. 24 Float [4] Wind Gust meters/second
7. 28 Float [4] Total Rainfall millimeters
8. 32 Float [4] New Rainfall millimeters
9. 36 Float [4] Indoor Temp celsius
10. 40 Float [4] Outdoor Temp celsius
11. 44 Float [4] Indoor Humidity %
12. 48 Float [4] Outdoor Humidity %
13. 52 ULong [4] unknown – (Value is always 0)

Wind Direction

Wind direction is encoded as an integer between 0 and 15. To get the wind direction in degrees, multiply the value by 22.5. To get compass directions (moving clockwise) 0 is North, 1 is North-Northeast, 2 is Northeast, etc…

. 0 N
. 1 NNE
. 2 NE
. 3 ENE
. 4 E
. 5 ESE
. 6 SE
. 7 SSE
. 8 S
. 9 SSW
. 10 SW
. 11 WSW
. 12 W
. 13 WNW
. 14 NW
. 15 NNW

C data structure that mimics this format:

struct WeatherRecord3600 {
double fTimeStamp;
float fOutdoorAbsolutePressure;
float fOutdoorRelativePressure;
float fOutdoorWindSpeed;
unsigned long ulOutdoorWindDirection;
float fOutdoorWindGust;
float fOutdoorTotalRainfall;
float fOutdoorNewRainfall;
float fIndoorTemperature;
float fOutdoorTemperature;
float fIndoorHumidity;
float fOutdoorHumidity;
unsigned long ulUnknown;
};

The fTimeStamp is an odd field. It represents the days since a epoch time (12/30/1899 00:00:00) in UTC local time. The fractional part is used to obtain hours, minutes, and seconds. There are a few functions that are needed to convert back and forth between that timestamp format and the normal local time format, they are given below.

To convert from a normal time_t to this format you would use:

time_t t;
WeatherRecord3600 wr3600;

wr3600.fTimeStamp=Convert_time_t_To_DateTime2(ConvertLocalToUTCLocal(t));

To convert from this odd timestamp to a time_t:

t=ConvertUTCLocalToLocal(Convert_DateTime2_To_time_t(wr3600.fTimeStamp));

-----------------------

double Convert_time_t_To_DateTime2(time_t vtime_t)

{
double fresult;
// 25569 days from Saturday, December 30, 1899 to Sunday, January 1, 1970 (where time_t seconds counts from)
double fDeltaDays = 25569 + (vtime_t / (60 * 60 * 24));
double fFractionDays = (vtime_t % (60 * 60 * 24)) / (double)(60 * 60 * 24);
return (fresult);
}

//----

time_t Convert_DateTime2_To_time_t(double fTime)

{
return (time_t)((fTime - 25569.0) * 86400.0);
}

//----

time_t ConvertUTCLocalToLocal(time_t t)

{
// Aquire a local time and a gmt time.
struct tm tm_localtime;
memcpy(&tm_localtime,localtime(&t),sizeof(tm_localtime));

// Aquire UTC time.
struct tm tm_gmtime;
memcpy(&tm_gmtime,gmtime(&t),sizeof(tm_gmtime));

// Convert them back to time_t types.
time_t t1=mktime(&tm_localtime);
time_t t2=mktime(&tm_gmtime);

// Subtract from local time the difference between local time and gmt time.
t1 += (t2-t1);

// If daylight saving time in effect, subtract an hour.
if (tm_localtime.tm_isdst)
t1 -= 60*60;

return(t1);
}

//----

time_t ConvertLocalToUTCLocal(time_t t)

{
// Aquire a local time and a gmt time.
struct tm tm_localtime;
memcpy(&tm_localtime,localtime(&t),sizeof(tm_localtime));

// Aquire UTC time.
struct tm tm_gmtime;
memcpy(&tm_gmtime,gmtime(&t),sizeof(tm_gmtime));

// Convert them back to time_t types.
time_t t1=mktime(&tm_localtime);
time_t t2=mktime(&tm_gmtime);

// Subtract from local time the difference between local time and gmt time.
t1 -= (t2-t1);

// If daylight saving time in effect, add an hour.
if (tm_localtime.tm_isdst)
t1 += 60*60;

return(t1);
}

## A collection of interesting stuff

http://www.lissproductions.org/wuhu_manual/2011/11/29/diy-lightning-detectors/

and just in case it gets lost:

# DIY lightning Detectors

Hi Everyone!

I began writing this email to ask if anyone had come across a DIY lightning Detector that could be mapped on a PC.  I ended up with a list of great links that I thought I would share with you!

I did find Site Mate.  It’s a FREE program to look at personal Lightning Radar sites (NO hardware required)  http://www.lrsatx.com/sitemate_page.htm

Simple lightning detectors – (clicks or flashes a light for each storm strike)

* Schematics for Lightning Detectors
http://www.techlib.com/electronics/lightning.html#Egor
This is the same one that Dimitris just posted.  Here’s his link:
http://users.otenet.gr/~meteo/project_portable-lightning-detector.html

Note that in the “reader’s versions” of the first link, one of the readers used this circuit to send a pulse to the electronic trigger of his digital camera.  This allows him to release the shutter at precisely the same time that a strike hits.  This is a GREAT idea, as anyone who’s sat in the rain with a “bulb” exposure will attest!

* Hobby Boards Lightning Detector ($32.50 assembled) Also available as a kit. http://www.hobby-boards.com/catalog/product_info.php?cPath=22&products_id=1550 DIY Lightning Radar – (shows location of strikes on map using PC) Personally, I was looking for DIY hardware that could produce results similar to Strikestar : “StrikeStar allows multiple, standalone lightning detectors to form a real-time lightning locator network with much better positional accuracy.” Strikestar is “exclusively designed for the NexStorm software and Boltek hardware “. Needless to say, the Boltek hardware ($599) and software (\$135+)  package is very expensive.

I found two different DIY systems using two different approaches:

1. Lightning radar MDF (= magnetic-direction-finding system) by Frank Kooiman
2. TOA (= time-of-arrival system) by Egon Wanke

Gerald Iihninger’s lightning detection page gives a good overview of each system.
http://members.inode.at/576265/lr.htm

1. Lightning radar MDF (= magnetic-direction-finding system) by Frank Kooiman

Lightning detector system with:
* 2 crossed loop antenna’s tuned to 10 kHz
* 2 simple opAmp amplifiers with gain of 100 x
* a sound card of a 1 GHz PC
* a free program that detects the direction to the source
of the lightning strike with an accuracy of 1 degree.
This program can be used at different sites to calculate
the location of the lightning strike using a trangulation method.

This system was developed as a hobby alternative to  the existing commercial Boltek lightning detector. The  advantages of the lightning radar are the low cost (â‚¬40 and up) compared to the Boltek (â‚¬350 to â‚¬600 depending on the version), the extreme sensitivity of the system, and the possibility of joining the group system  via the internet. Where Boltek detectors can detect lightning up to a range of 500km, the LR (lightning radar) has a range of 2000 to 3000km over land and several thousand km over water (e.g. lightning in Florida, south America).

One disadvantage of the LR is that it is not a plug-and-play system and therefore requires some knowledge of electronics and familiarity with a soldering iron. In practice, this is not really a disadvantage since it means that you learn a lot more about the science of detecting lightning.

Wouldn’t ya know it, but at the end of my research, I found Dimitris’ site!  I guess he’s the resident expert here!

* Dimitris site!
* Amateur Lightning Detector and Radar by Frank kooiman
http://members.home.nl/fkooiman/lightning/index.htm
* Partner Ground Station “Lightning Radar Project”
o http://users.edpnet.be/DanielV37/Detecteur3/
* San Antonio, US site w/description of Site Mate (and link to it too)
o http://www.lrsatx.com
* Site Mate – FREE program to look at personal Lightning Radar sites
o http://www.lrsatx.com/sitemate_page.htm

2. TOA (= time-of-arrival system) by Egon Wanke
http://www.blitzortung.org/Webpages/index.php?mode=3&map=0&lang=en

This system uses a pre-amp circuit board, evaluation board, VLF antenna (ferrite rods or loop ant above), and GPS with one-pulse-per-second (1PPS) output & serial interface

3.  Commercial Systems

* Stormwise – systems and components (ferrite rods, Specialty Directional Antennas)
o http://www.stormwise.com
* Boktek – Stormtracker, LD-250, etc…
o http://www.boltek.com
* Strikestar – software for Boltek systems
o http://www.strikestarus.com

I hope this helps (and inspires) someone else!  Thanks to Dimitris for bringing up the subject!

Jon G.

===========================================

http://www.lissproductions.org/wuhu_manual/2011/11/26/lacrosse-specific-information-hardware/

# LaCrosse Specific Information – hardware

## LaCrosse Weather station manuals

Here is a list of PDF‘s for your LaCrosse Weather station(s):

http://site.ambientweatherstore.com/Manuals/

## Pinout for the RS-232 cable for the WS-2310/15/17

On RJ-11 Side (clip down, telephone style connector)
From left to right looking down on the connector
Color: Blue Brown Green White

On the 9 Pin D-Shell (PC Interface)
Signal: RTS RXD TXD DTR
Pin...: 7 2 3 4

So Blue -> Pin 7, Brown -> Pin 2 etc.

Note that there is NO connection
to the RS-232 ground (pin 5)!!!

=================================

# LaCrosse WS-2810 Full Startup/Reset Procedure

1. If the battery in the wind sensor has not charged in full sun (facing due south) for at least three days, do this first.
2. For this procedure, chances of success are better when the distances between the display unit and other sensors relative to the temp/humidity sensor are within 50 feet. Line-of-sight orientation and fewest possible intervening obstructions are desirable. Further separation can be done after start-up.
3. After solar battery is charged, go to the display unit and follow the following steps as, and in the order, listed.
4. Press and hold the Set button. Release when the display ‘blanks out’.
5. Repeatedly press and release Set button until the “rES off” message appears at bottom of screen.
6. While in the “rES Off” mode, press and release the Up Arrow to change the message to “rES On”. Then press the Set button (once).
7. A counter at the bottom of the page will now appear showing the value “127” and then it will begin counting down to “0”. When zero is reached, the display will show “rES dOnE”.
8. At this point, remove the batteries from the display.
9. While batteries are still out, press any key on the display at least 20 times. (This helps to drain any residual charges in the circuits)
10. Now remove the batteries from the rain sensor and the temp/humidity sensor.
11. Leave everything as-is for at least 10 minutes.
12. Now go to the wind sensor and press and release the reset button recessed in the little hole on the bottom of the wind sensor. Use the provided plastic ‘rod’ or a straightened paper clip. The switch is approximately 5/8” straight inside the case. The actuation requires very little pressure. If you do it carefully you can feel (but probably not hear) a soft switch movement.
13. Now replace the batteries in the rain sensor and temp/humidity sensor, followed by replacement of batteries in the display unit.
14. Leave everything as-is and display untouched for at least 10 minutes.
15. Everything should now be linked and the display should show connectivity and activity of all the sensors.
16. If something is still not functioning, you should call LaCrosse technical support.

=================

http://www.lissproductions.org/wuhu_manual/2011/11/26/lacrosse-23xx-wind-sensor-modification/

# Heavy Weather Version 2.0 Beta history.dat Format

For completeness sake, here is the HW Beta 2.0 format. As you can see the data set is not complete. There is for example no relative pressure. That would have to be determined by either reading the relative pressure from the console or by prompting the user for an offset from the abolute pressure.

NOTE: Of course, having this data means you now have the format of the original LaCrosse WS3600 history.dat file. So in theory, you could now rewrite your data file from the Arduino into the same format – and probably – maybe – WD would think a WS3600 was connected. It does after all read the history.dat file from the old Heavy Weather program, now long defunct, if it sees that you have selected WS3600, and probably other similar models? Not difficult to do. Select the WS3600 as your station type, tell WD where the history.dat file is, and presto …..

Indeed, you could feed the Arduino data into a SQLite or MySQL database, and do nearly any re-arranging you wanted. As well as keep historical data and so on.

HeavyWeather V2.0 beta La Crosse WS-2310 and WS-2315 weather stations

## Row Format

Each row of data is stored in 36 byte chunks starting from the beginning of the file (no header).

OFFSET TYPE NAME UNIT
00 ULong [4] unknown (Value is always 1)
04 ULong [4] Timestamp seconds from 1/1/1900 00:00:00 (GMT)
08 Float [4] Abs Pressure hectopascals (millibars)
12 Float [4] Wind Speed meters/second
16 ULong [4] Wind Direction see below
20 Float [4] Total Rainfall millimeters
24 Float [4] Indoor Temp Celsius
28 Float [4] Outdoor Temp Celsius
32 UWord [2] Indoor Humidity %
34 UWord [2] Outdoor Humidity %

## Trailer

At the end of the file is an additional 28 bytes providing information about the dataset as a whole.

OFFSET TYPE DESCRIPTION
00 ULong [4] unknown
04 Ulong [4] unknown (0)
08 Float [4] unknown (5.698)
12 ULong [4] unknown (0)
16 ULong [4] Number of rows
20 ULong [4] Timestamp of the first row of data
24 ULong [4] Timestamp of the last row of data

## Wind Direction

Wind direction is encoded as an integer between 0 and 15. To get the wind direction in degrees, multiply the value by 22.5. To get compass directions (moving clockwise) 0 is North, 1 is North-Northeast, 2 is Northeast, etc…

VALUE DIRECTION
0 N
1 NNE
2 NE
3 ENE
4 E
5 ESE
6 SE
7 SSE
8 S
9 SSW
10 SW
11 WSW
12 W
13 WNW
14 NW
15 NNW

## weather.c, the data logger for the Arduino+Weather Receiver WS3600 output

This code should compile without major problems on nearly anything. PC or Mac. See elsewhere for the full set of files, the sketch, and the XCode Project version.
This takes the output of the Sketch, on your PC/Mac, and saves it into a textfile called history.dat.
If debugging is ON, it also outputs it to the screen.

//
//  main.c
//  newport
//
//  Created by Robert Chalmers on 12/08/2014.
//

#include <sys/types.h> /* defines data types */
#include <sys/stat.h> /* defines the structure of the data returned by the functions fstat(), lstat(), and stat() */
#include <stdio.h>   /* Standard input/output definitions */
#include <string.h>  /* String function definitions */
#include <unistd.h>  /* UNIX standard function definitions */
#include <fcntl.h>   /* File control definitions */
#include <errno.h>   /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
#include <stdlib.h> /*This header defines several general purpose functions, including dynamic memory management   */

/*
Expected input: Each line comes at 30 second intervals

80,31,31,20.6,50,1018,SSW,6.5,W  ,3.1
80,27,27,20.6,50,-,W  ,4.2,W  ,1.7
80,27,27,20.6,50,-,W  ,3.9,W  ,1.7
80,27,27,20.8,50,-,WSW,2.9,W  ,2.2
80,27,27,20.8,49,-,W  ,4.1,WNW,2.5
80,31,31,20.8,50,1018,WNW,4.1,W  ,2.6

I have added the '-', which is normally blank if
rain bit is not set, which results in the 1018 currently.
*/

/* Configuration and other defines */
/* Unless you change the Weather Shield Sketch, leave this aas is. */
#define BAUDRATE B38400
/* change this definition for the correct port */
/* Where the data is stored */
#define DATASTORE "/Users/robert/weather-c/history.dat"
/* the usb-modem port ie. COM1, tty, cu and so on*/
#define PORT "/dev/cu.usbmodem14311"

//#define DEBUG // use for Non-XCode compiles. ie, Windows/xNix etc. If needed. On by default in XCode

char line[1024];
char msg[1024];
ssize_t  fd=0;
char buf[255];
char Path[1024];

int  ioctl(int d, unsigned long	request, ... );

ssize_t read(int fd, void *buf, size_t count);

int main(int argc, char **argv)
{
int fd;
long ret;
char c;
FILE * pFile;
#ifdef DEBUG
printf("Debug Mode on\n");
#endif

fd = open(PORT, O_RDWR );
#ifdef DEBUG
printf("...Serial port open - Return code : %d\n", fd);
#endif
if (-1 == fd)
{
perror(PORT); perror(msg); exit(-1);
}

struct termios theTermios;
memset(&theTermios, 0, sizeof(struct termios));
cfmakeraw(&theTermios);
cfsetspeed(&theTermios, 38400);
theTermios.c_cflag = CREAD | CLOCAL;	// turn on READ and ignore modem control lines
theTermios.c_cflag |= CS8;
theTermios.c_cc[VMIN] = 1;
theTermios.c_cc[VTIME] = 0;	// set to 10 if 1 sec timeout
ret = ioctl(fd, TIOCSETA, &theTermios);
#ifdef DEBUG
printf("opening /dev/cu.usbserial...\n");
#endif
fd = open("/dev/cu.usbmodem14311", O_RDONLY);
#ifdef DEBUG
printf("...Serial port open - Return code : %d\n", fd);
#endif
if (fd < 0)
{
printf("Erreur a l'ouverture de /dev/cu.usbserial - Code=%d\n", fd);
exit(1);
}
#ifdef DEBUG
printf("Serial port opened...\n");
#endif
/* a file opening test
pFile=fopen("/Users/robert/weather-c/alphabet.txt","wt");
for (c = 'A' ; c <= 'Z' ; c++) {
putc (c , pFile);
}
fclose (pFile);
*/
/* end of file test bit */
/* Use this once I have it going */

/* while (1) is an endless loop, unless errors develop */
pFile=fopen(DATASTORE,"wt");
while (1)
{
if (ret == 1) {
#ifdef DEBUG
putchar(c);
#endif
putc_unlocked (c , pFile);
fflush(pFile);
}
else
{