//
// 4. Februar 2009
//
// SeilingSensoreNode
// by Christoph Wertmann and Etienne Ribeiro
// at ETH Zurich CAAD
//
// MEASURE THE ANEOMETER (WINDSPEED) SENSOR
// Measures the poluses comming from the green line
//
//
// Pin
// green: Digital Input
// white: GND
// broun: 3V to 5V
//



//
// Pins

#define aneometerSignalIn 2
#define ledPin 13


//
// Var

boolean startupDone;


//
// Setup

void setup() {

        // LED (2 * blink)
        pinMode(ledPin, OUTPUT);
        digitalWrite(ledPin, HIGH);
        delay(200);
        digitalWrite(ledPin, LOW);
        delay(200);
        digitalWrite(ledPin, HIGH);


        // Serial
        Serial.begin(9600);


        // Pressure
        //  -> Operationmode: 0: High speed (15bit, 9Hz), 1: High resolution (17bit, 1.8Hz), 2: Ultra low power (15bit, 1Hz), [3 Low poser but triggerd (15bit to 17bit, 1.8Hz) not supported on Sparkfun Breakout]
        byte operationmode = 1;
        startupDone = true;
        if (scp1000_AppendSensor (-1, 10, 11, 12, 13, operationmode) == false) {

                Serial.println ("Failed to startup Pressure Sensor");
                scp1000_printStatus(scp1000_Read('s'));
                startupDone = false;

        }

}




//
// Loop

void loop() {

        //
        // Aneometer

        // Mesure
        // (get Hz)
        int HzCounter = Aneo_getSpeedHZ (aneometerSignalIn, 100);
        // (Parse to m/s and km/h)
        double ms = Aneo_parseMS (HzCounter);
        double kmh = Aneo_parseKMH (HzCounter);
        // (get average Hz)
        int HzAverage = Aneo_getAverage ();
        double kmhAverage = Aneo_parseKMH (HzAverage);


        /*
        // Print
        if (HzCounter > 0) {

        // (Hz)
        Serial.print(HzCounter);
        Serial.print(" Hz sec.");
        Serial.print("       ");
        // (m/s)
        Serial.print((int)ms);
        Serial.print(".");
        Serial.print( int(abs((ms - (int)ms) * 100)) );
        Serial.print(" m/s");
        Serial.print("       ");
        // (km/h)
        Serial.print((int)kmh);
        Serial.print(".");
        Serial.print( int(abs((kmh - (int)kmh) * 100)) );
        Serial.print(" km/h");
        Serial.print("       ");
        //
        Serial.print("Average: ");
        Serial.print((int)kmhAverage);
        Serial.print(".");
        Serial.print( int(abs((kmhAverage - (int)kmhAverage) * 100)) );
        Serial.print(" km/h");
        //
        Serial.println("");

}
        */

        //
        // Pressure

        if (startupDone) {

                // Temperature
                int temp1;
                int temp2;
                scp1000_parseDegrees(scp1000_Read('t'), &temp1, &temp2);
                //
                Serial.print ("TEMPERATURE: ");
                Serial.print (temp1, DEC);
                Serial.print (".");
                Serial.print (temp2, DEC);
                Serial.print (" Grad C   ");
                // Pressure
                long pressure = scp1000_parsePa(scp1000_Read('p'));
                Serial.print ("PRESSURE: ");
                Serial.print (pressure);
                Serial.print (" Pa    ");
                // Hight
                Serial.print ("Hight: ");
                Serial.print (scp1000_getHightCM (pressure));
                Serial.print ("");
                Serial.println ("");


                // Status
                scp1000_printStatus(scp1000_Read('s'));
                Serial.println ("");

        }


        // Take a break
        delay(100);

}

This website has been archived and is no longer maintained.