Using three HC-SR04 sensors in tandem

Hello, I'm new to this forum, but I've used a lot of threads for previous projects, so I figured it was time to join. I've been struggling with this particular part of my science fair project for about a month now.

I'm trying to measure the distance between two HC-SR04 sensors (stationary relative to each other), and a single HC-SR04 sensor which is placed on a moving target. For clarification, the two sensors will be referred to as the "base sensors" and the moving sensor will be referred to as the "target". I've removed the transmitters from the base sensors, and the receiver from the target, so that I don't get soundwaves echoed from any random object, but rather, all soundwaves received by the base sensors will have originated from the target. Of course, I soldered a plain wire where the removed transducers used to be, so as to keep the internal circuit closed.

[important note: I am using the NewPing library]

The purpose of this is to obtain two distances and then use trigonometry to calculate the angle of the target relative to the midpoint between the two base sensors. The trigonometry part works, and I've been able to accurately measure the distance between the two sensors and a normal solid object. However, I can't get the target sensor itself to interact very well with the base sensors.

The target sensor is controlled analogously using a 555 timer astable circuit. An oscilloscope shows that this circuit works and outputs a pulse of 10 microseconds, which according to the datasheet is required to trigger the HC-SR04. In theory, the target sensor should be transmitting every 326 microseconds or so, basically almost constantly, like a beacon.

Unfortunately, the base sensors don't seem to be receiving any signals from this "beacon." The Arduino (Uno) gives the trigger pin a 10 microsecond HIGH pulse, which causes it to "transmit" a signal (it only thinks it's transmitting, because as mentioned above, I removed the transmitter). Once it does, the echo pin starts a HIGH pulse, which is terminated when it receives a signal on the receiver. The length of this HIGH pulse is measured by the Arduino, which allows it to calculate the distance. According to the HC-SR04 datasheet, it waits for up to 35 milliseconds before timing out. Obviously, that's more than enough time to receive a signal from the target.

Sorry for the extremely long explanation. I've spent hours and hours researching, and I still can't figure out what I'm doing wrong!!! Please help!!

(the code attached below does not include any of the trig stuff)

#include <NewPing.h>

const short int leftTrigpin = 13;
const short int leftEchopin = 12;  
const short int rightTrigpin = 11;
const short int rightEchopin = 10; 
const int maxDist = 300; // Maximum distance to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.

int sideB1 = 36;  //dist between sensors
int sideB2 = 18;  //1/2 dist

const float leftThreshold = 1.48;   //  below which PAL will turn left
const float rightThreshold = 1.66;  //  above which PAL will turn right
  
NewPing sonar[2] = {                            //array with 3 elements 
  NewPing(rightTrigpin, rightEchopin, maxDist), //array element 0. sets Trigpin to OUTPUT, Echopin to INPUT, and sets maxDist
  NewPing(leftTrigpin, leftEchopin, maxDist),   //array element 1
};

void setup() {
  Serial.begin(115200);
}

void loop() {          
  int sideA = sonar[0].ping(); 
  int sideC1 = sonar[1].ping();
  float rightrealDist = sideA * 2.00;  //to account for pulse not being originated from input PINGS
  float leftrealDist = sideC1 * 2.00;
  
  Serial.print("Right Distance = ");
  Serial.println(rightrealDist);
  Serial.print("Left Distance = ");
  Serial.println(leftrealDist);
  
  delayMicroseconds(326);

}

I can't see how that "idea" could possibly work. You have no timing reference to measure the mobile's received pulse against.

paolofermin88:
Oh, I just realized I probably should've put this question in the "Sensors" forum, oooops. So sorry about that. I'm going to post it there, so anyone who has an answer please reply there.

Next time use Report to Moderator to ask a moderator to move the thread.