How to talk from one HC-SR04 ultrasonic sensor to another?

I would like to send a signal from one HC-SR04 and receive it on a second HC-SR04. I tried to write this program but it always prints 0 cm. The code is the same as we would use for an echo ping. The only difference is that I trigger the trigger pin on the first HC-SR04 and listen on the echo pin on the second HC-SR04.

I think that this might be the problem:

RiGonz: ... it seems to me that the receiver needs the activation done by the emitter sending the ping, on the same module: ...

Can anyone help?

There was a suitcase tracking thing, where the first micro triggered its ultrasonic to send, AND using xbee or something, wirelessly triggered the other end to listen.

But I wonder if this is an XY Problem?

I tried to write this program

Can anyone else see this program?

AWOL: Can anyone else see this program?

const int trigPin = 2; const int echoPin = 4;

void setup() { Serial.begin(9600); pinMode(trigPin, OUTPUT); //triger pin on sensor 1 pinMode(echoPin, INPUT); //echo pin on sensor two }

void loop() { // establish variables for duration of the ping, // and the distance result in centimeters: long duration, cm;

// Sensor 1 is triggered by a HIGH pulse of 10 or more microseconds. // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:

digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW);

// Read the signal from the sensor 1 on sensor 2 (a HIGH pulse)

duration = pulseIn(echoPin, HIGH);

// convert the time into a distance cm = microsecondsToCentimeters(duration);

Serial.print(cm); //PROBLEM THIS IS ALWAYS 0 Serial.print("cm"); Serial.println();

delay(100); }

long microsecondsToCentimeters(long microseconds) { // The speed of sound is 340 m/s or 29 microseconds per centimeter. return microseconds / 29; }

The HC-SR04 has a built in microprocessor and cannot be used in the way you are attempting.

jremington: The HC-SR04 has a built in microprocessor and cannot be used in the way you are attempting.

do you think desoldering might be an option to achieve what i am after? If not is there something you could recommend as an alternative to HC-SR04 ?

Here a link who explain how works "one" of the different HC-SR04 http://uglyduck.ath.cx/ep/archive/2014/01/Making_a_better_HC_SR04_Echo_Locator.html

Article is dated january 14. I buy some units on Ebay (1$/€ per unit) Feb 2015 there is always the same "cut and paste" : filter is always centered to 20 kHz.

I have not succeeded to discover the micro program, I do not know what he does. Micro does not directly manage the length of the burst. The burst is not controlled by timers but by powering on/off the Max232. This can not work properly: the charge pumps that generates the + 10V and -10V can not be activate in a such short "ON" time. I checked with an oscilloscope: the output level of the Max232 is effectively only 0 / + 5V -> it is useless.

If we add the loss of gain due of the filter mis-centered at 20kHz and the output level of 0 / + 5V instead of -10V/-10V, total loss of gain is about 40 20 dB , in pure number attenuation of 100 10 !

The amplifier used has an average Ft of only 700kHz . With a gain of 10, bandwidth will be only 70 kHz. Do not forget that the bandwidth is defined as the frequency which corresponds to a gain divided by 2! With 4 cascaded amplifiers, bandwidth of the whole chain is less than 40 kHz !

As the LM324 is not rail-to-rail, last stage of LM324 associated with transistor Q1 is used to make a pseudo open collector comparator. The schematic is very unstable and enter too easily into self-oscillation .

[u]Nevertheless,[/u] [u]we must recognize that this module[/u] [u]works[/u]. But change nothing, otherwise nothing will work.

If doing some electronics do not put you off, you would have interest to make a board with an atmega328 (like nano or mini-pro), amplifiers with 3 Mhz Ft like TL082N (10 for few $/€ on Ebay) and use a real comparator (like LM393) to interface with the micro. US microphone can be directly controlled with an ATmega328P.

Here a link to do a burst à 40 38 kHz: Modulating a 38 kHz carrier with a 500 Hz signal http://www.gammon.com.au/forum/?id=11504