Ping sensor used as Air flow device

Based on youtube video https://youtu.be/BNTSSxzm1GM
Instead of using 2 ping sensors separately why not ping both at the same time and calculate the difference between falling echo pins which is when the sound from the opposite ping sensor was received.
Since both sensors sent the same pulse at the same time the only possible dilemma is cancellation of sound from the other transmitter but I believe this would be negligible.
advantages would be that both ping sensors would not need to be dismantled to achieve results.
What do you think YouTube ItMightBeWorse?

#define DelayBetweenPings 50 // it works to about 5 milliseconds between pings

volatile  unsigned long DeltaT;
volatile  unsigned long edgeTime;
volatile bool PingSent;

unsigned long DT;

void PintTimer( )
{
  uint8_t pin2, pin3;
  unsigned long cTime;      // Current time
  cTime = micros();         // micros() return a uint32_t
  pin2 = PIND >> 2 & 1;     // Quickly get the state of  pin 3
  pin3 = PIND >> 3 & 1;     // Quickly get the state of  pin 3
  if ((pin2 == HIGH) || (pin3 == HIGH)) {
    edgeTime = cTime; //Caught the frist pulse but not the second
    return;
  } else { // Bolth pulses recieved
    DeltaT = cTime - edgeTime; // Calculate the change in time
    PingSent = false;
  }
}

void PingTrigger(int Pin)
{
  digitalWrite(Pin, LOW);
  delayMicroseconds(1);
  digitalWrite(Pin, HIGH); // Trigger another pulse
  delayMicroseconds(10);
  digitalWrite(Pin, LOW);
  PingSent = true;
}

void PingIt()
{

  static unsigned long PingTimer;
  if ((unsigned long)(millis() - PingTimer) >= DelayBetweenPings) {
    PingTimer = millis();
    // set interrupts flag
    Serial.println(DT);
    PingTrigger(4); // Send another ping
  }

  static unsigned long SpamTimer;
  if (!PingSent & (unsigned long)(millis() - SpamTimer) >= 100) {
    SpamTimer = millis();
    unsigned long DT;
    cli ();         // clear interrupts flag
    DT = DeltaT;
    sei ();
    // Calculate the Air Velocity here!
    char S[20];
    Serial.print(dtostrf(DT, 6, 1, S));
    Serial.println();
  }
}

void setup()
{
  Serial.begin(115200);
  Serial.println("AirSpeed Test");
  pinMode(3, INPUT);
  pinMode(4, OUTPUT);
  attachInterrupt(digitalPinToInterrupt(2), PintTimer, FALLING);
  attachInterrupt(digitalPinToInterrupt(3), PintTimer, FALLING);
}

void loop()
{
  PingIt(); // Manage ping data
}

Z (Arc Robotics)

I recurved a message about simultaneous ping recurve.
The code accounts for a simultaneous receive the interrupt trigger of either pin runs the same code which reads both pins if both pins are low when the initial ping is received then the sound reached the sensor within the minimum resolution, differential time will be out of range because the start trigger never occurred and with additional code we can set the air speed to zero.
Z

Hi,
Is there a schematic diagram?

Thanks.

Most ping sensors don't care if you didn't ping them. They listen to all pings. So send a pulse from 1 and start listening on 2. You 'dismantle' them in software, not hardware.

I would not be listening on both simultaneously in case you get echoes - sensor 2 may hear a bounce from its own ping before it hears the desired pulse from sensor 1. But that is highly dependent on your physical layout, air duct or whatever.

With two facing each other, you can also measure the temperature of the air and correct for that in your software.