Airspeed in Arduino

Hi there. I’m doing a project where I need to use 2 ultrasonic distance sensors to calculate Airspeed and trigger a buzzer whenever it falls to a lower airspeed or no air at all. I’ve been wrapping my head around the formula for the actual airspeed, but I can’t seem to translate it into arduino and make it work with 2 sensors. Any inputs as to how to do this would be helpful. Thanks.
I am attaching 2 pictures: one of them is of the sensors in tinkercad, the other one is the picture of the study I found. I am lost in the code part for this.

I found a simplified formula that can be used too, and it was this: AirSpeed=(0.3/2)((pingSensor1/1000000-pingSensor2/1000000)/(pingSensor1/1000000pingSensor2/1000000));

This is what I have so far, which is not right:

void Motor_Sensor()
{

//FROM HERE -->This moves the motor between 10 and 100 cm.
long duration;
int cm;
int revSpeed;
//cm = Ping4Pin(triggerPin, echoPin, duration);
float pingSensorA;
float pingSensorB;
float Airspeed;

serial.print(“Sensor A-B:”);
serial.print(readSensorA);
delay(1000);
serial.print(“Sensor B-A:”)
serial.print(readSensorB);

//Change L for size of tube
Airspeed=(L/2)((readSensorA+readSensorB)/(readSensorAreadSensorB));
serial.print(“Air Flow=”);
serial.print(Airspeed);
serial.print(“m/s”);
delay(1000);

if (Airspeed > 0 && Airspeed < 100)
{ // if the object is within range (change this to suit)
revSpeed = map(Airspeed, 10, 100, 50, 255); // converts data range from sensor
// from 5 → 100 to 50 → 255
analogWrite(motorPin, revSpeed); // drive the motor at the converted speed
delay(500);
digitalWrite(10, HIGH);
digitalWrite(8, LOW);
noTone(0);
}

else
{
analogWrite(motorPin, 0); // else set the motor to zero
//digitalWrite(motorPin, LOW);
revSpeed = 0;
digitalWrite(10, LOW);
digitalWrite(8, HIGH);
tone(13, 659, 1000);
lcd.setCursor(1,0);
lcd.print(“No Airflow!”);
}

delay(10); // DELAY 10 MILISEGUNDOS

sensors1.PNG

Your formula cannot work, it's missing the angle at which the sensors are tilted against the flow direction.

The angle to airflow is 0, so
2cos(0) = 2

0 == parallel to the airflow? How should that work?

zwieblum:
0 == parallel to the airflow? How should that work?

Have you used a unit circle before?

Anyway, why use ultrasonic for airspeed? Usually pitot tubes and differential pressure sensors are used for airspeed sensing:

Because based on that study, you can use distance sensors to calculate airspeed (or in this case airflow). I know that you can just use pressure sensors, but what makes it a challenge was trying to figure out how to do it with 2 sensors. I am still having problems with the formula, though.
I actually changed the whole code, but I still have problems with the formula. The formula that I need is FORMULA: (L/2cos(x))((Tup-Tdown)/(Tup*Tdown))

I did cos(0), with L being the distance of .03 (meters).

So what I did was float AirSpeed=(0.3/2)((cm/10000-cm1/10000)/(cm/10000cm1/10000));

With cm as my T up and cm1 as my Tdown. But it still gives me a negative air flow on tinkercad. I need help with the formula, please!

Thanks

The only way "AirSpeed" can be negative is if "cm1" > "cm". That's a start.

You have mysterious variables that are not defined anywhere else in your code snippet. My guess is that they're globals, but you need to show us your entire code (IN TAGS).