Connect with us

Eliminating ping sensor noise on an arduino

Discussion in 'Sensors and Actuators' started by liomry, Oct 4, 2012.

Scroll to continue with content
  1. liomry

    liomry

    16
    0
    May 7, 2012
    Hi all,

    So I have a ping sensor (HC-SR04) which I'm using as a rangefinder for my robotics project. Everything is working but I seem to be getting odd readings every couple of pings which I think is due to noise on the circuit. I've tried adding a 100nF ceramic capacitor across the 5v / ground as shown but that seemed to stop the ping from going beyond 12cm. Any ideas ? (I've tested the code and sensor when it's the only thing plugged into the arduino with no issues)

    If it makes a difference the arduino is sharing a 9.6v power source with a Raspberry Pi, maybe I need to put an electrolytic capacitor somewhere in that circuit?

    The 5v for the ping sensor is coming from the Arduino +5v rail.

    Currently on the Arduino I have this sensor and a serial connection to the Raspberry Pi. This serial connection is being used at every ping to report the distance measured.
     

    Attached Files:

  2. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,361
    2,756
    Jan 21, 2010
    Have you considered taking multiple readings and ignoring any outliers?
     
  3. liomry

    liomry

    16
    0
    May 7, 2012
    Hi Steve, thanks for getting back to me,

    I have considered this but it's a case that every second reading is incorrect, therefore if I drop one reading or if it picks the wrong group to start with the majority return will be incorrect.

    Incidentally the incorrect reading seems to start at 66cm and then very slowly drop towards 0, I've seen it reach 59cm within ~ 8 mins. This is what leads me to believe that there's something funny with the circuit, maybe ground isn't 100% free of current?
     
  4. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,361
    2,756
    Jan 21, 2010
    You could try adding a (say) 10uF capacitor in parallel with the 0.1uF capacitor. It may help if the problem is noise.

    I have one of these devices, but I haven't ever played with it.

    Have you considered that it might be a bug in your code? If it happens every second reading, it sounds too regular to be random.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-