Ultra sonic sensor

Hi guys ! I am New to arduino world and i need some help! I have a project which includes comuniction betwen 2 ultrasonic sensors ( one will only use triger and the other one just echo) when the 2 sensor receive the signal from the first one i want a led to blink. I am using 2 diferent boards because i want to stay at the distance . I have been surfing on the Internet and I found nothing useful so i need help espeacealy with the code ! Thx guys ! I am using HC-SR04 SENSORS.

You have to be more specific on how you see it done. Are there separate Arduinos, ping-ing each other, or there are wires from all these sensors going into one arduino?

In order to receive an echo from HC-SR04 without having it sendind a beep, you have to synchronise them somehow

2 diferent boards , one sensor going to arduino uno and another to arduino mega.

The simplest way to disable a ping is to remove or scratch on the board the connection to the transmitter piezo, (let's say on uno) and then to synchronize uno and mega to send a ping at the same time.
Assuming they are position in range to each other.
Then the mega will report an echo that will tell it how far ahead is an obstacle, and the uno will hopefully report half the distance between the mega's and uno's own ultrasonic transcievers.

How do you synchronize the two - that can be tricky, you may use either a simple wire between the two and problem is solved, or some radio/infrared signal but expect some tuning work to compensate for delays.

How does i synchronize ?

I dont want to connect them with wires

then wireless should be.

Are you using the ultrasonics as the communication link? Or do you also have radio (wireless, 433MHz, or something)?

I think that i have to explain all again.i am using two ultrasonic sensors (lets call them A and B) . What i want to do îs to use sensor A to Send a signal to sensor B (all without wires and without any spare Module as bloothoth or wireless) . When sensor B receive the signal i want to know that ( for exemple în serial monitor when sensor receive nothing it will apear * 0 * and when it receive smt it will apear 1 ). My Problems are espeacealy with the code. Thx for the future posts that will help me...

Sergane1313:
I think that i have to explain all again.i am using two ultrasonic sensors (lets call them A and B) . What i want to do îs to use sensor A to Send a signal to sensor B (all without wires and without any spare Module as bloothoth or wireless) . When sensor B receive the signal i want to know that ( for exemple în serial monitor when sensor receive nothing it will apear * 0 * and when it receive smt it will apear 1 ). My Problems are espeacealy with the code. Thx for the future posts that will help me...

The problem is not the code, the problem is in how ultrasonic sensor works:

  1. Arduino sends an electric signal, the sensor sends a ping, receives an echo and
    2 then responds with another echo signal to the arduino.
    3 In order to know the distance arduino counts the time between fist and second signal.

if 1. doesn't happen, then steps 2 and 3 won't happen regardless what other ultrasonic sunds in the room are.

The only way you can get what you want with these sensors is to synchronize the two arduinos to send pings at the same time, that requires one of the transmitter of the two to be muted and requires a way of communicating between arduinos other than ultrasonic sensors themselves.

Regular HC-SR04 has it's own uCPU on-board, this is why 1-2-3 procedure described above. The only way I could see to make it works as a receiver is to solder a wire directly to comparator output, bypassing uCPU. Look here for drawings, I think collector Q1 is what you need.
http://uglyduck.ath.cx/HC-SR04E/HC-SR04.svgz

Thx for the Post i will try this tommorow...

ThE diagram not seems to match with my boards. After some research i have Discover ed that my sensors are on the old style.

https://cdn.hackaday.io
Link to my schematic...

Sergane1313:
https://cdn.hackaday.io
Link to my schematic...

403 Forbidden

//www.google.ro/search?q=schematic+for+hc-sr04&rlz=1C1VFKB_enRO625RO625&espv=2&biw=1600&bih=799&source=lnms&tbm=isch&sa=X&ved=0ahUKEwi_t_2zjvXNAhWGAxoKHf8BAG8Q_AUIBigB#tbm=isch&q=schematic+for+hc-sr04+old+&imgrc=KzgdcPYkoINh7M%3A

schematic


https://www.google.ro/search?q=schematic+for+hc-sr04&rlz=1C1VFKB_enRO625RO625&espv=2&biw=1600&bih=799&source=lnms&tbm=isch&sa=X&ved=0ahUKEwi_t_2zjvXNAhWGAxoKHf8BAG8Q_AUIBigB#tbm=isch&q=schematic+for+hc-sr04+old+&imgrc=tBgbD58U-ZrImM%3A

how it looks like

In this blog

you can find an application to support multiple ultrasonic sensors

To use this setup with your own application, you need Arduino Mega and a library for ultrasonic sensor array. The library is described in this blog

Cheers, Ollie

i did not find a solution finally , so i am hoping to receive more information in the future , i am patience for the moment cause i am working at another project...
thx for everything !!!

Just use both sensors in normal way with any library and close TR on one sensor and R on another.
I use my own device to measure distance without library with code like this:

digitalWrite (trigPin, LOW);
    delayMicroseconds (2);
    digitalWrite (trigPin, HIGH);
    delayMicroseconds (10);
    digitalWrite (trigPin, LOW);
    dTime = pulseIn (echoPin, HIGH, waitEcho);

And I have the problem when I use two my devices together because one device is activating another :slight_smile:

CAN YOU WRITE A FULL PROGRAM THAT DOES THE FOLLOWING :
WHEN THE SENSOR 1 RECEIVE SIGNAL FROM SENSOR 2 IN THE SERIAL MONITOR WILL APEAR "1" AND IF NOT RECEIV SIGNAL SERIAL MONITOR WILL DISPLAY "0" ;
THX A LOT .... !!