Electronic – Averaging switch sensor value

switches

I have a float switch that has three possible positions- open when above the water level, closed when below the water level, and rapidly opening and closing (freq~=0.1s) when its near the water level. I need to be able to distinguish bouncing around from the other two while only sampling the voltage across the switch every 1-2 seconds. I thought I could use an RC circuit to do this but my electronics background is fairly weak. I put together the following diagram:

schematic

simulate this circuit – Schematic created using CircuitLab

I think this circuit has a time constant of 1s which should roughly give me the average switch value over the last 1 second or so. I think the current should be 1mA, which I think is appropriate for reading on an Arduino. Should this work? Is it a good way of solving this problem?

Best Answer

What is V1 exactly, does it have any internal resistance? Does the switch has any internal resistance?

I think you may have two choices:

  1. Since the switch only changes at 10Hz. You may sample the signal with Arduino ADC at 100Hz, which is easy for Arduino to achieve. Then you can implement averaging algorithm in your Arduino. Say you need the readings every one second, then you can average 100 points every second, using a timer.

  2. Do it in analog way, like yours. You may need a voltage follower, which has low output resistance. The output resistance of your current circuit is high for the input resistance of an ADC. And you may get an inaccurate result. This is a voltage follower: http://www.learningaboutelectronics.com/Articles/Voltage-follower