Dear Forum,
I need to trigger one ultrasound, through RFM69, to be detected by another one. Each setup were tested successfully by itself. Both ultrasound works independent from each other.
Then when circuits were triggered through monitoring, but no detection of ultrasound. I wonder, perhaps I need to delay the detection for sometime. But tried various delay, still no success. Can someone advise?
This is triggering code:
void loop() {
// Should be a message for us now
uint8_t buf[RF69_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (rf69.recv(buf, &len))
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10); //Original code only 10, I have tried from 50, 100,300
digitalWrite(trigPin, LOW);
Serial.println("Triggered");
Blink(LED,3);
}
else
{
Serial.println("recv failed");
}
}
This is the detection code:
void loop() {
long duration, distance;
rf69.send(data, sizeof(data));
rf69.waitPacketSent();
delay(200); //I have tried to change this variable, also without success.
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
Serial.print(distance);
Serial.println(" cm");
Blink(LED,3);
delay(250);
}