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