Asked — Edited
Resolved Resolved by DJ Sures!

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

Hello,

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 https://www.seeedstudio.com/Grove-Ultrasonic-Distance-Sensor.html?gclid=EAIaIQobChMI5fKn6rOn8wIVPXNvBB1GFgkpEAQYASABEgIsTvD_BwE


Related Hardware Arduino Due/Mega

ARC Pro

Upgrade to ARC Pro

ARC Pro will give you immediate updates and new features needed to unleash your robot's potential!

PRO
Synthiam
#1   — Edited

Looks like it should. Specify the trigger and echo to be on the same port

#2  

Thanks DJ.  I’m going to order one to test. Cheers

#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() { Serial.begin(9600); } void loop() { long RangeInCentimeters1; long RangeInCentimeters2;

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

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

delay(250);

}

Thank you in advance. Cheers

PRO
Synthiam
#4  

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

Quote:

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

PRO
Synthiam
#5  

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

PRO
Synthiam
#6  

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! Cheers

PRO
USA
#8  

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

JSN-SR04T 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.

A02YYUW 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

EzAng

#9  

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. cheers