Hello all,
I am in a new project that inclueds the A3423 to measure speed and wind speed.
For that i took the small turbine from an portable windmeter.
The sistem is already working about measureing the speed, now the problem is the direction
In the datasheet it says the direction pin is high or low.
Tried to use an digital input but the voltage in that pin just drops a bit so could not detect the diference.
Changing statagy and using the analog 0 pin but that did not work to.
Is there any other ideias?
Is a photo of the prototype.
Is also including an DS18B20 to temperature measure.
// Constants definitions
const float pi = 3.14159265; // pi number
int period = 10000; // Measurement period (miliseconds)
int delaytime = 10000; // Time between samples (miliseconds)
int radio = 6
// Variable definitions
unsigned int Sample = 0; // Sample number
unsigned int counter = 0; // B/W counter for sensor
unsigned int RPM = 0; // Revolutions per minute
float speedwind = 0; // Wind speed (m/s)
void setup()
{
// Set the pins
pinMode(3, INPUT);
digitalWrite(3, HIGH);
pinMode(13, OUTPUT);
pinMode(5, INPUT);
// sets the serial port to 115200
Serial.begin(115200);
}
void loop()
{
Sample++;
Serial.print(Sample);
Serial.print(": Start measurement...");
windvelocity();
Serial.println(" finished.");
Serial.print("Counter: ");
Serial.print(counter);
Serial.print("; RPM: ");
RPMcalc();
Serial.print(RPM);
Serial.print("; Wind speed: ");
WindSpeed();
Serial.print(speedwind);
Serial.print(" [m/s] ");
Serial.println();
if (counter > 10){
if (digitalRead(5)== LOW)
{
Serial.print(" IN ");
}
else
{
Serial.print("OUT ");
}
}
else
{
Serial.print(" No Wind ");
}
delay(10000);
}
// Measure wind speed
void windvelocity(){
speedwind = 0;
counter = 0;
digitalWrite(Led, HIGH);
attachInterrupt(1
, addcount, CHANGE);
unsigned long millis();
long startTime = millis();
while(millis() < startTime + period) {
}
digitalWrite(Led, LOW);
detachInterrupt(1);
}
void RPMcalc(){
RPM=((counter/2)*60)/(period/1000); // Calculate revolutions per minute (RPM)
}
void WindSpeed(){
speedwind = ((2 * pi * radio * RPM)/60) / 1000;
}
void addcount(){
counter++;
}
Thanks,
Timóteo
