Welcome to Synthiam!

Program robots using technologies created from 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 Dunning-Kruger!

Hc-Sr04 Shows Only 255

I am trying to get the HC-Sr04 sonar to work with the EZB. I use the add for my project, select radar view and the value stays at 255. I am using port D0 and D1. Could the sensor be bad? It is brand new, just received it in box with other components.


AI Support Bot
Related Content
Based on your post activity, we found some content that may be interesting to you. Explore these other tutorials and community conversations.
I think I have the wiring correct, posted a close up photo
its the port names only I have reversed..does that matter...the wiring is correct
The green wire and the white wire shouldn't they be plugged into D0,D1 white pins? Looks like from your picture you have the green wire plugged into the RED pin on the EZB...

Black wire goes to black pin on EZB (D0)
Red wire goes to red pin on the ezb (D0)
White wire will be either white pin of the EZB on D0 or D1
Green wire will be on white pin of the EZB either D0 or D1
Forget my last post... Try reversing green and white... Look at the back of the Ping make sure the trigger goes to the EZB on the correct pin meant for the trigger and the same for the echo wire... D0 is your trigger (white or green) and D1 is your echo (white or green)...
From your last post (picture)... Green is your echo (plug it into the echo on the back of the ping) D1... White is your trigger (plug it into the trig on the back of the ping) D0... make sure your ping control in ARC reflects that setup...
I have white on trigger going to d0 white
Then I have green on echo going to d1 white

nothing 255.
Ok... one last thing to check... is the voltage regulator outputting 5V? I see the led on in your pics, but that may not mean anything... Can you confirm with a multimeter?... If it is maybe you do have a duff ping sensor.... You'll need to contact ez robot and I am sure they will mail you out a new one right away...
Hi @dbeard,

Thanks for your photos they really help! A couple other quick checks for you:

The Default value of the Ultrasonic is 255 until an object passes in front of it, have you tried placing your hand in front of the sensor at a fairly close distance (ex: 6 inches)?

How high of voltage input are you providing to the EZ-B?

Do you have the voltage input (Vin) side of the provided Ultrasonic 5V regulator connected to the EZ-B side or to the Ultrasonic side? It should be on the EZ-B side.
Awesome Jeremie.... Never thought about the possibility the voltage reg could have been connected backwards... that might be it...
When this happened to me, I found that my Ping unit was fried. It just takes a split second to touch wires were they don't belong. You will be lucky if you haven't blown something. Good luck. I hope things will be fine for you. If you go back and see D.J.s video on HOW to do this, it will help.

my 2 cents.
Is there a new video showing how to use the ping with the inline voltage regulator? If not, the old video would not be much help to him... The ping could have been defective right from the factory.....
Good Morning. I verified that coming out of the regulator is ~4.9 volts. That is the side going out to the sensor, so I think that is good. I think everything is working fine except for sensor. Have ordered a new one and will be very careful to connect correctly before applying power. Thanks for all the support and suggestions.
You probably didn't ruin the sensor... More than likely it was duff from the factory... Glad you got it sorted out though...

United Kingdom
They are very sensitive sensors, even the slightest hint of static and they can play up.
Just wanted to update the thread. Received new sensor and it is working. Appreciate all the help.
Thanks again to everyone.
Hi, old thread here but just wondering, i picked up the 4 wire sensor utrasonic with no regulator so,can I just hook up ping and echo to the white signals on EZB-v4 but the +5v and ground separately to a 5 volt battery external,do I need to attach another ground also to EZ-B? Or just leave it absent? (signals ony)

edit.....So I tried it out with no other ground than the 5 volt ac adapter on the sensor with the radar window,it is showing multiple red dots near bottom but hand in front of sensor then shows a red ping further to top of radar window and motors go into obstacle turning so I guess I can just run the sensor with it's own battery and nothing but signal wires to white ports EZ-B?will his cause any future harm if no extra ground to EZ-B?

next edit.....so since I was getting crazy random pings everywhere,thought I would add the ground wire on eZ-B and then $$bingo all the random pings stopped,now i was getting accurate steady red dot line showing the roof as my sensor was facing the roof and when I put my hand in front of sensor it showed up a red dot on radar closer to bottom,think that's it ,working good! :D
Yes, this is a very common oversight/mistake for folks newer to robotics and electronics, you always need interconnected grounds or "commons". This is the return path for electronics, with out a shared common connection for the ground the circuit would not be complete.

Good job solving your own question @RoboRad

Also (you already appear to know this) but as a reminder, do not exceed the 5volts for your ultrasonic sensor or you will damage it.