Im new and i can´t upload attachments so i paste the code here
// declare a threshold value on top of the sketch
int threshold = 500; // change value to suit
int hallSensor_pin = A0; //function used to define the pin used
int hallSensorValue = analogRead(hallSensor_pin);
//int hallSensorStatus[10];
//int addcount(int);
// --- Const---
//const float pi = 3.14159265359; //PI number
//int period = 5000; //Measurement time (milliseconds)
int delaytime = 2000; //Interval between samples (milliseconds)
int radius = 0.155; //Anemometer radius (metros)/ 155 mm
// --- Global ---
unsigned int Sample = 0; //Stores the number of samples
unsigned int counter = 0; //counter for the sensor
unsigned int RPM = 0; //rpm
float speedwind = 0; //Wind speed (m/s)
float windspeed = 0; //Wind speed (km/h)
unsigned long tempo;
void setup()
{
Serial.begin(19200);
}
void loop()
{
Serial.println("");
Serial.print("VALOR HALLSENSOR:");
Serial.println(hallSensorValue);
Sample++;
Serial.print(Sample);
Serial.print(": Start reading...");
windvelocity();
Serial.println(" done.");
Serial.print("Counter: ");
Serial.print(counter);
Serial.print("; RPM: ");
RPMcalc();
Serial.print(RPM);
Serial.print("; Wind speed: ");
//*****************************************************************
//print m/s
WindSpeed();
Serial.print(windspeed);
Serial.print(" [m/s] ");
//*****************************************************************
//print km/h
SpeedWind();
Serial.print(speedwind);
Serial.print(" [km/h] ");
Serial.println();
delay(delaytime);
} //end setup
//Function to measure wind speed
void windvelocity()
{
speedwind = 0;
windspeed = 0;
//counter = 0;
//attachInterrupt(A0, addCount, RISING);
addCount();
/*
unsigned long millis();
long startTime = millis();
while (millis() < startTime + period) {}
*/
}
void addCount()
{
if (hallSensorValue <= 900)
{
counter++;
}
}
//Calculate revolutions per minute (RPM)
void RPMcalc()
{
tempo = millis();
do {
RPM = counter();
}while (tempo < 5001);
}
//Calculates wind speed in m/s
void WindSpeed()
{
windspeed = 0,9738937226 * RPM;
} //end WindSpeed
//Calculates wind speed in km/h
void SpeedWind()
{
speedwind = windspeed * 3.6;
} //end SpeedWind
/*
//Increment counter
void addcount() {
counter++;
}
*/