Hi everyone,
I have been trying to measure flight time of a 40khz burst. I have two SRF02 sensors each connected to a serial line of my arduino mega, I have one that sends the burst (I see the led lighting up) and the second one which should be waiting for the burst.
The problem is that I always read 0 from the receiving sensor instead of the time passed from when I started the fake ranging and when he got the burst.
Anyone ever used these sensors in fake ranging mode?
Here is also my code:
void setup()
{
Serial.begin(115200);
Serial1.begin(9600);
Serial3.begin(9600);
}void loop()
{Serial1.print(0x0, BYTE);//address of sonar
Serial1.print(0x58, BYTE);//enter fake ranging which just waits for a 40khz burst
delay(70);
Serial3.print(0x0, BYTE);
Serial3.print(0x5C, BYTE);//send the burst
delay(3000);
Serial1.print(0x0, BYTE);
Serial1.print(0x5E, BYTE);//get the result of the fake ranging
while(Serial1.available()<2);
while(Serial1.available()){
//Serial.print("\n");
Serial.print(Serial1.read(),DEC);
}
Serial.print("\n");
delay(1000);}