Welcome to Synthiam!

Program robots using technologies created by industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation, and artificial intelligence easy.

Get Started
Asked — Edited
Resolved Resolved by DJ Sures!

Will The 3 Wire Grove - Ultrasonic Distance Sensor Work On The Arduino Mega


I am trying to free up many digital ports on my arduino mega and seen these Grove - Ultrasonic Distance Sensor.  Will they work on my arduino mega?

Thank you in advance.

Edited:  link to Grove - Ultrasonic Distance Sensor

Related Hardware Arduino Due/Mega


Upgrade to ARC Pro

Experience early access to the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

#1   — Edited
Looks like it should. Specify the trigger and echo to be on the same port
Thanks DJ.  I’m going to order one to test.
#3   — Edited
Hi DJ,

I just tried to use the Grove - Ultrasonic Distance Sensor
 and does not work.  I used the trigger and echo to be on the same port .  I have the version 10-3-21 software.  Do you think you could take a look to see if you can get these working the mega.  I have not tried the EZB 4 1/2 yet.
EDITED: It does not work on the EZB 4 1/2 either.
Edited again:  here’s a copy of Q/A..
Can we connect mulitule ultrasonic to one arduino?

A4: Yes, Here is the example, one sensor is connected to D2 and other to D3.

#include "Ultrasonic.h"

Ultrasonic ultrasonic1(2);
Ultrasonic ultrasonic2(3);
void setup()
void loop()
long RangeInCentimeters1;
long RangeInCentimeters2;

RangeInCentimeters1 = ultrasonic1.MeasureInCentimeters(); // two measurements should keep an interval
Serial.println(" cm");

RangeInCentimeters2 = ultrasonic2.MeasureInCentimeters(); // two measurements should keep an interval
Serial.println(" cm");


Thank you in advance.
Try with an ez-robot ez-b first. Because maybe the sensor isn't working. I don't see a reason the sensor shouldn't work for you. The one-wire sensors I have worked fine with the mega. Are you using a digital port? You can't use a servo port. It has to be a digital port.

Remember, a D2 on the EZB Arduino Mega is pin #4. See the mapping here: https://synthiam.com/Support/Hardware/Arduino-Due-Mega

Or press one of the two buttons for viewing the board manual.
User-inserted image


Digital Ports
ARC has the ability to select up to 24 Digital ports per EZB. Digital ports also operate as bit-bang serial/uart (transmit only). The MEGA has 21 Digital capable ports mapped to the ARC Digital ports starting from D0 to D20...

(ARC Left, Arduino Right)
D0 = 2,
D1 = 3,
D2 = 4,
D3 = 5,
D4 = 6,
D5 = 7,
D6 = 8,
D7 = 9,
D8 = 10,
D9 = 11,
D10 = 12,
D11 = 13,
D12 = 44,
D13 = 45,
D14 = 46,
D15 = 62,
D16 = 63,
D17 = 64,
D18 = 65,
D19 = 66,
D20 = 67
If it isn't working for you on an EZ-Robot EZB, then...

1) Is it getting enough power?

2) Is it wired correctly?

3) Are the correct pins selected?

4) Is it broken?

Those ping sensors are incredibly popular with Synthiam users - I can't see how it isn't working hmmm
PS, i added a slight change to the mega firmware that "might" help - it should at least provide higher accuracy as well. Get it from the Arduino Mega hardware page here: https://synthiam.com/Support/Hardware/Arduino-Due-Mega

But if that doesn't work - i'd look into my suggestions above. It might be power-related. These sensors are generally 5v and the Arduino and EZ-B are 3.3v

So you'd need a separate power supply or voltage regulator for ultrasonic sensors like that. Make sure they have common grounds.
#7   — Edited
You are the man! @DJ,

your firmware was the fix.  They are now working, I testEd 3 of them all good.

BTY, you may have dated the firmware date on purpose or accident. It’s dated November 11, 2021

Thanks again you’re the best!
Hi Merme,

Have you ever used the Waterproof Ultrasonic Distance Sensors?

They work like the HC-SR04 but are good for outside adventures.

Purchased on Amazon

The JSN-SR04T is sensor in that it comes as a separate printed circuit board and sensor unit. The sensor, which is a single device that acts as both transmitter and receiver, is attached to the PCB using a 2-meter cable.

The A02YYUW is an ultrasonic distance sensor that some resemblance to the HC-SR04 in that it has a separate receiver and transmitter.

I tested both on a Arduino, the A02YYUW works better at closer distance for accurate readings

The JSN-SR04T’s default starts at about a foot distance for accurate readings

Hi EzAn.

I have not used or tried using the Waterproof Ultrasonic Distance Sensors.  I only use the 3 Wire Grove - Ultrasonic Distance Sensor.  

BTY, the 3 Wire Grove - Ultrasonic Distance Sensor does not fix any of the standard 4 wire HC-SR0 Mounting brackets,boards.  I have not been able to find any that fit the 3 Wire Grove - Ultrasonic Distance Sensor.  I have to hot glue them to the Mounting brackets,boards.

I haven’t really played with them yet I’ve been doing other things that need done first.

Take care and talk to you later.