Capacitor for filtering Sharp IR sensor.


// I know this was somehow discussed before but I am not sure it is ok to digg up old threads.

I have a sharp IR sensor, with working range from 20mm to around 150mm the problem is that its returned values are not very stable, it has “spikes”, the manual recommends connecting a 10uF capacitor around ground and +.

I am not sure what is the right capacitor for this, I just found that there are polarized and non-polarized capactors :-?
What I purchased today looks similar to this:

(sorry, forum doesn’t let me post images directly, you have to copy/paste url :frowning: ).

But mine shows zeros on that white strap, not “-”

My questions:

  • is this the one I need for this?
  • if this is polarized, then can I link two of these together to get a non-polarized one?
  • just to be sure: how should this be soldered? One end to the ground and one to the + ?


Most larger value capacitors are electrolytics like the picture you posted and are polarized - they need to be connected the right way round. Usually the shorter lead is the cathode (-) and the longer lead the anode (+). Electrolytics usually have a band or something marking the cathode as illustrated. Lower Voltage types are usually smaller and cheaper (16v is a common voltage) and are good for arduino use. You connect the - to gnd and the + to the data/ 5v pin. There shouldn't be a problem with the one illustrated. You can't connect polarised electrolytics 'back to back' as the one connected the wrong way round would take a dim view of it and possibly explode. Non polarised electrolytics are available but there is little point in using them for Arduino.

Thanks for the reply pluggy. Yes, it has a white stripe on shorter pin. Actual values on mine are: 10uF 50V 85º (4W) Is it ok to use? :o

Is it ok to use

More than OK it is virtually bullet proof for what you want to do with it.

Something must be wrong, I am afraid not to fry the Uno board. With just Adruino and capacitor it works ok, but when I connect the sensor, the Arduino software doesn't seem to find the board anymore, it says that COM 3 cannot be found and these errors under it ... Any ideas? :-?

Serial port COM 3 not found

at javax.swing.JComponent.processMouseEvent(
at java.awt.Component.processEvent(
at java.awt.Container.processEvent(
at java.awt.Component.dispatchEventImpl(
at java.awt.Container.dispatchEventImpl(
at java.awt.Component.dispatchEvent(
at java.awt.LightweightDispatcher.retargetMouseEvent(
at java.awt.LightweightDispatcher.processMouseEvent(

EDIT: it worked after a few disconnects, I am not sure if it is because of the capacitor. I still see spikes though, I cannot see an improvement; maybe sensor values are just not as stable as I expected. :-/

I am not sure if it is because of the capacitor.

No it is not. It could be you were shorting the supply or drawing too much current from it.

I cannot see an improvement;

If you have connected it correctly then there should be an improvement. The other thing to try is averaging the results in software.

maybe sensor values are just not as stable as I expected

That is a distinct possibility.

Since you mentioned drawing too much current... I used the IR sensor with a piezo buzzer and I was supposed to use a resistor with the buzzer but I didn't. The resistor is supposed to limit the amount of power draw from the board?

Not using a resistor will damage the pin it is connected to but wouldn't cause the system to disconnect like you are seeing.